Safely Roll Out an AI Agent
Prompt and model changes are production changes. The same discipline you apply to a code deploy — test offline, inspect against a stop list, roll a slice of traffic, watch the quality numbers, keep a one-call rollback — applies to an agent’ssystem_prompt, model, or knowledge-base update.
Orbit already ships each stage; this guide wires them into one pipeline.
The endpoint paths below are relative. Send them against
https://api.orbit.devotel.io/api/v1.
What the pipeline covers
- Choosing a model/runtime profile (chat vs voice vs retrieval).
- Grounding the agent in your knowledge sources, before launch.
- Defining the guardrail policy that shapes what can be said.
- Offline comparison of the candidate against the prompt in production.
- Graduated rollout that shifts one small traffic slice at a time.
- Automatic regression runs on every publish.
- Live scoring, drift detection, and a human-in-the-loop when you want it.
- A clean fallback to a person on a queue when a conversation needs one.
- The console surfaces for the same gates: gate settings, blocked-promotion alerts, the prompt diff, and the canary panel.
Prerequisites
- An agent you already have running, with an active production prompt. Build a WhatsApp and SMS AI Agent covers the messaging form end to end.
- An API key with
agents:read/agents:writescope. - The agent’s
version-aware runtime — canary, regression, and comparison endpoints all operate on saved versions, so read the agent versions surface first.
1. Choose the models — chat vs voice vs retrieval
A single agent seldom uses one model for everything. A chat surface tolerates a long reasoning model; voice needs one with a fast first-token; retrieval benefits from a cheaper reranker. Pick per surface.- Chat (SMS / WhatsApp / widget).
POST /agentsaccepts any Claude model. WhatsApp and SMS AI Agent covers the full build. - Voice. First-token latency matters more than depth. The voice handback guide is the pattern to copy, and it still applies here.
- Retrieval. Where you point
search_knowledgedoes most of the answering. Tune it with the retrieval benchmark below.
2. Load knowledge sources
The prompt is one input. The knowledge base is a second — bigger and more volatile. Create it, attach it to the candidate agent, then score retrieval before you spend time tuning the prompt.201 and returns the standard response envelope:
POST /agents/:id/retrieval-benchmark/runs
over your golden question set and read GET /agents/:id/retrieval-benchmark.
The run result contains recall_at_k for each scenario, so the CI gate can
reject a candidate that stops retrieving the documents its questions require.
scenarios keeps the per-question gate visible:
GET /agents/:id/retrieval-benchmark before
promoting. If recall is off, tune the knowledge sources first.
3. Define guardrails
The policy decides what the agent must and must not say, regardless of prompt. List policies, attach one to the candidate, then inspect its firing counts:{ data, meta } envelope. Read data.by_rule
for counts such as total, refused, escalated, and error:
4. Test offline
Never let a new prompt meet a live channel first.Persona simulation
POST /agents/:id/persona-simulation replays a scripted customer persona
against the candidate prompt and grades the whole conversation against a rubric.
Use the same scenarios on every candidate so the pass rate and mean score are
comparable.
200 response is an envelope. Gate on the aggregate values, then
inspect each scenario before allowing traffic:
Gate it in CI
Run the same two checks on every candidate version. These scripts deliberately fail closed: a missing field, a failed request, or a value below the pinned threshold exits non-zero. SetORBIT_AGENT_ID, ORBIT_VERSION_ID, and
ORBIT_API_KEY in your CI secret store.
Node.js (TypeScript)
Python
5. Roll out gradually
POST /agents/:id/canary-rollout starts a staged rollout for the
candidate version. The default ladder is 5% → 25% → 100%; override the
per-stage array to stay in your budget/error tolerance.
GET returns the current stage and its live scorecard verdict.
evaluate compares the running scorecard against the stage gates and
persists the decision (advance, hold, rollback, complete). rollback is
the operator kill-switch; cancel voids a rollout started by mistake.
6. Verify with regression tests
POST /agents/:id/regression-tests saves replayable conversations, and
POST /agents/:id/regression-tests/run-all runs them after each deploy.
7. Monitor in production
Three surfaces together tell you how the live rollout is doing:- Quality scorecard.
GET /agents/:agentId/quality-scorecard?window=7&min_sample=20computes the resolved rate, latency, cost, and customer-sentiment index from the conversation-outcomes ledger. - Fairness evaluation.
GET /agents/:id/fairness-eval/packlists the built-in paired-testing probes;POST /agents/:id/fairness-eval/runreplays them against a chosen attribute, flagging biased tracks before the rollout reaches 100%. - Loop detection.
POST /agents/conversations/:conversationId/loop-checkanswers whether the agent is stuck repeating itself on a live conversation. - Human oversight.
GET /agents/oversight/sessionslists live voice / chat with an oversight state; supervisor takeover and release endpoints bind a human to a problematic conversation.
8. Route to a human fallback
Some conversations should not stay with the agent at all.Worked example — promoting a WhatsApp support agent from 5% to 100%
You built the agent in WhatsApp/SMS form and want a more specific prompt that deflects refunds without sacrificing tone.- Save the candidate prompt as a version (
PUT /agents/:idwith the newsystem_prompt, orPOST /agents/:id/versionsif you pin by id). - Run
POST /agents/:id/persona-simulationon the refund scenario set — all pass or you stop here. - Run
POST /agents/:id/shadowagainst recent conversations and reviewGET /agents/:id/shadow-comparison?days=7for tone regressions. - Start the rollout:
POST /agents/:id/canary-rolloutwithstages: [5, 25, 100]. - After the first tick, read
GET /agents/:id/canary-rolloutand runPOST /agents/:id/canary-rollout/evaluate. A decision ofadvancetells you the 5% stage’s gates passed; hold means more sample is needed; rollback means the gates failed and the candidate is off live. - Run
POST /agents/:id/regression-tests/run-allat each stage; the candidate must pass the saved gate set before advancing. - Watch
GET /agents/:agentId/quality-scorecardandPOST /agents/:id/fairness-eval/runat each stage. - When the evaluator reports
complete, the candidate is serving 100%. If any tick returnsrollback, the server pinned the baseline back;POST rollbackperforms the same pull manually.
9. Run the same gates from the console
Everything above has a console surface on the agent’s Versions tab (Agents → your agent → Versions), so the pipeline can be run without leaving the dashboard. The tab is split into the version list, a Promotion gate tab, and the canary rollout panel. The mental model carries over one-to-one: a promotion (the per-version Restore action, the console equivalent ofPOST /agents/:id/versions/:vid/promote) is
refused while the gate is failing, so a candidate that regresses your
pinned checks never becomes live. The gate has two independent corpora,
and either one can block a promote:
- Saved regression tests — the deterministic, hand-written conversations from the Testing tab. Same semantics as the scripted regression gate: a fixed script replays the identical conversation on every run, so a failing result means the candidate changed behaviour, not the input. Block conditions: any test fails, a test cannot run, or none are saved yet.
- Pinned golden sets — judge-scored golden sets from the eval-suite runner, compared against the thresholds you set.
Set the gate up
In the Promotion gate tab, the Pre-promotion regression gate card holds the whole configuration:- Enable promotion gate — the master switch. Off by default; an agent that never opts in promotes exactly as before.
- Require saved regression tests — attaches the Testing tab suite to the gate with the block conditions above.
- Pinned golden sets — pick up to ten golden sets created in the eval-suite runner; each row shows its case count.
- Max P95 regression (0–10) — tolerated fraction slower than the
baseline, e.g.
0.2= 20% slower. - Max pass-rate regression (0–1) — tolerated judge pass-rate drop vs
the prior run, e.g.
0.1= a 10-point drop. - Minimum pass rate (0–1) — absolute floor that bites even on a candidate’s first run.
Read a blocked promotion
With the gate armed, attempt a promote that regresses, and the promote action for that version turns into a blocked notice instead of a button:- Blocked by the promotion gate: … — a regression or pass-rate floor breach, with the failing detail in the reason (which suite regressed, by how much).
- Blocked by the red-team safety gate: … — the adversarial safety pack fired; the reason names the failing category.
Review the prompt diff before you promote
Select a candidate in the version list and open its diff. The viewer compares the candidate against the previous version or live (production) via the selector, and covers the full versioned shape: the system prompt as a line-level split pane with added/removed highlights and a change count, configuration fields (model, temperature, max tokens) as a before/after table, and tools, knowledge bases, safety config, and the config bag as side-by-side JSON. Read it before every promote: the gate catches regressions in behaviour, but only the diff shows you what changed — a prompt edit you did not expect is a reason to stop regardless of scores.Promote with a rollback path
The staging arm of the pipeline lives in the same tab. The Canary rollout panel ramps a challenger version’s traffic share stage by stage (default ladder5, 25, 50, 100) while a quality scorecard (pass
rate, sentiment, latency, thumbs-down, errors) grades each stage. From
an active rollout:
- Check now — runs the stage evaluation: advance, hold, or roll back.
- Roll back — pulls the challenger off traffic immediately, whatever the scorecard says; the confirmation dialog warns it cannot be undone.
- Cancel — voids a rollout started by mistake.
Console vs API — division of labor
The console is the day-to-day surface: configure the gate once, attempt promotes, read block reasons, review diffs, and ride the canary panel. The API flow above is the automation surface: scripted persona simulation, shadow comparison, and regression runs wired into CI, plus everything the console wraps (GET|PUT /agents/:id/promotion-gate/settings,
the canary endpoints, and the promote/rollback calls). Both drive the
same persisted gate configuration and the same saved versions, so a gate
armed in the console enforces an API promote too. Author the regression
tests and golden sets in Agent evals: datasets, runs, and pass-rate
gates; for the QA grounding behind
the rubrics, see Run your first QA evaluation, from rubric to coaching
plan.
Troubleshooting
See also
- Build a WhatsApp and SMS AI Agent — the messaging form this pipeline rolls out.
- AI Voice Agent Handback — return an escalated voice call to the agent after a human step.
- Creating Agents — full agent configuration reference, including guardrails and escalation triggers.
- Agent versions — saved prompt configurations these rollout endpoints move between.
- Troubleshooting: promotion gate blocks —
decode
PROMOTION_GATE_FAILED/RED_TEAM_GATE_FAILEDwhen a promote is refused. - Handoff targets — the destination conversations route to when the agent hands off.