How to test AI agents: tasks, trials and graders you can build this week
For agent builders4 min read

Here is how to test AI agents with a small eval: write a set of tasks with clear pass or fail conditions, run each task several times in a clean environment, and score what the agent changed rather than what it said. Twenty to fifty tasks from real failures are enough to start. This post gives the vocabulary, a short runner and the mistakes to avoid.
How to test AI agents: six words you need
Anthropic's guide to agent evals defines the terms most teams now use.
| Term | Meaning |
|---|---|
| Task | One test with inputs and success criteria |
| Trial | One attempt at a task; you run several because outputs vary |
| Grader | Logic that scores part of the result |
| Transcript | The full record of a trial: outputs, tool calls, intermediate results |
| Outcome | The final state of the environment when the trial ends |
| Eval runner | The system that runs tasks, records steps, grades and aggregates |
Source: Demystifying evals for AI agents(opens in a new tab)
Start from real failures
The guide suggests 20 to 50 tasks drawn from real failures as a solid start, and recommends building from what you already check by hand: pre-release tests, bug reports and support queues. Waiting for a perfect suite only makes it harder to build.
Write tasks so that two experts would independently reach the same verdict. Keep a reference solution for each one, to prove the task is solvable. And include cases where the agent should not act, otherwise you optimize for an agent that always does something.
A runner in thirty lines
The runner below runs every task several times and applies code graders to the outcome. The agent is a stand-in function. Replace it with a call to your own agent, and have it return the final state your graders need.
from collections import defaultdict def fake_agent(task, trial): # Replace with a real agent run in a fresh sandbox. # Returns the final state, not just the reply text. ok = (trial + len(task["id"])) % 4 != 0 return {"file_renamed": ok, "steps": 3 + trial} TASKS = [ {"id": "rename-report", "check": lambda s: s["file_renamed"]}, {"id": "rename-invoice", "check": lambda s: s["file_renamed"]},] def run_eval(tasks, agent, trials=5): results = defaultdict(list) for task in tasks: for t in range(trials): state = agent(task, t) results[task["id"]].append(bool(task["check"](state))) return results for task_id, outcomes in run_eval(TASKS, fake_agent).items(): print(task_id, f"{sum(outcomes)}/{len(outcomes)} passed")Three things in this runner matter more than they look. Each trial gets its own state, so one run cannot help the next. The grader reads the state, not the transcript text. And every outcome is kept, so you can compute more than one number later.
Run enough trials
A single run tells you little, because the same agent can pass and fail the same task on different attempts. Five trials per task is a cheap place to start. If a task passes in some trials and fails in others, do not average it away. That task is telling you the agent is inconsistent there, and it is often the most useful case in the set to read.
Choose graders by what they cost
The same guide lists three kinds. Code graders such as string checks, test runs and tool-call checks are fast, cheap and repeatable, but brittle on subjective work. Model graders score against a rubric and handle nuance, but they are non-deterministic and need calibrating against human judgment. Human graders set the standard and are the slowest.
Use code graders wherever the end state can be checked by a program. Add a model grader for tone or explanation quality, and spot check it with a person. Give a model grader an option to say unknown, which the guide recommends to cut down on invented grades.
Mistakes that make results meaningless
- Sharing state between trials, which creates correlated failures and inflated scores.
- Grading the exact path. Agents find valid routes you did not plan for, so give credit for the result.
- Never reading transcripts. Read some failures to confirm they are the agent's mistakes and not grader bugs.
- A suite that sits at 100 percent. It now only catches regressions, so add harder tasks.
- One person owning all the tasks. Treat evals like unit tests, with owners and contributions from domain experts.
Treat a failed eval like a failed build. A change that lowers the pass rate on tasks it should not touch needs an explanation before it ships, and the explanation is usually in one or two transcripts.
When a suite is stable, run it on every change to a prompt, tool or model. A drop in one task is a lead to follow. A drop across many tasks usually points at the runner or the environment.