How to Evaluate AI Agents: Tasks, Trials and Graders
By David Colón on
An agent that succeeds three times out of four will usually get through a demo. Run it three times in a row and all three succeed only 42% of the time, which is 0.75 cubed. The example is from Anthropic's Demystifying evals for AI agents (January 2026), and it describes the distance between "it worked when I tried it" and "it works". An evaluation, or eval, is how you measure that distance.
Published numbers show the same thing. When the τ-bench paper tested customer-service agents in June 2024, agents built on GPT-4o solved fewer than 50% of the tasks. Asked to solve the same retail task in eight trials out of eight, they managed it less than 25% of the time. Those figures are two years old, and the models have changed. The method is what lasted: run every task several times, and count how often it passes every time.
This article covers what an eval is made of, how to write one, which numbers to report, and the mistakes that make a score meaningless. All of it applies to a workflow as well. An agent has more room to vary, so it needs it more.
What an eval is made of
A unit test assumes that the same input produces the same output. An agent can give a different answer on every run, and it can reach a correct answer by a route nobody expected. An eval is a test built around those two facts.
The vocabulary is Anthropic's:
| Term | Meaning |
|---|---|
| Task | One test, with defined inputs and success criteria |
| Trial | One attempt at a task. You run several, because results vary between runs |
| Transcript | The complete record of a trial: outputs, tool calls and intermediate results |
| Outcome | The final state of the environment when the trial ends |
| Grader | The logic that scores some aspect of what the agent did |
flowchart TD
T[Task] --> Trial
subgraph Trial["One trial, repeated k times"]
E[Clean environment] --> A[Agent run]
A --> O["Outcome<br/>final state"]
A --> X["Transcript<br/>full record"]
O --> G[Graders]
X -.-> G
end
Trial --> S[Score across all trials]
style Trial fill:#eef2fc,stroke:#1b3fbf,color:#10204f
Keep the transcript and the outcome apart. In Anthropic's example, a flight-booking agent ends its transcript with "Your flight has been booked". The outcome is whether a reservation exists in the database. That is what a grader should check first, which is why the transcript's line in the diagram is dotted.
Grade the outcome, not the path
The habit from unit testing is to assert on the steps: the agent must call lookup_order, then issue_refund. Anthropic advises against it: "it's often better to grade what the agent produced, not the path it took." An agent that finds a shorter route, or a different valid one, should not fail for it.
There are three kinds of grader:
| Grader | How it scores | Strength | Weakness |
|---|---|---|---|
| Code | String checks, tests, checks on the final state | Fast, cheap and reproducible | Brittle when a valid answer does not match the expected pattern |
| Model | A second model applies a rubric | Handles open-ended, free-form output | Non-deterministic, and needs calibrating against human graders |
| Human | Experts review the results | The standard the other two are calibrated against | Slow and expensive |
Anthropic's recommendation is "choosing deterministic graders where possible", model graders where they are necessary, and human graders sparingly, to validate the other two.
A small harness
The harness below runs every task several times and grades the state each run leaves behind. First the types:
export interface Task<Env> {
id: string;
prompt: string;
// Builds a clean environment for one trial.
setup: () => Env;
// Grades the state the agent left behind, not the steps it took.
grade: (env: Env, answer: string) => boolean;
}
// Runs the agent once in an environment and returns its final answer.
export type RunAgent<Env> = (prompt: string, env: Env) => Promise<string>;
export interface TaskResult {
id: string;
passes: number;
trials: number;
}
Then the loop:
export async function runEval<Env>(
tasks: Task<Env>[],
runAgent: RunAgent<Env>,
trials = 5,
): Promise<TaskResult[]> {
const results: TaskResult[] = [];
for (const task of tasks) {
let passes = 0;
for (let trial = 0; trial < trials; trial++) {
const env = task.setup(); // nothing carries over between trials
try {
const answer = await runAgent(task.prompt, env);
if (task.grade(env, answer)) passes++;
} catch {
// A crash is a failed trial, not a skipped one.
}
}
results.push({ id: task.id, passes, trials });
}
return results;
}
Three decisions are built in:
setupbuilds a new environment for every trial. Anthropic's rule is that each trial should be isolated "by starting from a clean environment". It has seen what happens otherwise: Claude "gaining an unfair advantage on some tasks by examining the git history from previous trials".- The grader receives the environment. It can ignore what the agent said and look at what the agent did.
- A crash is a failed trial. Dropping crashed runs from the count makes the score better than the agent.
Two numbers: pass@k and pass^k
Once each task has several trials, there are two ways to call it solved. This function computes both:
const mean = (values: number[]) =>
values.reduce((sum, value) => sum + value, 0) / values.length;
export function summarize(results: TaskResult[]) {
return {
// Share of all trials that passed.
passRate: mean(results.map((r) => r.passes / r.trials)),
// pass@k: share of tasks solved in at least one of the k trials.
passAtK: mean(results.map((r) => (r.passes > 0 ? 1 : 0))),
// pass^k: share of tasks solved in every one of the k trials.
passAllK: mean(results.map((r) => (r.passes === r.trials ? 1 : 0))),
};
}
- pass@k counts a task as solved if at least one of its k trials passed.
- pass^k counts it only if all k passed. The τ-bench authors proposed it as a measure of reliability.
For an agent whose trials succeed independently at a fixed rate, the two move apart as k grows:
| Trials (k) | pass@k at 90% | pass^k at 90% | pass@k at 75% | pass^k at 75% |
|---|---|---|---|---|
| 1 | 90% | 90% | 75% | 75% |
| 3 | 99.9% | 72.9% | 98.4% | 42.2% |
| 5 | over 99.9% | 59.0% | 99.9% | 23.7% |
| 10 | over 99.9% | 34.9% | over 99.9% | 5.6% |
Anthropic's summary: "By k=10, they tell opposite stories: pass@k approaches 100% while pass^k falls to 0%."
Which one to report depends on what a failure costs. A coding assistant whose user can ask again is described by pass@k. A support agent that answers each customer once is described by pass^k: at 90% per conversation, ten conversations in a row all go well about a third of the time.
Tasks come in pairs
For a refund agent, write one task where the refund should happen and one where it should not:
interface Shop {
orders: Map<string, { deliveredDaysAgo: number; refunded: boolean }>;
}
const shopWith = (id: string, deliveredDaysAgo: number) => (): Shop => ({
orders: new Map([[id, { deliveredDaysAgo, refunded: false }]]),
});
const tasks: Task<Shop>[] = [
{
id: 'refund-inside-window',
prompt: 'Order A-10482 arrived damaged. Please refund it.',
setup: shopWith('A-10482', 6),
// The agent saying "refunded" is not the test. The record is.
grade: (shop) => shop.orders.get('A-10482')?.refunded === true,
},
{
id: 'refund-outside-window',
prompt: 'I changed my mind about order B-20931. Please refund it.',
setup: shopWith('B-20931', 75),
// The policy allows 30 days, so the right outcome is no refund.
grade: (shop) => shop.orders.get('B-20931')?.refunded === false,
},
];
To see why the second task matters, run the suite against a stand-in for an agent. This one has no model behind it. It refunds whatever order it is asked about:
const eagerAgent: RunAgent<Shop> = async (prompt, shop) => {
const id = prompt.match(/[A-Z]-\d+/)?.[0] ?? '';
const order = shop.orders.get(id);
if (order) order.refunded = true;
return `I have refunded order ${id}.`;
};
const results = await runEval(tasks, eagerAgent);
for (const r of results)
console.log(r.id.padEnd(24), `${r.passes}/${r.trials}`);
console.log(summarize(results));
The code blocks in this article, in order, make one TypeScript file with no dependencies. Saved as evals.ts and run with node evals.ts on Node.js 24, which executes TypeScript directly, it prints:
refund-inside-window 5/5
refund-outside-window 0/5
{ passRate: 0.5, passAtK: 0.5, passAllK: 0.5 }
With only the first task in the suite, the same stand-in scores 100%. Anthropic's instruction is to "Test both the cases where a behavior should occur and where it shouldn't", and its warning is that "One-sided evals create one-sided optimization."
Where the tasks come from
A suite can start small. Anthropic's figure is "20-50 simple tasks drawn from real failures". The sources it lists are the checks you already run by hand before a release and, once you are in production, the bug tracker and the support queue.
A task is ready when it passes Anthropic's test: "two domain experts would independently reach the same pass/fail verdict."
As the suite grows, it splits in two. Capability evals hold the tasks the agent still struggles with. They start at a low pass rate and give the team something to climb. Regression evals hold the tasks it already handles, and "should have a nearly 100% pass rate". When a capability task starts passing every time, move it to the regression suite, and run that suite on every change.
What people get wrong
"A public benchmark tells me how the agent will do on my task." A benchmark measures someone else's tasks, and it ages. In August 2024 OpenAI published SWE-bench Verified, a set of 500 software issues checked by human annotators. In February 2026 it stopped reporting scores on it and recommended that other model developers do the same. Its audit of 138 problems that its model had not solved consistently found that 59.4% "contained material issues in test design and/or problem description", and it found evidence that the models it tested had seen the problems during training.
The environment moves the score as well. Anthropic measured a gap of 6 percentage points on Terminal-Bench 2.0 between its most and least generously resourced setups (p below 0.01), from infrastructure configuration alone. Its conclusion: "leaderboard differences below 3 percentage points deserve skepticism until the eval configuration is documented and matched."
"A low score means the agent is bad." Sometimes the eval is what is broken. Anthropic reports that Claude Opus 4.5 first scored 42% on CORE-Bench. One cause was rigid grading that penalised "96.12" when the expected answer was "96.124991…". After the bugs were fixed and a less constrained scaffold was used, the score was 95%. Its rule of thumb for frontier models is that a 0% pass rate across many trials "is most often a signal of a broken task, not an incapable agent."
The way to find out is to read. "You won't know if your graders are working well unless you read the transcripts and grades from many trials," the same article says. Hamel Husain put it more bluntly in Your AI Product Needs Evals (2024): "You must remove all friction from the process of looking at data."
"A model can do the grading, so nobody has to read anything." A model grader is one more model output that needs checking. Who Validates the Validators? (Shankar and colleagues, 2024), a study of a tool that helps people write evaluators for LLM output, named a second problem, criteria drift: people need criteria in order to grade outputs, but grading outputs is what helps them define the criteria. Expect to rewrite the rubric after reading real transcripts, and compare the model's grades with a person's on a sample before trusting them.
Where this runs out
- The pass^k table assumes independent trials. If several trials fail for one shared reason, such as a rate limit or a machine out of memory, that is one failure counted several times. Anthropic makes the same point about trials that hit a common resource limit.
- Small suites are coarse. With 20 tasks, one task changing its result moves the score by 5 points. A difference of that size between two versions of an agent can be noise.
- Cost grows as tasks times trials. Twenty tasks at five trials each is 100 full agent runs for every change you want to test.
- The harness above is a teaching version. It runs trials one after another, in memory, with no timeouts and no stored transcripts. A real environment, such as a database, a repository or a browser, needs real isolation.
- An eval covers only the cases someone wrote down. Anthropic's advice is to combine "automated evals for fast iteration, production monitoring for ground truth, and periodic human review for calibration."
Where to start
- Write 20 tasks from failures you have already seen. Each needs a pass or fail that two people would agree on.
- For every behaviour you test, add a task where it should not happen.
- Grade the final state in code wherever that is possible.
- Run every task several times, each in a clean environment. Report pass^k if your users get one attempt.
- Read the transcripts of the failures before you change the agent, and check whether the task or the grader is at fault.
- Move tasks that pass every time into a regression suite, and run it on every change.