Part 4: Production

Evals and end-to-end testing

Turn "it seems better" into a number that blocks a bad merge, from one tool call to a whole conversation

BuilderLeaderSoloOpsClaude16 min read

In short

A change is not tested until something ran the agent and a number could have gone red.

Key ideas

  • Grade end state first, trajectory policy second, style with a pinned judge last
  • Report pass^k, not average success, for customer-facing flows
  • Gate on replay in CI; let agents write and repair tests, never run the gate

A summary only. The reasoning, examples, checklist and what to do on Monday are in the chapter. Read it in the book

52.4%

of surveyed teams run offline evals

61.2% to <25%

pass^1 to pass^8, tau-bench retail

Inside the chapter

  1. 1Why evals are the biggest gap
  2. 2Five kinds of evals
  3. 3Building the dataset
  4. 4Metrics: definitions that end arguments
  5. 5Graders and judges
  6. 6CI tiers: gate on replay, learn on live runs
  7. 7Agents writing your E2E tests
  8. 8Online evals and tooling (as of late 2026)

Try it: pass^k

pass^k is the chance a task passes all k trials: p to the power k.

pass^1

90%

pass^4

65.6%

Consistency drops fast

At 90% per run, all 4 runs pass only 65.6% of the time. Gate risk-tagged slices on pass^k, not on one lucky run.

tau-bench style metric. Your p comes from your own eval runs.

Go further: free on this site

Questions readers asked about this chapter, a 5-question self-check with explanations, and every source it cites.

Questions readers ask (6)

6 questions. Open one to read the answer.

What will running evals cost us each month?

Illustratively, 300 regression cases x 3 trials x $0.15 is $135 per full run. On 40 pull requests and 30 nights a month: 70 x $135 = $9,450. Run only smoke (50 cases, one trial, $7.50) on pull requests, with replayed cassettes where you can, and the full suite nightly: 40 x $7.50 + 30 x $135 = $4,350. A batch discount lowers the nightly run further. Add judge tokens; use your own inputs.

I have no users yet. Where do my first 20 real cases come from?

From the work the agent will replace: the last 20 instances you did by hand (emails answered, leads researched, reports written), each with your answer as reference. Add questions prospects ask, in their own words. Then write five hard or risky cases: a refund above your limit, another language, an angry customer. Tag hand-written ones and replace them as real traces arrive.

For a RAG agent, how do I evaluate retrieval separately from the answer?

Store expected sources (document ids) on each case and grade retrieval with code: did the expected document appear in the top k, at what position? Check the retrieval tool alone and the full run's trace, since the agent may phrase its query badly. Grade the answer separately with a grounding judge given the retrieved text. Low recall means fix indexing, chunking or the query; good recall with poor grounding means fix prompt or model.

Who owns the eval set, engineers or domain experts?

Both. Engineering owns harness, fixtures, graders and the gate. A named domain expert (support lead, finance analyst, lawyer) owns expected outcomes and rubrics, because they decide what correct means. Enforce it with code-owner rules on expected outcomes, and budget their time, for example a few hours a month. Without a named expert, references go stale and evals stay green while quality drops.

Should the simulated user be the same model as my agent?

