Education › Evals & Harness › Stage 5: Building & improving harnesses

Shipping agents to production

Versioning prompts and tools, staged rollouts, feedback loops and operating agents safely.

Advanced ~45 min read Module 20 of 20

Running an agent for yourself is one thing; running it for thousands of users is a distributed-systems problem with an unpredictable component in the middle. Production agents need sandboxes provisioned per session, a gateway in front of model providers with quotas and fallbacks, durable session state, versioned prompts and harness configuration, audit logs, kill switches, and an incident process that understands model behaviour. This final lesson assembles everything in the track into a production architecture and a launch checklist.

After this module you can
  • Describe a production architecture for an agent service
  • Version and roll out prompts, tools and harness configuration safely
  • Handle provider outages, rate limits and per-tenant quotas
  • Prepare kill switches, audit logs and incident runbooks for agents
  • Run a launch review using a production readiness checklist

A production architecture

ComponentResponsibility
API and session serviceAuthenticates users, stores durable session state, streams progress
Agent workersRun the loop; stateless so they can scale and restart
Sandbox poolPre-warmed isolated containers or microVMs, one per session, destroyed after
Model gatewayRoutes to providers, enforces quotas, retries, fallbacks, caching, logging
Tool services and MCP serversBusiness actions with the user's permissions
Policy and approvalsPermission rules, approval queue, audit log
TelemetryTraces, metrics, online evals, cost tracking
Config and flagsVersioned prompts, tool sets, budgets, kill switches

Keep agent workers stateless and store session state (messages, task list, workspace snapshot references) durably, so a crashed worker or a deploy does not lose a user's task. Long tasks should survive restarts by resuming from the last completed step.

statesessionsactionscommandsmodel callsusageUsersAPI + sessionsauth, streamingSession storedurable stateTool servicesuser's permissionsAgent workersstatelessSandbox poolone per sessionModel gatewayquotas, fallbacksProvidersprimary + fallbackTelemetrytraces, cost
A production agent service: stateless workers resume sessions from durable storage, run actions in per-session sandboxes and tool services, and reach models only through a gateway with quotas and fallbacks.

Versioned configuration and rollout

Prompts, tool definitions, budgets and model choices are behaviour, so manage them like code: versioned in a repository, reviewed, evaluated in CI and rolled out gradually. Record the configuration version in every trace. Being able to roll back a prompt in one minute is as important as rolling back a deploy.

agent-config.yaml: one versioned unit of behaviour
yaml
version: 2026.10.1
prompt: prompts/support-v14.md
tools: [orders_search, orders_refund_preview, orders_refund, tickets_create]
models:
  primary: provider-a/large
  fallback: provider-b/large
  router_small: provider-a/small
budgets:
  max_steps: 30
  max_tokens: 300000
  max_seconds: 600
approvals:
  orders_refund: always
  tickets_create: never
rollout:
  canary_percent: 5
  guardrail_metric: unsafe_action_rate
kill_switch: false

Providers, quotas and fallbacks

  • Gateway: all model traffic passes through one internal gateway that holds keys, enforces per-tenant and per-user quotas, and records usage for cost attribution.
  • Rate limits: queue and smooth bursts; back off on provider limits; prioritise interactive sessions over background jobs.
  • Fallbacks: a second provider or model for outages, evaluated in advance on the benchmark so you know the quality you fall back to.
  • Timeouts: per call and per session, with clear user-facing messages when exceeded.
  • Cost controls: per-tenant budgets and alerts on spend anomalies, since a looping agent can burn money quickly.

Safety operations

Agents can take actions, so incidents can be actions, not only bad text. Prepare for that before launch.

