Courses / Agentic AI / Module 11
Module 11: Agent evaluation: task success, trajectory evals, simulation, regression suites in CI
12 h · theory 4 · hands-on 5 · project 2 · revision 1
You will be able to
- Measure task success and trajectory quality
- Simulate users and tools for repeatable tests
- Build a regression suite that runs in CI
- Track cost and steps per task
Capstone increment: Trajectory eval suite on 25 incident scenarios, run on every pull request.
Job-description skills: Evaluation of agents · Lab tools: deepeval, pytest
1. What to measure
Grade agents on four things: the outcome (did the task succeed: the incident fixed, the right ticket created, the right answer given), the trajectory (did it use sensible tools in a safe order), the cost (steps, tokens, money, time) and safety (any rule violated, any action without approval).
Outcome comes first. Grade the path only where it matters for safety or cost; many different paths can be fine.
2. Repeatable runs: simulated tools and users
Real tools make evals slow, expensive and flaky. Record tool responses for each scenario (or build small fake services) so every trial sees the same world, and check the end state of that world, not just the agent’s words: was the ticket created with the right fields, was the config value changed, was nothing else touched?
For conversational agents, simulate the user with a scripted or model-driven persona that answers clarifying questions, as τ-bench (tau-bench) does for customer-service agents. Keep scenarios in version control with their fixtures and expected outcomes.
3. Non-determinism: pass@k and pass^k
The same agent on the same scenario can succeed and fail on different runs. Run each scenario k times. pass@k (any of k tries succeeds) flatters an agent; pass^k (all k succeed), introduced with τ-bench, is closer to what users experience across many interactions. Watch how far apart they are.
Mean single-trial success 72% · pass@1 (any try works) 72% · pass^1 (every try works) 72%
| Scenario | One trial | pass@1 | pass^1 |
|---|---|---|---|
| Disk full on a worker | 98% | 98% | 98% |
| Expired TLS certificate | 95% | 95% | 95% |
| Bad deploy, clear rollback | 92% | 92% | 92% |
| Memory leak after release | 88% | 88% | 88% |
| Noisy neighbour on shared DB | 80% | 80% | 80% |
| Flaky upstream API | 74% | 74% | 74% |
| Config drift between regions | 65% | 65% | 65% |
| Two incidents at once | 55% | 55% | 55% |
| Misleading alert | 45% | 45% | 45% |
| Silent data corruption | 30% | 30% | 30% |
Guided experiments
- At k = 1 all three numbers match. Raise k to 8. Which metric would a vendor put on a slide, and which would an on-call engineer care about?
- “Bad deploy, clear rollback” succeeds 92% of the time. What is its pass^8? If the agent handles that incident type 8 times a month, how often does at least one go wrong?
- pass@k is the right metric in one case: when a cheap verifier can pick the working attempt. Which scenarios here could you verify automatically?
- You can only afford 3 trials per scenario in CI. Why is one run per scenario not enough to tell a 90% agent from a 70% one?
4. Grading: state, rules and judges
Prefer deterministic graders: end-state checks on the simulated environment, and trajectory rules (“set_config only after request_approval”, “never more than 10 steps”). Trajectory matching comes in modes: strict, unordered, subset and superset; use the loosest that still catches the failures you care about.
Use an LLM judge only for what code can’t check, such as the quality of an incident summary, and calibrate it against human labels as in the RAG Systems and GenAI courses.
5. A regression suite in CI
Start with 20 to 30 scenarios drawn from real incidents, including hard and adversarial ones. Run each 3 times on every pull request with simulated tools, report pass^3, average steps and cost per scenario against main, and fail the build on drops beyond the noise. Run the full suite with more trials nightly.
Every production failure becomes a new scenario. Over time the suite becomes the most valuable thing in the repo: it lets you change prompts, models and tools with confidence.
Hands-on: coding window
The coding window and the full VS Code lab are available after you sign in.
Sign in to codeLabs
Lab 11.1: 25 scenarios with fixtures
Write 25 incident scenarios with recorded tool responses, an expected end state and tags (easy, hard, adversarial). Make the agent’s tools read from fixtures in eval mode.
Expected: evals/scenarios/ with fixtures; one command runs a scenario offline.
Lab 11.2: Graders
Add end-state checks, trajectory rules (approval before change, step cap) and a calibrated LLM judge for summaries. Report each separately.
Expected: A per-scenario report with outcome, rules, judge score, steps and cost.
Lab 11.3: CI suite (capstone increment)
Run the suite with k = 3 on every pull request, compare pass^3, steps and cost with main, post a comment and fail on real drops.
Expected: A PR that breaks the approval rule fails CI with the scenario named.
Go deeper
Videos
- How to evaluate agent trajectories with AgentEvals · LangChain · ~12 min. Evaluating agent trajectories with AgentEvals: match modes and LLM judges.
- How To Build AI Evals · Hamel Husain · ~34 min. How to build evals that matter, from someone who has built them for many teams.
- τ-bench: Evaluating Real-World Tool-Agent-User Interaction · Andriy Batutin · ~7 min. The τ-bench paper explained: simulated users, tools and pass^k.
Further reading
- Paper τ-bench: A Benchmark for Tool-Agent-User Interaction in Real-World Domains · Yao et al., 2024. Simulated users, database end-state grading and the pass^k metric from this module.
- Paper AgentBench: Evaluating LLMs as Agents · Liu et al., 2023. Eight environments and the failure analysis of why agents get stuck.
- Interactive SWE-bench · Princeton NLP. The leaderboard and task format for coding agents graded by running real tests.
- Article Your AI Product Needs Evals · Hamel Husain. A practitioner's case for building evals first, with the levels of testing that work in production.
GitHub repositories
- sierra-research/tau2-bench: Simulated users and tool environments, and how pass^k is computed.
- langchain-ai/agentevals: Trajectory match evaluators (strict, unordered, subset, superset) and LLM-as-judge for trajectories.
- UKGovernmentBEIS/inspect_ai: A framework for agent evals with sandboxes, tools and scorers.
- confident-ai/deepeval: pytest-style agent metrics such as task completion and tool correctness.
Checkpoint quiz
Interview questions
- How do you evaluate an agent that takes actions, not just one that answers?
- Explain pass@k and pass^k. Which would you report to a customer?
- How do you make agent evals repeatable when tools and models are non-deterministic?
- Design a CI eval suite for an agent. What runs on every PR, and what nightly?
- Your agent’s success stayed flat but cost doubled after a prompt change. How would you catch and debug that?
Ask the professor
Sign in to ask questions about this module.
Discussion
Community discussion appears here once giscus is configured (see README).