Prefer a different one, so they do not share blind spots. Profile-conditioned simulators track human judgments fairly well (Spearman's rho about 0.7, SimulatorArena), so seed personas from real sessions. Pin the simulator's version like a judge, keep its persona factual (what the user knows, wants, will reveal), and run it hotter than the agent. After a simulator upgrade, re-baseline, or you will read simulator drift as agent change.

Is it safe to commit cassettes to the repository?

Only after filtering auth headers and keys in vcr_config, with a secret scanner over cassettes in CI. Cassettes also hold full prompts and responses, so build test conversations from redacted or synthetic data only: replace names, emails and account ids with consistent fakes so trajectory checks still work. A repository is usually readable by more people than your trace store. If your SDK streams over websockets that an HTTP recorder misses, record behind your own model-client interface.

Answered in the book, not repeated here: See Chapter 9, Noise and determinism

Self-check (5)

Score: 0 / 5 (0 answered)

  1. Question 1 of 5

    A two-line prompt change made the agent stop asking for the order number before refunds. Which eval would have caught it most cheaply?

    Show the answer

    Answer: B.

    The regression is in the path, not the wording, and a three-line code grader on the trace catches it on every pull request. A tone judge would score the reply as fine, and manual playground checks are vibe evals that cannot be repeated.

  2. Question 2 of 5

    An agent succeeds on 75% of trials. Roughly how often do three trials of the same task all pass?

    Show the answer

    Answer: C.

    0.75 cubed is about 0.42: pass^k measures whether every attempt works, which is what a customer who asks three times feels. The 98% figure is pass@3, the chance that at least one of three passes.

  3. Question 3 of 5

    Your eval gate fails often without a real regression, and engineers re-run it until it turns green. What should you do?

    Show the answer

    Answer: A.

    A gate is only useful if a red result is believed, so its tolerances must match the noise of the suite. Removing it loses the protection, and fewer trials make the flapping worse.

  4. Question 4 of 5

    An agent processes a refund correctly but never asked the user to confirm. How should the E2E test grade it?

    Show the answer

    Answer: D.

    The chapter grades state, then policy, then style: a correct database is necessary but not sufficient. Grading on outcome alone is the tempting answer and is exactly what tau-bench's authors warn against.

  5. Question 5 of 5

    A suite replays cassettes matched only on URL and method. A prompt change goes in. What is the risk?

    Show the answer

    Answer: A.

    With bodies ignored, any request to the same endpoint matches an old recording, which is how the composite case hid a regression for three weeks. Flakiness is the opposite problem: replay removes model variance rather than adding it.

Sources

Sources cited

  • LangChain, State of Agent Engineering, June 2026. langchain.com
  • Anthropic, Writing effective tools for agents, with agents, September 2025. anthropic.com
  • OpenAI, Introducing GPT-6.2 Astra and Sol, November 2026. openai.com
  • Yao et al., τ-bench: A Benchmark for Tool-Agent-User Interaction in Real-World Domains, June 2024. arxiv.org
  • Arize AI (Aryan Kargwal), Why AI Agents Break: A Field Analysis of Production Failures, January 2026. arize.com
  • FastMCP, Tests (development docs), accessed November 2026. gofastmcp.com
  • Anthropic, Demystifying evals for AI agents. anthropic.com
  • Snorkel AI, Terminal-Bench 4.1 hardens the verifiers behind the scores, November 2026. snorkel.ai
  • OpenAI, The Hugging Face incident and the road ahead, August 2026. openai.com
  • Promptfoo, LLM red teaming guide (open source), accessed November 2026. promptfoo.dev
  • Inspect Evals (UK AI Security Institute), AgentDojo: A Dynamic Environment to Evaluate Prompt Injection Attacks and Defenses for LLM Agents, accessed November 2026. ukgovernmentbeis.github.io
  • Sierra, tau-bench (GitHub repository), accessed November 2026. github.com
  • Sierra Research, tau2-bench / tau3-bench README (GitHub), July 2026. raw.githubusercontent.com
  • Sierra, tau-bench leaderboard, accessed November 2026. taubench.com
  • SimulatorArena: Are User Simulators Reliable Proxies for Multi-Turn Evaluation of AI Assistants?, October 2025. arxiv.org
  • LangChain, Multi-turn simulation (LangSmith docs), accessed November 2026. docs.langchain.com
  • Barres et al., τ²-Bench: Evaluating Conversational Agents in a Dual-Control Environment, June 2025. arxiv.org
  • Wikipedia, Binomial proportion confidence interval, accessed November 2026. en.wikipedia.org
  • Anthropic, Quantifying infrastructure noise in agentic coding evals, February 2026. anthropic.com
  • Scale Labs, SWE-bench Pro leaderboard, accessed November 2026. labs.scale.com
  • xAI, Grok 4.5, July 2026. x.ai
  • Anthropic, Building strong safety evaluations, November 2026. anthropic.com
  • OpenAI, How to make your completions outputs consistent with the new seed parameter, November 2023. developers.openai.com
  • Thinking Machines Lab, Defeating Nondeterminism in LLM Inference, September 2025. thinkingmachines.ai
  • LangChain, Integration testing (LangChain Python docs), accessed November 2026. docs.langchain.com
  • Kiwi.com, pytest-recording (GitHub repository), accessed November 2026. github.com
  • Anthropic, Migrating our Messages API to Rust, November 2026. anthropic.com
  • Daniel Roedler, Octomind, AI doesn't belong in test runtime, accessed November 2026. dev.to
  • Microsoft, Playwright MCP (GitHub repository), accessed November 2026. github.com
  • Browserbase, Stagehand v3 (changelog), October 2025. browserbase.com
  • Anthropic, Computer use tool (Claude docs), accessed November 2026. platform.claude.com
  • Playwright, Release notes, accessed November 2026. playwright.dev
  • Playwright, Test agents. playwright.dev
  • SD Times, The False-Heal Problem in AI Test Automation. sdtimes.com
  • Alshahwan et al. (Meta), Automated Unit Test Improvement using Large Language Models at Meta, February 2024. arxiv.org
  • Mündler et al., SWT-Bench: Testing and Validating Real-World Bug-Fixes with Code Agents, June 2024. arxiv.org
  • WebTestBench: Evaluating Computer-Use Agents towards End-to-End Automated Web Testing, March 2026. arxiv.org
  • ClickHouse, ClickHouse welcomes Langfuse: The future of open-source LLM observability, January 2026. clickhouse.com
  • OpenAI, OpenAI to acquire Promptfoo, March 2026. openai.com
  • Arize AI, License (Phoenix docs), accessed November 2026. arize.com
  • PyPI, inspect-ai (0.3.292), November 2026. pypi.org
  • OpenAI, Deprecations (API docs), accessed November 2026. developers.openai.com
  • AWS, Release notes for Amazon Bedrock AgentCore, accessed November 2026. docs.aws.amazon.com
  • Google Cloud, Introducing Gemini Enterprise Agent Platform, powering the next wave of agents, April 2026. cloud.google.com

Further reading

  • Hamel Husain, Using LLM-as-a-Judge For Evaluation: A Complete Guide, October 2024 (updated 2026). hamel.dev
  • Hamel Husain, A Field Guide to Rapidly Improving AI Products, March 2025. hamel.dev
  • Anthropic, A statistical approach to model evaluations, November 2024. anthropic.com
  • vcrpy, Advanced features (documentation), accessed November 2026. vcrpy.readthedocs.io