07. Evals in Production#
Level: Practitioner · Reading time: 20 min · Exercise: 75 min Prerequisites: A Minimal Evaluation Harness, Statistics for Evals
In one sentence: After this chapter you can record a trace of every attempt, choose online metrics that mean something, gate each change on a regression run, and turn production failures into new evaluation tasks.
Why this matters#
The agent passed the offline evaluation and shipped. Two weeks later the escalation rate, the share of calls handed to a person, climbs. Offline you tested 60 tasks that you wrote yourself. Production sends thousands that you did not write, and their mix changes every week.
The question: how does evaluation continue after release?
The core idea#
Three activities feed each other:
- Observe. Record what happened, attempt by attempt.
- Measure. Turn those records into a few numbers you trust.
- Return. Turn production failures into tasks, run them as a regression check on every change, and ship the next version.
The loop is often called a data flywheel: each release produces evidence that makes the next evaluation more like the real world.
Figure 1. The data flywheel: production failures come back as dataset tasks and as a gated change.
flowchart TD
R["Release a version to users"] --> O["Observe: a trace for every attempt"]
O --> M["Measure: online metrics split by intent"]
M --> F["Find failures: escalations, repeats, rule hits"]
F --> L["A person labels each failure"]
L --> D["New tasks in the dataset"]
D --> G["Fix the largest class, gate the change on a regression run"]
G --> R
Each turn adds real tasks, so the next version is judged on real failures.
Clay Bavor of Sierra describes what changed. Before agents, he says, most calls to a call center were never transcribed, so nobody could analyze them or run a controlled experiment on them. With agents every conversation is digital, and the methods of twenty years of website testing apply to conversations (14:00).
A trace is the recorded trajectory of one attempt in production. Observability is being able to ask questions of all your traces.
The analogy, and where it breaks. Tracing is logging, as you know it from servers and request IDs. It breaks on one point: an agent's trace is also its explanation. The answer alone does not tell you why the agent refunded the wrong order. The tool calls do.
How it works, step by step#
1. Log a trace for every attempt#
| Field | Why it is there |
|---|---|
request |
To reproduce the attempt |
calls, with arguments and results |
To see the route, not only the destination |
answer |
What the user actually saw |
model, prompt_version |
To know which system produced it |
tokens_in, tokens_out, latency_ms |
Cost and speed |
outcome |
The label you evaluate on later |
Requests contain personal data. Bavor's list of what sits below the surface of an agent product includes detecting and encrypting personal information, and keeping traces for audit. Decide what you store before the first request arrives. Part 4 covers the security side: defenses and guardrails. Sierra's own trace tool, Bavor says, shows for one action everything that happened underneath, so that a team can see where the seconds go and run independent steps in parallel (38:00).
2. Choose online metrics that mean something#
| Metric | What it catches | What to watch for |
|---|---|---|
| Outcome from the system of record, the database that holds the real state of the business (refund issued, ticket reopened) | Real results | Exists only for actions that change state |
| Escalation or handoff to a person | Tasks the agent could not finish | Depends on your handoff policy |
| Repeat contact: the same customer returns about the same issue | Wrong answers that looked fine | Depends on recognizing the customer |
| Explicit feedback: ratings | Strong dissatisfaction and strong delight | Sparse, and skewed to strong feelings |
| Guardrail triggers | Attempts that broke a rule | Counts rule hits, not real harm |
| Latency and cost per resolved attempt | Slow or expensive answers | Meaningless without quality |
Always split these by intent, the kind of request. An average over all requests hides the one intent that broke. Part 8 covers the technique: slicing.
Use metrics that fit your job, not the ones that exist. Bavor's example is speech recognition in a voice agent. Word error rate, the share of words transcribed wrongly, is in his words "not at all the right metric" (22:00) for transcription quality, because it rewards transcribing the television in the background. His teams had to write their own metric, one that looks at the primary speaker only. His advice: "don't assume that whatever metrics are out there to measure a component of what you're doing is necessarily the right set of yardsticks" (24:00). Decide what a great experience is, then measure that.
Even a simple metric hides a definition. Latency looks easy to measure. For a voice agent, Bavor says, what matters is the time from the moment the person stops talking to the moment the agent starts to answer, not from the end of the audio the agent was analyzing. Detecting that the person really stopped is so hard that Sierra starts several reasoning attempts and keeps the one that fits (20:00). The time a model takes to answer also varies a lot: in his figures, the 90th percentile can be 500 milliseconds for one model and 2,500 for another. So Sierra sends the same request to the provider several times and uses the first answer that returns. For an evaluation this means two things. Define the start and the end of a latency measurement in the user's terms. And report a tail, such as the 90th percentile, the value that 9 of 10 attempts stay below, not only the mean.
3. Use user feedback with care#
Explicit feedback, such as a rating, is rare and biased toward strong reactions. Implicit signals, such as a customer rephrasing the same request three times, are plentiful and ambiguous. Use both to find conversations to read. Use people to label them. Sample the reading across intents and outcomes instead of reading the most recent ones.
4. Gate every change on a regression run#
Kästner describes continuous integration: a service that runs all tests whenever code is submitted, in a clean environment, and that can refuse to merge a change which breaks a test (chapter 14). People forget to run tests; the service does not.
For an LLM system the same works with three adjustments:
- Compare, do not just score. Run the main branch and the change on the same tasks and use a paired comparison.
- Use tolerance. A metric that moves by less than the noise is not a regression.
- Pin the conditions. Fix the model version, the temperature, and the seeds. A model name that silently points to a new version breaks the comparison.
5. Run the flywheel#
- Each week, pull the attempts that escalated, were re-asked, or tripped a guardrail.
- Have a person confirm each one's failure class. A model can suggest the label.
- Add each one to the dataset as a task record with the expected outcome and a tag.
- Fix the largest class and re-run.
- Keep a fresh sample of production tasks that you do not tune on. Check it monthly, so that a rising score on the regression set still means something.
Sierra's version. The agents handle 60% to 90% of incoming inquiries, in Bavor's figures, and hand the rest to people in a call center. A feature called Expert Answers looks at the common reasons for escalation, records how the human experts answered, and uses a model to write the new knowledge into the agent for later runs (42:00). The handoff is the failure, the expert's answer is the label, and the fix reaches the next version.
6. Test in production, carefully#
Kästner writes that testing in production complements offline testing. You observe the real system to see whether its behavior changed. You can inject a fault on purpose, known as chaos testing. You can show two versions to different users, which is an A/B test. And you limit it to a subset of users, with a way to roll back quickly (chapter 14). Bavor's contrast: to compare two conversations, a call center had to hand one script to 1,000 people and another to 1,000 more, and hope they followed it (14:00).
For an agent, a useful injected fault is a tool that returns an error. The question is whether the agent recovers or invents an answer.
Worked example#
A trace. One line of a .jsonl file, in which each line is one JSON object:
{"trace_id": "t-8f21", "time": "2026-11-24T09:14:02Z",
"model": "model-x", "prompt_version": "refund-v7",
"request": "Please refund order #1042.",
"calls": [["authenticate", {"ok": true}],
["lookup_order", {"order": "1042", "amount": 42.5}],
["refund", {"ok": true}]],
"answer": "I refunded $42.50 to your card.",
"tokens_in": 310, "tokens_out": 131, "latency_ms": 1840,
"outcome": {"escalated": false, "rating": null, "repeat_contact_48h": false}}
One online metric. The repeat-contact rate is computed from the outcome field:
import json
def repeat_contact_rate(path):
"""Share of non-escalated conversations whose customer returned within 48 hours."""
with open(path) as f:
traces = [json.loads(line) for line in f]
handled = [t for t in traces if not t["outcome"]["escalated"]]
return sum(t["outcome"]["repeat_contact_48h"] for t in handled) / len(handled)
The gate. It reuses the harness, shipped as examples/eval_harness.py. Save this file next to it and run python3 ci_gate.py: with -I Python does not look in the folder, and the import fails.
# ci_gate.py: keep it in the same folder as eval_harness.py
import sys
from eval_harness import DATASET, PROFILES, StubModel, regressions, run, summarize
def metrics(system):
return summarize(run(system, DATASET))
# In real use, `baseline` is a metrics file saved from the main branch and
# `candidate` is the system that the pull request builds.
baseline = metrics(StubModel("baseline", PROFILES["baseline"]))
candidate = metrics(StubModel("tuned", PROFILES["tuned"]))
bad = regressions(baseline, candidate)
print("regressions:", bad or "none")
sys.exit(1 if bad else 0) # exit code 1 fails the build
regressions: ['cost']
What to observe:
- The gate prints the one metric that got worse and exits with code 1. The three quality metrics improved. A person now decides whether the higher cost is acceptable.
- The trace records the route (
authenticatebeforerefund), the versions, and the outcome in one object. The trajectory checks and the online metric read the same record. repeat_contact_ratecounts only conversations the agent handled. An escalated call says nothing about whether the agent's answer would have held.
What the practitioners say#
Most of an agent product is not the model. Bavor shows a slide he calls the agent iceberg. Above the water sit the model, retrieval and tool use. Below it sit several dozen production concerns, among them observability and monitoring, changelogs, regression testing, user simulation, an experimentation framework, staged releases, and sampling for quality review (8:00).
Agents need a different development cycle. An agent is not deterministic: for a given input you cannot know the output in advance. So the lifecycle becomes build, test and optimize, continuously (12:00).
Simulate before and after launch. Sierra's simulations, described in the previous chapter on environments, are a hardened form of the τ-bench setup: synthetic databases and tools, and mock user personas that include an emotional state (36:00). Sierra's Voice Sims blog post says the simulations are generated as new conversation flows are added and run inside the delivery pipeline, gating releases. Simulation started at Sierra as a more efficient way to test: one agent plays the user (28:00).
Use AI to check AI, then add deterministic rules. Bavor's belief is that "the solution to most problems with AI is more AI" (40:00). Around the main agent sit smaller supervisor agents: one checks that it stays on task and answers only from the knowledge base, others watch particular tasks (40:00). A tool called Insights lets a customer ask open questions of its transcripts, such as what drives low customer satisfaction or why calls escalate (40:00). For attacks, he layers deterministic input checks, supervising models, internal rules, and output checks that end a session when the agent starts revealing its prompt (44:00). Systems of record are reached only through ordinary deterministic software with access controls. On the attack side, Sierra employs outside red-team companies and an internal group. One attack he mentions asked for the system instructions in Icelandic, written backwards (42:00).
Kästner's caution. Quality practices help only if they are used. Enforcement by tooling works better than good intentions (chapter 14). Part 8 covers production experiments in depth: testing and experimenting in production.
Pitfalls#
- Logging only the final answer. You cannot see the route. Fix: log every tool call with its result.
- No versions in the trace. You cannot tell which system produced a failure. Fix: model and prompt version on every record.
- Raw ratings treated as truth. Fix: sample and read, across intents and outcomes.
- One average over all requests. Fix: slice by intent.
- A flaky gate. An unseeded model, or a model name that changes underneath you. Fix: pin versions and seeds, add tolerance.
- The regression set becomes the whole truth. Scores rise on it and fall in production. Fix: a fresh held-out sample each month.
- No way back. Fix: a tested rollback before any production experiment.
- Production examples added without labels. A wrong expected answer poisons the set. Fix: a person confirms each one.
Try it#
Deliverable: tracing plus a gate, for one agent or for a script that calls a chat model.
- Write one JSON trace per attempt to a
.jsonlfile, with the fields from this chapter. - Define three online metrics for it. Write down which trace field each one uses.
- Add the gate script, and make it run on every change to the prompt.
You are done when one command over your trace file lists the last ten attempts that escalated, such as jq -c 'select(.outcome.escalated)' traces.jsonl | tail -n 10, and a deliberately broken change makes the gate exit with code 1.
Stretch goal: each night, score a random 5% of production attempts with your offline graders, and compare the result with your offline dataset.
Key takeaways#
- Evaluation does not end at release. Observe with traces, measure with online metrics, and return failures to the dataset.
- A trace is a trajectory: request, tool calls, answer, versions, cost, outcome.
- Use metrics that fit your job. Off-the-shelf component metrics can reward the wrong thing.
- Gate every change on a paired comparison against the main branch, with pinned conditions and a tolerance for noise.
- Keep a fresh sample of real tasks, so that the regression set does not become the whole truth.
- Test in production on a subset of users, with rollback.
Self-check#
- What must a trace contain so that a failure can be reproduced and diagnosed? A. Only the final answer and the time it took B. The customer's name, address and order history C. The request, each tool call and result, and the model and prompt versions D. The model's training data and settings
- Why does Bavor reject word error rate as a measure for a voice agent's transcription? A. It rewards transcribing background sound that the agent should ignore B. It is too cheap to be trusted C. It needs human labels for every call D. It is too slow for long calls
- What does the data flywheel add to the evaluation dataset? A. Synthetic tasks from a generator, unchecked B. Benchmark scores other companies published C. More model versions on the same old tasks D. Failures seen in production, confirmed by a person, with an expected outcome
- A change raises exact match and doubles the cost. What should the gate do? A. Pass silently, because quality rose on every task B. Report the cost regression so that a person decides C. Block the change with no override by anyone D. Change the token price until the cost looks smaller
- What is the role of a subset of users in testing in production? A. To speed up the rollout to every user B. To collect more ratings from willing customers C. To measure the effect of a change while limiting the damage it can do D. To collect more training data for the next model
- Why keep a fresh sample of production tasks every month? A. To check that scores on the regression set still predict performance on unseen tasks B. To grow the regression set faster each month C. To lower the cost of each evaluation run D. To calibrate a judge against human labels
Show answers
1. C. Without the route and the versions, a failure cannot be reproduced. 2. A. The metric measures every word in the audio. The agent should transcribe only the caller. 3. D. A production failure becomes a task with a label and a tag. 4. B. `regressions` lists `cost`. The exit code tells the pipeline, and a person makes the trade. 5. C. It is a controlled experiment with a rollback path. 6. A. Tuning against the regression set inflates its scores. The fresh sample is the check.Sources#
- Lecture: Clay Bavor, "Practical Lessons from Deploying Real-World AI Agents", UC Berkeley Agentic AI MOOC, Fall 2025: video · guide, used at the agent iceberg, every channel is digital, metrics that fit, AI to check AI.
- Reading: Kumar Pandya and Sachi Shah, "Voice Sims: test agents in real world conditions before they talk to your customers", Sierra blog (September 11, 2025): link.
- Book: Christian Kästner, Machine Learning in Production: From Models to Products (MIT Press, 2025), chapter 14, sections on continuous integration and testing in production: link.
Next#
→ the case study of Berkeley's green agent and white agent project, a course that asks students to build the evaluator first.