1. Fetch config at session start
One call registers the key on first use (your defaults become revision 1) and resolves the right revision per session.Cache the resolved config for the session; do not fetch per turn. Wrap the resolve in a try/except that falls back to your
DEFAULTS: the failure mode is then your current behavior, never a broken call. The SDK method ships in the next roark_analytics release; until you upgrade, the same call is one POST /v1/agent-config/{key}/resolve request.2. Link the config to your Roark agent
Autoimprove finds the config through the agent your calls already report. Link once:roark agent endpoint create if you have not already.
3. Run Autoimprove
Exactly the same as any other agent:AWAITING_PROMOTE, promote is a pointer swap: your very next session reads the verified revision. Rolling back is writing the prior revision back to production; the chain preserves every state.
4. Guard your tools (optional)
Roark’s test calls dial your production deployment, which means your real tools would run: real bookings, real SMS, real transfers. The tool guard fixes that. Wrap a side-effecting tool once; during a Roark test call it never executes. Instead, Roark answers with a simulated backend response that is shaped by the tool’s contract, consistent with the test scenario (a scenario about a fully booked calendar gets a realistic “no availability” from a booking tool), and consistent with earlier tool responses in the same call. You configure nothing per tool. Real callers always hit the real tool: the guard only diverts when the resolve response identified the session as a Roark simulation, and the endpoint independently re-validates the simulation before answering.book, cancel, send_sms, transfer, charge); leave read-only lookups unwrapped when live data makes the test more realistic. Pass the richest toolDescription you can: the contract is what shapes the simulated response. In LiveKit Agents, wrap the function before registering it with @function_tool; in Pipecat, wrap the handler before registering it on the LLM service. Identical retries within a few minutes return the stored response, so double-fired handlers stay consistent, and every mocked invocation is recorded against the simulation as evidence of what your agent tried to call.
The failure contract, precisely: 404 means the simulation id is unknown (treat the session as real), 409 means the simulation already ended (do NOT run the real tool; use your fallback), and any other error also means use your fallback. The roark_analytics SDK gains a first-class simulation.mock_tool(...) method in its next release; the decorator above works today. The guard is a simulations-wide feature, not an Autoimprove one: every Roark test call against your deployment gets safe tools, you can pin deterministic responses per tool with fixtures, and you can read back exactly what your agent called after each run. The full workflow, including CI assertions and automatic grading, is in the Tool Call Testing recipe.