Agent incidents differ from ordinary outages in one important way: the system may be up and fast while doing the wrong thing. Dashboards of errors and latency stay green. That is why online evals, unsafe-action metrics and user reports must feed the on-call alerting, and why the first response is usually to narrow what the agent may do (a tool, writes, a tenant) rather than to take the whole service down.

  • Kill switches at several levels: disable one tool, disable write actions, disable the agent for a tenant, disable it globally. They must work without a deploy.
  • Audit log of every consequential action: who, which session, which tool, arguments, approval, result. Keep it separate from debug traces and tamper-evident.
  • Runbooks for agent incidents: stop the behaviour, find affected sessions from traces, reverse actions where possible, notify users, add eval cases, then re-enable.
  • Data handling: retention limits for prompts and traces, redaction, regional storage where required, and clear user-facing disclosure that an AI agent is acting.
Kill-switch checks before every tool call
python
def check_switches(flags, tenant: str, tool: str, is_write: bool) -> str | None:
    if flags.get("agent_disabled") or flags.get(f"tenant_disabled:{tenant}"):
        return "The assistant is temporarily unavailable."
    if flags.get(f"tool_disabled:{tool}"):
        return f"{tool} is temporarily disabled; tell the user and offer a human handoff."
    if is_write and flags.get("writes_disabled"):
        return "Write actions are paused; prepare the change for a human to apply."
    return None

Launch readiness

  1. Evals: held-out benchmark meets the target with intervals; pass^k for key tasks; safety suite at zero failures; red-team findings fixed and added as cases.
  2. Isolation: sandboxes per session, no network by default, least-privilege credentials, approvals on irreversible actions.
  3. Operations: tracing, dashboards for success, cost and unsafe actions, alerts, on-call owner, runbooks, kill switches tested.
  4. Resilience: fallback provider evaluated, quotas and budgets set, sessions survive worker restarts.
  5. Rollout: canary percentage, success and guardrail metrics, rollback procedure rehearsed.
  6. Compliance: data retention, redaction, audit log, user disclosure and human escalation path.
Tip

Rehearse the bad day before launch: flip each kill switch in staging, fail the primary provider, and walk through reversing a wrong refund from the audit log.

Hands-on practice

Production review of your agent

  1. Draw your agent's production architecture using the components table and mark what you have and what is missing.
  2. Move prompts, tools, budgets and model choices into a versioned config file recorded in every trace.
  3. Add a gateway wrapper with per-user quotas, retries and a fallback model, and evaluate the fallback on your benchmark.
  4. Implement and test four kill switches without redeploying.
  5. Write a one-page incident runbook for a wrong-action incident.
  6. Run the launch readiness checklist and list the gaps with owners and dates.
Cheat sheet

Shipping agents to production — at a glance

Main things to focus on

  • Stateless workers, durable sessions, sandbox per session.
  • One model gateway: keys, quotas, retries, fallbacks, cost.
  • Prompts and harness config are versioned behaviour.
  • Kill switches at tool, write, tenant and global level.
  • Audit every consequential action; rehearse incidents.
  • Launch on evidence: held-out evals, safety at zero, rollout plan.

Architecture

session service + durable stateSurvive restarts
stateless agent workersScale and redeploy
pre-warmed sandbox poolFast isolation
model gatewayCentral control

Config

version, prompt, tools, modelsOne versioned unit
budgets: steps, tokens, secondsLimits
approvals per toolHuman control
rollout: canary + guardrailGradual release

Resilience

fallback model, pre-evaluatedOutages
per-tenant quotasFairness and cost
prioritise interactive trafficUnder load
spend anomaly alertsRunaway loops

Safety ops

kill switch: tool / writes / tenant / allNo deploy needed
audit log (tamper-evident)Accountability
runbook: stop, scope, reverse, notifyIncidents
retention + redaction + disclosureCompliance

Common pitfalls

  • Session state held only in worker memory.
  • Provider keys spread across services instead of one gateway.
  • A fallback model that was never evaluated.
  • Kill switches that need a deploy to flip.
  • Launching on a dev-set score without held-out and safety evals.
Quiz

Check your understanding

5 questions · 4 to pass · answers are explained as you go. Your best score is saved on this device only.

Progress and quiz scores are saved in this browser only. Back up or restore on the hub.

Was this lesson useful? Tell me what to improve →