# Agent Evaluation: You Are Grading the System, Not the Model

> Agent evaluation grades the whole system — model, prompts, tools, loop, environment. An episode is tasks, trials, trajectories, and outcomes; pass^k measures reliability, stateful graders check final states, and cost is accounted per successful task.

- URL: https://dmxsf.com/en/wiki/applications/agent-evaluation/
- [DMXSF](https://dmxsf.com/en/about/)
- Intermediate
- Updated: 2026-11-21
- Tags: Agents, Evaluation, Tool use

## After this page you will be able to

- Explain how agent evaluation differs from model evaluation: it grades system plus protocol, not parameters.
- Describe one evaluation episode with tasks, trials, trajectories, and outcomes, and separate the agent harness from the evaluation harness.
- Compute pass^k, explain how it differs from pass@k, and why agent evaluation cares about the former.
- Explain why stateful grading (checking the environment's final state) is more reliable than judging how an answer reads.
- Compare two agent designs by cost per successful task, and name the blind spots of that metric.

Model evaluation asks what a model can do; [agent evaluation](https://dmxsf.com/en/wiki/applications/agents-and-tool-calling/) asks whether a system can get real tasks done, reliably, with tools and state. If you have read [LLM evaluation methodology](https://dmxsf.com/en/wiki/evaluation/llm-evaluation/), this page brings the same discipline to multi-step, tool-using, stateful systems.

## What is graded: the system plus its protocol

A benchmark score measures a specific system on a specific task distribution under a specific protocol. The system includes the model, prompts, memory, tools, control loop, and execution environment; changing any of them can change the score. So:

- **Hard questions alone do not make an evaluation agentic.** Making the problem harder while the system still just emits one answer is only a harder model evaluation. The key change is that the system can act, observe consequences, and adapt.
- **Read every score with its protocol.** Ask first: benchmark version and split, system configuration, permitted tools, budget (steps, tokens, time), and the grader.
- **The harness is part of the system and part of the evaluation.** The agent harness decides what context the model sees, how tool calls execute, and when to stop; the evaluation harness initializes tasks, imposes limits, preserves evidence, invokes graders, and aggregates results. Keep the two separate: **the system under test must never touch its own grading rules**.

The conceptual model of one evaluation episode (adapted from Anthropic's evaluation guidance and Harvard CS2680's course notes):

```text
for task in frozen_task_set:                 # task set frozen, no edits mid-eval
    for trial in trials_for(task):           # repeated trials measure variability
        env = reset_to(task.initial_state)   # environment is resettable
        while not done(agent) and within(budget):
            obs = env.observe()              # model sees instruction, obs, tools only
            action = agent.next_action(obs)  # reference answers hidden from the model
            env.execute(action)
        scores = protected_graders(env, trajectory)  # graders are protected
```

Four words worth remembering: task, trial, trajectory, outcome. Repeated trials measure **variability**, not new tasks; the trajectory is the evidence for appeals and diagnosis, and must preserve failures, timeouts, and tool errors.

## Metrics: reliability first, cost accounted together

[Read the task-level reliability calculation](https://github.com/dmxsf/dmxsf/blob/main/src/dmxsf/applications/agent_metrics.py)

### pass^k: the deployer's metric

pass@k asks "sample k times, does the best succeed" — a capability ceiling. **pass^k** asks "run the same task k independent times, does every run succeed" — reliability. Real users run an agent over and over, and any single failure is a real loss, so agent settings care about pass^k. Under an independence assumption, the orders of magnitude (arithmetic from this page, recomputable directly):

```python
# pass^k (all must succeed) = p**k; "at least one success" = 1-(1-p)**k
# comparing the two shows what "retrying for reliability" really costs
for p in (0.4, 0.6, 0.8):
    print(f"p={p:.1f}: p^4={p**4:.3f}  1-(1-p)^4={1-(1-p)**4:.3f}")
```

Output:

```text
p=0.4: p^4=0.026  1-(1-p)^4=0.870
p=0.6: p^4=0.130  1-(1-p)^4=0.974
p=0.8: p^4=0.410  1-(1-p)^4=0.998
```

The widget below draws pass^k and pass@k as curves, and shows how “concentrated” and “spread” task distributions with the same average produce opposite pass^2.

For a task with a one-run success probability of 0.8, four independent attempts all succeed with probability about 0.41. Difficulty also differs across tasks, so estimate repeatability for each task.

### Estimate within each task before averaging

[τ-bench](https://arxiv.org/abs/2406.12045) defines pass^k as the probability that all $k$ attempts of one task succeed, averaged across tasks. For $T$ tasks, if task $i$ has $c_i$ successes in $n_i$ trials, the share of subsets of size $k$ containing only successes gives:

$$
\widehat{\mathrm{pass}}^{\,k} =
\frac{1}{T}\sum_{i=1}^{T}
\frac{\binom{c_i}{k}}{\binom{n_i}{k}}
$$

Each task needs at least $k$ trials. Collect missing trials or report the actual coverage for that $k$. Pooling successes across tasks and raising the overall one-run score to a power loses the grouping. Both synthetic examples below score 50% on a single attempt. The successes are distributed differently. The example ran on an Apple M2 Max with Python 3.12.14.

```python
from collections.abc import Sequence
from math import comb

def pass_all(tasks: Sequence[Sequence[bool]], k: int) -> float:
    """Estimate task-average all-success probability."""
    if k < 1 or not tasks or any(len(trials) < k for trials in tasks):
        raise ValueError("need k >= 1 and at least k trials per task")
    ratios = [comb(sum(row), k) / comb(len(row), k) for row in tasks]
    return sum(ratios) / len(ratios)

concentrated = [(True, True), (False, False)]
spread = [(True, False), (False, True)]
assert pass_all(concentrated, 1) == pass_all(spread, 1) == 0.5
assert pass_all(concentrated, 2) == 0.5 and pass_all(spread, 2) == 0
for name, tasks in zip(('concentrated', 'spread'), (concentrated, spread)):
    first, second = pass_all(tasks, 1), pass_all(tasks, 2)
    print(f"{name}: k=1 {first:.0%}, k=2 {second:.0%}")
```

```text
concentrated: k=1 50%, k=2 50%
spread: k=1 50%, k=2 0%
```

In the concentrated case, one task succeeds repeatedly. In the spread case, every task fails at least once. A high repeatability score can still come from easy tasks, so report it by task family and difficulty and resample whole tasks to estimate uncertainty. Reset shared mutable state before interpreting trials as independent.

### Stateful grading: check the environment's final state

Take a τ-bench-style support task: the user wants to return an eligible item, and policy requires **confirmation before the refund**. The grader checks: a correctly recorded refund, untouched unrelated orders, required content in the reply, and confirmation preceding the write. Stateful grading like this is far more robust than "does the reply read like the reference answer" — an agent acts on the environment, not on text.

### Cost: account per successful task

[AI Agents That Matter](https://arxiv.org/abs/2407.01502) argues for comparing accuracy and cost together. In an application, track planning, tool calls, retries, verification, and cleanup for the whole task. The following 100-task example uses synthetic figures.

```text
baseline:  $1.50 per success (80/100)
candidate: $1.20 per success (75/100)
difference: 5 fewer successes, $0.30 lower unit cost
```

The candidate is cheaper per success but loses five completions; with an 80% success floor, it is ineligible. **Compare agent designs on the whole quality–cost frontier, and on which tasks were gained or lost**; "cost per successful task" is undefined at zero success and cannot tell you which task family regressed.

*Figure: The evaluation harness freezes tasks, resets the environment and keeps the grader; the agent harness is the system under test itself. The dashed grader sits outside what the agent can read: the score comes from the environment's final state, not from the reply.*
## A map of benchmarks: classify by what they grade

Harvard CS2680 maintains a 48-entry benchmark directory; its core idea is worth borrowing — classify by what is graded, not by fame:

| Category | Representative benchmarks | What is graded and how |
| --- | --- | --- |
| Interactive task completion | WebArena (2307.13854), OSWorld (2404.07972), GAIA (2311.12983), SWE-bench (2310.06770), Terminal-Bench, BrowseComp | Real web/desktop/repo environments; final state or artifacts are checked |
| Isolated capabilities | BFCL (tool choice), ToolSandbox (state-dependent tool use), LongMemEval (long-term memory), τ-bench / τ²-bench (2406.12045 / 2506.07982), AgentDojo (2406.13352), MultiAgentBench | Tool choice, memory, instruction following graded separately, with precise rules |
| Workflow artifacts | MLE-bench, KernelBench, GDPval | End-to-end artifacts (working models, kernels, documents) graded by experts or programs |
| Harder, fresher tasks | GPQA, FrontierMath, HLE, LiveBench, ARC-AGI-3 | Contamination-resistant, but still an extension of model evaluation, not agent evaluation |

To choose a benchmark for your agent, first diagnose your product's failure mode, then pick benchmarks that cover it — and **read the grading protocol**: different versions under the same name can grade very differently.

## Use traces to locate failures

[Berkeley Advanced LLM Agents](https://agenticai-learning.org/sp25) covers memory, planning, and multimodal interaction in separate lectures. The [spring Scalable AI application assignment](https://scalable-ai.eecs.berkeley.edu/S2026/assets/assignment_4.zip) asks students to measure application quality and systems performance together. Isolate these factors with a sandbox task such as moving a meeting on a mock calendar using stored user preferences.

- **Observation and memory.** Give each run the same calendar snapshot and conversation history. Log the retrieved preferences and their version. Toggle only memory and report results separately for tasks that require cross-session preferences.
- **Planning and execution.** Inspect the event selected and the time submitted to the tool. Replay the same scripted responses for tool timeouts, then check the final state and look for duplicate events.
- **Outcome.** Check the event ID, time, attendees, and unrelated events that should remain intact. Record call count, total elapsed time, and cost per success. Save failure traces for regression tests using the same starting state.

Measure the original system first. Change one of the model, memory, planner, or tool at a time so the comparison can identify the effect of that change.

### Check the grader with a mock calendar

Four hand-built traces cover a correct update, a missing update, a duplicate, and an unrelated change. The two graders ran on an Apple M2 Max with Python 3.14.3 and have no third-party dependencies.

```python
before = [("check-in", "09:00"), ("interview", "14:00")]
expected = [("check-in", "10:00"), ("interview", "14:00")]
traces = [
    (True, expected),
    (True, before),
    (True, expected + [("check-in", "10:00")]),
    (True, [("check-in", "10:00"), ("interview", "15:00")]),
]

reported = sum(claim for claim, _ in traces)
verified = sum(sorted(events) == sorted(expected) for _, events in traces)
assert verified == 1 and reported == len(traces)
print(f"reported success: {reported}/{len(traces)}")
print(f"correct final state: {verified}/{len(traces)}")
```

```text
reported success: 4/4
correct final state: 1/4
```

The gap reflects how these traces were constructed. Sorting accepts a different event order while preserving duplicates. Use stable event IDs in a real calendar and include fields that matter to task success, such as attendees and time zones.

## Common pitfalls

- **Harness drift**: the scaffold (prompt templates, retry policy, tool descriptions) changed, the score moved, and you blamed the model. Mitigation: version the harness configuration and freeze it when swapping models.
- **Reporting a single run**: agent variability is far larger than single-turn Q&A; a single-run score carries little information. Report mean and spread over repeated trials, and pass^k where possible.
- **Non-resettable environments**: state leaks between tasks and "remembering last time's answer" masquerades as capability. The evaluation harness must reset the environment before every trial.
- **Exposed graders**: reference answers or grading logic leak into the model's context and scores inflate instantly. Grading state must stay with the evaluation harness.
- **Task-set leakage into training**: agent trajectory data is hot; once benchmark tasks enter training sets, scores inflate (the same logic as [benchmark contamination](https://dmxsf.com/en/wiki/evaluation/benchmark-contamination/)).

## Summary and exercises

- Agent evaluation = system × task distribution × protocol; the harness is part of the system, the two harnesses stay separate, and the system under test never touches the grader.
- On metrics, reliability (pass^k) comes before capability ceiling (pass@k); cost is accounted per successful task but must be read with success rate and latency.
- Choose benchmarks by what they grade; read the protocol before the score.

### Quick quiz

**1. You keep the model but change the prompt template and retry policy. What happens to the agent benchmark score?**

- [x] It can change noticeably, because the score measures the whole system of model + scaffold + protocol
- [ ] It stays fixed, since the score depends only on model parameters
- [ ] It can only improve

> The harness is part of the system. Fix the protocol and document the configuration when comparing systems.

**2. A task has a single-trial success rate of 0.8. Roughly what is the probability that four consecutive trials all succeed?**

- [ ] 0.8
- [ ] 0.998
- [x] 0.41

> pass^k (all must succeed) = 0.8^4 = 0.410; 0.998 is the pass@k-style "at least one success". Deployment cares about the former.

**3. What does τ-bench-style stateful grading mainly check?**

- [x] The environment's final state (refund record, untouched orders) and the ordering of operations (confirmation before the write)
- [ ] Semantic similarity between the reply and a reference answer
- [ ] The length of the thinking steps in the trajectory

> An agent acts on the environment. Checking final state and constraint ordering closes the hole where a reply reads fine while nothing was actually done right.

**4. A candidate agent design costs less per successful task. Is it automatically better?**

- [ ] Yes, cost is the only decision metric
- [x] Not necessarily: it may succeed less often and lose critical tasks; cost must be read with success rate and latency
- [ ] Lower cost per success always means a higher success rate

> This page's example: $1.20 vs $1.50 per success, but the candidate loses five completions and can fall below the business floor.

**5. Why must the environment be reset before every trial?**

- [x] To prevent state leaking between tasks, where "remembering the last answer" is mistaken for capability
- [ ] To make trajectories longer
- [ ] To save compute

> Environment resets keep every trial on the same task; leaked state makes results uninterpretable.

### Exercises

1. Pick an agent-style application you use (support, coding assistant), and write its cost-ledger template: which fields are recorded per episode (model calls, cache hits, tool fees, human cleanup, ...)?
2. Pick two agent benchmarks you care about; for each, write three sentences on "what the system receives, what it does, and what the grader checks", then judge which failure modes each covers and which it misses.

Suggested answer for exercise 1 (key fields):

<details>
<summary>Click to expand</summary>

Per model call: model name, role (main loop / planning / compression / verification), input and output token counts, cache hit or not; tool calls: name, count, fees; per episode: total latency (p50/p95), retries, outcome (success / failure / timeout), human-intervention time. Aggregate: verified success rate, total spend ÷ successful tasks, cost per attempted trial, cost distribution across tasks. Keep offline costs (teacher trajectories, fine-tuning, the evaluation itself) in a separate ledger instead of amortizing them into single calls.
</details>

## Further reading

- Anthropic, [Demystifying evals for AI agents](https://www.anthropic.com/engineering/demystifying-evals-for-ai-agents) and [Building effective agents](https://www.anthropic.com/engineering/building-effective-agents): sources of this page's episode model.
- Yao et al., [τ-bench](https://arxiv.org/abs/2406.12045) (2024); Si et al., [τ²-bench](https://arxiv.org/abs/2506.07982) (2025): stateful grading and pass^k.
- Kapoor et al., [AI Agents That Matter](https://arxiv.org/abs/2407.01502) (2024): the cost-accounting and quality–cost-frontier argument.
- Liu et al., [AgentBench](https://arxiv.org/abs/2308.03688) (2023); Zhou et al., [WebArena](https://arxiv.org/abs/2307.13854) (2023); Jimenez et al., [SWE-bench](https://arxiv.org/abs/2310.06770) (2023); Mialon et al., [GAIA](https://arxiv.org/abs/2311.12983) (2023); Xie et al., [OSWorld](https://arxiv.org/abs/2404.07972) (2024): four task formats of interactive-environment benchmarks.
- Debenedetti et al., [AgentDojo](https://arxiv.org/abs/2406.13352) (2024): joint evaluation of agent utility and security; see also [prompt injection and jailbreaks](https://dmxsf.com/en/wiki/safety/prompt-injection-and-jailbreaks/).
- Course notes: Harvard CS2680, *Agent Evaluation and Benchmarks* and *Cost-effective Agents* (2026), whose benchmark taxonomy and cost framework this page adapts.

## Companion code

[Agent evaluation: repeatability and terminal state](https://github.com/dmxsf/dmxsf/tree/main/labs/applications/agent-evaluation): Compare equal one-run scores and validate four calendar traces.

- Run it in the companion repository (add --quick for a fast pass): `uv run dmxsf run applications/agent-evaluation`
- [View the lab script](https://github.com/dmxsf/dmxsf/blob/main/labs/applications/agent-evaluation/run.py)
- [Lab write-up](https://github.com/dmxsf/dmxsf/blob/main/labs/applications/agent-evaluation/README.en.md)
- [`agent_metrics.py`](https://github.com/dmxsf/dmxsf/blob/main/src/dmxsf/applications/agent_metrics.py)
- [Find this lab in the catalog](https://dmxsf.com/en/code/#agent-evaluation)

## FAQ

### If I keep the model but change the agent scaffold (harness), does the benchmark score change?

Yes — often more than swapping the model would. The score measures the whole system (model + prompts + memory + tool interface + control loop + environment) under a fixed protocol; changing tool descriptions, retry budgets, or stopping conditions all move the score. Fix the protocol when comparing systems, and report the harness configuration.

### What is the difference between pass^k and pass@k?

pass@k asks "sample k times, does the best trial succeed" — a capability ceiling. pass^k asks "run the same task k independent times, does every trial succeed" — reliability. That is what a deployed agent needs: users run it repeatedly, and any single failure is a real failure.

### Why does τ-bench check the database state instead of the reply?

Because an agent acts on an environment. "The refund succeeded" can be words in a reply, or it can be a correctly recorded refund in the database, with unrelated orders untouched and confirmation preceding the write. Stateful grading checks the environment's final state and the ordering of constraints, closing the hole where a reply reads correctly while nothing was actually done right.

### If a candidate agent design costs less per successful task, is it automatically better?

No. In a synthetic example: on 100 tasks, a baseline costs $120 and succeeds 80 times ($1.50 per success), while a candidate costs $90 and succeeds 75 times ($1.20 per success). The candidate is cheaper per success but loses five completions; if the business requires at least 80% success, the candidate is ineligible. Cost must be read together with success rate.

### With so many agent benchmarks, how do I choose?

Classify by what they grade: interactive task completion in real environments (WebArena, OSWorld, SWE-bench), isolated capabilities (tool choice, memory, instruction following), and workflow artifacts (MLE-bench). Diagnose your product's failure mode, pick benchmarks that cover it, and read the grading protocol — same name, different versions and rules.
