Skip to main content
A LiveKit or Pipecat agent is your code on your infrastructure, so there is no provider document for Roark to edit. The managed-config integration turns that around: your agent fetches its tunable surface (prompt, model, params, voice) from Roark at session start, and Autoimprove works on that config with the same loop, safety model, and promote gate as provider agents. The key mechanic is per-session resolution: Roark’s test calls dial your production deployment directly. Because Roark originated those calls, the config endpoint recognizes them and serves the staging revision for those sessions only. Real callers always get production config; you deploy nothing extra.

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.
Autoimprove finds the config through the agent your calls already report. Link once:
Your agent also needs a registered phone endpoint (the number Roark’s simulations dial): roark agent endpoint create if you have not already.

3. Run Autoimprove

Exactly the same as any other agent:
What happens under the hood differs only in the staging story: instead of cloning a shadow, Roark forks a staging config channel from production. Its test calls dial your production number, get recognized, and read the staging revision; every change Roark makes is a new audited revision on that channel. Real traffic never sees any of it. When the job reaches 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.
Wrap the writes (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.

What Roark can and cannot improve here

Roark can change anything in the document you externalized: prompt, model and sampling params, and your STT/TTS choices (voice, speed, language) when you include them, as the example does. It keeps the key shape your code reads (it never renames keys). What stays in code (tool logic, pipeline structure) is out of reach by design; the job’s final report recommends those changes for a human when the config surface is not enough. Guarded tools are still out of reach for changes, but their invocations become testable: Roark sees what your agent tried to call with what arguments, with no real side effects.