Agent Evaluation Framework
Decide what good means, measure it the same way every time and let the evidence decide what ships.
An evaluation framework is a repeatable way to answer "is this agent good enough, and better than before?" It has a set of tasks with success criteria, a harness that runs them, graders that judge results and rules that turn scores into decisions. Use it offline before release and online with real traffic after.
What you will learn: the parts of a framework, how to define success, offline versus online evaluation, outcome verification, a runnable comparison with a release gate and a reference architecture.
Prerequisites: Agent Testing: Unit to End-to-End.
Why you need one
Without evaluation, changes are judged by a few impressive or disappointing examples. A prompt edit that fixes one complaint can quietly break five other behaviors. A framework gives every change the same examination, so you can improve on purpose.
| Part | Meaning | Example |
|---|---|---|
| Task | One situation with a goal | "Cancel my order A1" |
| Environment | The world the agent acts in | Sandbox with two open orders |
| Trial | One attempt at a task | Run 3 of 10 |
| Trace | What happened during a trial | Messages, tool calls, timings |
| Grader | Judges a trial | Is only A1 canceled? |
| Suite | A group of tasks with a purpose | Order handling, policy refusals |
| Gate | The decision rule | No suite may fall by more than two points |
Define success before measuring
Write criteria that two reasonable people would apply the same way. Cover what must happen, what must not happen and the limits.
| Dimension | Example criterion |
|---|---|
| Outcome | The booking exists with the requested date and room |
| Constraints | No other booking changed; no spend without approval |
| Grounding | Stated facts match the tool results |
| Communication | The reply says what was done and what remains |
| Efficiency | Within the step, time and cost budget |
Offline and online evaluation
| Aspect | Offline | Online |
|---|---|---|
| Data | Curated tasks | Real use |
| Timing | Before release | During operation |
| Ground truth | Known expected outcomes | Often unknown; inferred or sampled |
| Risk to users | None | Real, so limit exposure |
| Good at | Comparing versions, catching regressions | Finding new situations and real-world value |
| Weak at | Cases nobody thought to include | Controlled comparison and rare harms |
Online methods
- Shadow runs: the new version processes real requests, but its actions and replies are not used.
- Canary release: a small share of traffic, with automatic rollback on bad signals.
- Controlled experiment: compare versions on similar groups using outcomes that matter.
- Sampled review: people grade a random sample, plus all high-risk and flagged cases.
- User signals: corrections, repeat contacts, abandonment and explicit ratings, read with care.
Shadow runs need protection: replace anything that changes data with a stand-in, or the "unused" version will still act.
Who decides what good means
Engineers can build a harness, but they should not invent success criteria alone.
| Role | Contributes |
|---|---|
| Domain expert | Correct outcomes, important exceptions, hard cases |
| Product owner | Which user tasks matter most and what trade-offs are acceptable |
| Risk or security | Hard stops and required scenarios |
| Engineer | Harness, graders, reproducibility and speed |
| Support and operations | Real failures and early warning signs |
A good test of a criterion is disagreement: give three borderline examples to two reviewers separately. If their verdicts differ, rewrite the criterion before automating it.
Task-based evaluation and outcome verification
Evaluate tasks, not isolated replies. An agent may say "Your order is canceled" while the system disagrees. Verify the outcome in the environment.
| Task type | Verification |
|---|---|
| Change a record | Query the record; check others are untouched |
| Write code | Run tests the agent could not alter |
| Answer from documents | Check key facts and that citations support them |
| Research | Rubric for coverage and source quality; spot-check claims |
| Refuse or escalate | Confirm nothing changed and the right route was offered |
Choosing tasks
Start with a few dozen real or realistic cases drawn from requests, support records and past failures. Include easy, typical and hard ones, tasks where the right result is to do nothing, and each user group you serve. Anthropic's article on evaluating agents recommends building from real failures and distinguishes two kinds of suite:
| Suite kind | Purpose | Expected pass rate |
|---|---|---|
| Capability | Shows what the agent cannot yet do | Starts low; improvement is the goal |
| Regression | Protects what already works | Close to perfect; any drop matters |
Anatomy of one task
Store tasks as data, so people can review them without reading harness code.
id: refuse-cancel-shipped
tags: [orders, policy]
start_state: order A3 has status "shipped"
user: "Please cancel order A3, I changed my mind."
pass_if:
- order A3 is still "shipped"
- no refund was created
- reply explains the return process
must_not:
- claim that the order was canceled
owner: support-lead
why: A past release told customers shipped orders were canceled
The why line saves a future colleague from deleting the task as redundant. The must_not list captures harms that an outcome check alone would miss.
Graders
| Grader | Strength | Limit |
|---|---|---|
| Code check | Fast, repeatable, clear | Only for checkable properties |
| Reference comparison | Useful where a right answer exists | Can reject valid alternatives |
| Model grader | Judges meaning at scale | Bias and variation; needs calibration |
| Human expert | Best judgment of nuance | Slow, costly, can disagree |
Grade separate dimensions separately. One blended score hides the case where answers became friendlier and less accurate.
A comparison with a release gate
This program compares two versions of a stand-in agent. Each task runs fifty times. The grader looks only at what changed, ignoring the agent's claim. Results are grouped by tag, with a confidence interval, and a gate blocks the release if any group falls by more than two points.
"""Run tasks several times, grade the end state, compare two versions."""
import math
import random
TASKS = [ # (id, tag, expected end state)
("cancel-1", "orders", {"A1": "canceled"}),
("cancel-2", "orders", {"A2": "canceled"}),
("refuse-1", "policy", {}), # correct outcome: change nothing
("refuse-2", "policy", {}),
]
def agent(version, task_id, rng):
"""Stand-in for a real agent run. Returns (claim, changes made)."""
order = "A" + task_id[-1]
if task_id.startswith("cancel"):
ok = rng.random() < {"v1": 0.80, "v2": 0.97}[version]
return "Done.", {order: "canceled"} if ok else {}
obeys = rng.random() < {"v1": 0.95, "v2": 0.75}[version]
return "Handled.", {} if obeys else {order: "canceled"}
def wilson(passes, n, z=1.96):
p = passes / n
mid = p + z * z / (2 * n)
half = z * math.sqrt(p * (1 - p) / n + z * z / (4 * n * n))
return (mid - half) / (1 + z * z / n), (mid + half) / (1 + z * z / n)
def evaluate(version, trials=50, seed=7):
scores = {}
for task_id, tag, expected in TASKS:
for t in range(trials):
rng = random.Random(f"{seed}-{task_id}-{t}")
_claim, changes = agent(version, task_id, rng)
passes, n = scores.get(tag, (0, 0))
scores[tag] = (passes + (changes == expected), n + 1)
return scores
base, new = evaluate("v1"), evaluate("v2")
total = lambda s: sum(p for p, _ in s.values()) / sum(n for _, n in s.values())
print(f"overall v1 {total(base):.0%} v2 {total(new):.0%}")
blocked = []
for tag in base:
(bp, n), (np_, _) = base[tag], new[tag]
low, high = wilson(np_, n)
print(f"{tag:7} v1 {bp / n:.0%} v2 {np_ / n:.0%} (v2 95% interval {low:.0%}-{high:.0%})")
if np_ / n < bp / n - 0.02:
blocked.append(tag)
print("release:", f"BLOCKED by {blocked}" if blocked else "allowed")
Output:
overall v1 88% v2 86%
orders v1 81% v2 99% (v2 95% interval 95%-100%)
policy v1 94% v2 73% (v2 95% interval 64%-81%)
release: BLOCKED by ['policy']
This is why averages mislead. The new version is far better at canceling orders, and the overall figure barely moves. Underneath, it has started making changes when it should refuse. A single average might have let that through; the per-tag gate stops it.
The range printed next to a rate shows how uncertain it is with this many trials, treating trials as independent. Real trials that share tasks are not fully independent, so treat the range as optimistic. More distinct tasks usually help more than more repeats.
Read the failures
Scores tell you that something changed; traces tell you why. After each run, sort failures into causes before touching the agent.
| Cause | Typical action |
|---|---|
| Agent misunderstood the request | Clarify instructions, or teach it to ask |
| Wrong or missing tool | Improve the tool set or descriptions |
| Missing information | Fix retrieval or context assembly |
| Broke a rule | Enforce it in code |
| Task is ambiguous or wrong | Fix the task |
| Grader error | Fix the grader and rescore old results |
| Environment fault | Repair the sandbox; do not count it either way |
The largest group is the next piece of work. Rows for task and grader errors are normal early on, and ignoring them teaches the team to distrust the whole system.
Reference architecture
Record enough to reproduce
For every result keep the code revision, model name and settings, prompt and tool versions, dataset version, environment seed, grader version and the trace. Without these, a score from last month cannot be compared with today's.
Designing the gate
| Rule | Example |
|---|---|
| Hard stops | Any unauthorized action blocks release |
| Per-group floors | Each critical suite stays above its minimum |
| No significant regression | Compared task by task with the current version |
| Budget | Cost and slow-end latency within agreed limits |
| Waivers | Named person, reason and expiry date |
Compare versions on the same tasks and look at which tasks flipped from pass to fail. A paired view is more informative than two totals, and reading those flipped traces is usually the fastest route to a fix.
Combining trials honestly
Decide in advance how several trials of one task count. For a helpful suggestion, "succeeds in at least one of five attempts" may describe a workflow where a person picks the best. For an action taken automatically, what matters is that it succeeds every time, so report the share of tasks passing all trials. The two figures can differ widely for the same agent. State which one each gate uses.
Can you trust the evaluation?
- Run a known-good and a known-bad agent; the scores should separate clearly.
- Read a sample of passes as well as failures. Graders are often too generous.
- Check that the agent cannot see expected answers or edit the checks.
- Calibrate model graders against human labels and repeat after changing the grader.
- Refresh tasks; repeated tuning against a fixed set inflates scores.
- Keep a held-back set you rarely look at.
Public benchmarks help compare models and ideas, but they are not your tasks, data or rules: see Agent Benchmarks and Datasets.
Managing cost and time
Run small, fast suites on every change and the full set before release. Use code graders first and model graders only where needed. Cache environment setup, but never cache the behavior under test. Track the evaluation bill as a normal operating cost.
Give every task an owner and a sentence explaining why it exists. A suite nobody understands gets ignored the first time it blocks a release.
What to watch online
Real traffic rarely comes with correct answers attached, so combine several imperfect signals and check them against each other.
| Signal | What it may show | How it can mislead |
|---|---|---|
| Task completion in the system of record | Work actually got done | Done does not mean done correctly |
| Reopened or repeated requests | The first answer failed | Some users simply leave instead |
| Human corrections and overrides | Where judgment differs | Reviewers may approve without reading |
| Escalation rate | Limits of the agent | A low rate can mean it should escalate and does not |
| Explicit ratings | User satisfaction | Few and unrepresentative responses |
| Sampled expert grading | Quality on real cases | Small samples miss rare harms |
Compare online grades with offline scores for the same version. A wide gap suggests the suite no longer resembles real use. Handle real conversations according to your privacy rules before adding them to any dataset, and remove personal details that the test does not need.
Rare and severe harms
Averages and samples are poor at finding events that happen once in many thousands of runs. Cover those with targeted adversarial tasks, hard limits in code and alerts on the action itself, for instance any transfer above a threshold. Evaluation reduces uncertainty; it does not replace controls.
A two-week starting plan
- Write success criteria for the three most important user tasks.
- Collect twenty to fifty cases, including refusals and past failures.
- Build a resettable sandbox and code graders for outcomes.
- Run the current version to set a baseline and read every failure.
- Agree a gate with the people who own the risk.
- Run it on the next change, then add sampled online review.
Framework checklist
- Success and failure are defined per task
- Outcomes are verified in the environment
- Tasks include cases where doing nothing is correct
- Results are reported by group with trial counts
- Versions of everything are recorded
- Gates have hard stops and accountable waivers
- Production failures flow back into the suite
Frequently asked questions
How many tasks do I need?
Enough to cover your important situations and to detect the size of change you care about. A few dozen good ones are far better than none; grow from real failures.
Should I buy an evaluation platform?
A platform can help with running, storage and review. It cannot decide what success means for your tasks, which is the harder part.
Can the agent's own model grade it?
It can, with care, but it may favor its own style. Calibrate against people and consider a different grader.
What if the gate blocks a clearly useful change?
Fix the regression, or record a time-limited waiver with the risk owner. Do not quietly lower the threshold.
References and further reading
- Demystifying evals for AI agents (Anthropic)
- tau-bench: tool, agent and user interaction benchmark (paper)
- NIST AI Risk Management Framework
Next steps
Task, Tool and Planning Metrics
Choose measures that matter.
LLM Judges, Human Review and Ratings
Grade meaning reliably.
Continuous Evaluation, Statistics and Scorecards
Keep measuring in production.