How to evaluate an AI agent: tests that catch failures
Run the agent on 20 to 50 tasks taken from real failures, each in a clean environment and more than once. Grade the outcome with code first, the transcript for limits, and an LLM judge only for what code cannot check. Why pass^k matters for an agent customers use.
Tecyfy · Published · 8 min read

To evaluate an AI agent, run it on 20 to 50 tasks with a known right result, each in a clean environment and more than once, and grade what it changed. Check the outcome with code first (is the refund in the database, do the tests pass), add limits on the transcript for rules that hold whatever the path, and use an LLM judge with a written rubric only for what code cannot check.
An agent is harder to test than a single prompt. It takes many steps, calls tools, changes things, and may take a different path each run. A test that reads only its last message can miss what the agent actually changed: it may say the job is done when it is not.
The words, in the order they happen
Five of the terms Anthropic's engineering team defines make the rest of this easier to follow:, and they make the rest of this easier to follow:
- A task is one test: an instruction and a way to tell if it worked. "Refund order 1042, which arrived broken."
- A trial is one run of the agent on that task.
- The transcript is everything that happened in the trial: the model's messages, tool calls and tool results.
- The outcome is the state of the world at the end. The agent may say "your refund is done"; the outcome is whether the refund exists in the payments table.
- A grader checks part of the transcript or the outcome and scores it.
1. Collect tasks from real failures
Start with 20 to 50 tasks taken from what went wrong: support tickets the agent mishandled, bugs your team fixed by hand, requests that confused it. Anthropic's advice is that this is enough at first, because early changes often have large effects.
Write each task so that 2 people who know the domain would give the same verdict. If they would argue, the task is vague and its score will be noise. Include tasks where the agent should not act as well as ones where it should: a refund it may issue, and one over its limit that must go to a person. An eval with only the first kind can leave you with an agent that refunds almost everything.
2. Give every trial a clean start
Each trial should begin from the same fresh state: a new copy of the database, an empty folder, a reset sandbox. Anything left over from an earlier trial can make failures that are not the agent's fault, or help it cheat. Anthropic saw Claude score better on some tasks by reading the git history left by earlier trials.
3. Grade the outcome, then the limits, then the rest
Use graders in this order:
- Code that checks the outcome. Query the database, run the unit tests, read the file. It is fast, cheap and gives the same answer every time.
- Code that checks the transcript. Count the turns, the tokens and the tools called. Use it for rules that hold whatever path the agent takes: the refund tool must not run without approval, the task must finish in under 10 turns.
- An LLM judge with a rubric, for what code cannot see: was the reply polite, did it explain the delay. Write the rubric as pass or fail questions, and check the judge against a person's verdicts before you trust it. LLM as a judge: how to write a rubric you can trust covers that.
Resist checking for an exact sequence of tool calls. Agents find valid routes the test did not expect, and a test that fails them punishes good work. Check what the agent produced.
4. Run each task more than once
The same agent on the same task can succeed on one trial and fail on the next. So run each task several times and decide which number you care about:
- pass@k, the chance that at least 1 of k trials succeeds. It suits a tool where one good result is enough, such as generating code a person picks from.
- pass^k, the chance that all k trials succeed. It suits an agent that customers use, who expect it to work every time.
At 75% per trial, 3 trials give a pass@3 of 98% and a pass^3 of 42%. The 2 numbers tell opposite stories about the same agent. Move the sliders to see how fast they part.
the same for every task, to keep the sum simple
each from a clean start
20 tasks × 3 trials
pass@398%passes at least once
pass^342%passes every time
An agent that passes 75% of trials, run 3 times on each task: pass@3 is 98% (at least 1 success) and pass^3 is 42% (every trial passes). In this run, 20 of 20 tasks passed at least once and 6 passed every time.
pass@k = 1 − (1 − p)^k and pass^k = p^k, for a success rate p on each trial. Real tasks differ in difficulty, so measure p per task from your own runs.
5. Read the transcripts
A score tells you something failed; the transcript tells you what. Read the failed trials, and some of the passing ones. You are looking for 2 things: mistakes by the agent, and tests that marked a good answer wrong. With a frontier model, a task that fails across many trials (say 100) most often means the task or its grader is broken, not the agent.
Write a short note on each failure, then group the notes. The groups (wrong order looked up, refund over the limit, promised a date it cannot know) become your next tasks and your next fixes.
6. Keep 2 sets: capability and regression
- A capability eval asks "can it do this yet?" Its pass rate starts low, and you work to raise it.
- A regression eval asks "does it still do everything it used to?" It should pass close to 100% of the time, and any drop means something broke.
When the agent handles a capability task reliably, move it into the regression set and run that set before every change ships.
How to tell a real gain from noise
With 30 tasks, one more pass moves the score by about 3 points. Before you celebrate a 5-point gain, report the score with its standard error and compare the old and new agent on the same tasks, as Anthropic's statistical guide recommends. The eval sample size calculator says whether a change is likely real and how many tasks you need to see one of a given size.
The capstone of the free AI engineering course puts all of this in one script: 12 end-to-end cases for a support assistant, outcome and transcript checks, the projected monthly bill, and an exit code that stops the release when any case fails.
Questions
- How do you evaluate an AI agent?
- Give it tasks with a known right result, run each one in a clean environment, and grade what it changed: is the refund in the database, does the code pass its tests. Add limits on the transcript (turns, tools it must not call) and an LLM judge with a written rubric for what code cannot check, such as tone. Run each task several times, because the same agent does not do the same thing every time.
- How many test cases does an agent eval need?
- Anthropic suggests starting with 20 to 50 simple tasks drawn from real failures. Early changes often have large effects, so a small set shows them. To tell a small improvement from noise you need more, and the eval sample size calculator works out how many.
- What is the difference between pass@k and pass^k?
- pass@k is the chance that at least 1 of k trials succeeds; pass^k is the chance that all k succeed. With a 75% success rate on each trial, 3 trials give a pass@3 of 98% and a pass^3 of 42%. Use pass^k for an agent customers rely on every time, and pass@k for a tool where one good result is enough.
- Should I check the agent's tool calls or its result?
- Mainly the result. Anthropic found that checking for an exact sequence of tool calls makes tests brittle, because agents find valid paths the test did not expect. Check the outcome, and add transcript checks only for rules that matter whatever the path: a refund tool must not be called without approval, the task must finish in under 10 turns.
- What is the difference between a capability eval and a regression eval?
- A capability eval asks whether the agent can do something yet, so its pass rate starts low and you work to raise it. A regression eval asks whether it still does everything it used to and should pass close to 100% of the time. Tasks move from the first to the second once the agent handles them reliably.