An agent does not produce one answer: it takes a sequence of actions in an environment, calling tools, reading results and deciding what to do next. That makes evaluation harder in three ways. There are many valid paths to the same goal, so comparing to one reference trajectory is too strict. Runs are long and non-deterministic, so one success proves little. And the agent changes things, so you need an environment you can reset. This lesson covers outcome-based grading with end-state checks, trajectory checks for safety and efficiency, reliability metrics such as pass^k, simulated users, and how to build environments that make all of this repeatable.
- Grade agents by verifying the end state of the environment
- Add trajectory checks for forbidden actions, efficiency and policy
- Compute pass@k and pass^k and explain what each says about reliability
- Design resettable environments with fake tools and simulated users
- Measure cost, steps and latency alongside success
Grade outcomes, not paths
The most robust way to grade an agent is to check what is true at the end. Did the order get refunded in the database? Do the repository's tests pass? Does the file contain the right content? This end-state check is written as code against the environment, so it is objective and tolerant of the many different routes an agent might take. Benchmarks such as SWE-bench (do the hidden tests pass after the agent's patch?) and tau-bench (does the database match the expected state?) are built this way.
def check_refund_task(db) -> dict:
order = db.get_order("A-1042")
return {
"refunded": order["status"] == "refunded",
"correct_amount": order["refund_amount"] == 59.00,
"other_orders_untouched": db.count_changed(exclude=["A-1042"]) == 0,
}
def passed(result: dict) -> bool:
return all(result.values())Note the third check. Agents can reach the goal while causing collateral damage, so good end-state checks also verify that nothing else changed.
Trajectory checks: how it got there
Outcomes are not everything. An agent that refunds the right order but first emails the customer's details to the wrong address has failed. Record the full trajectory (every message, tool call, argument and result) and add checks on it.
- Forbidden actions: never called
delete_account; never wrote outside the workspace. - Required actions: verified identity before changing an order; asked for confirmation before an irreversible step.
- Policy compliance: did not offer a refund outside the policy window, even when the user pushed.
- Efficiency: number of steps, tool calls and tokens compared with a reasonable budget.
- Tool-call validity: share of calls with schema-valid arguments; repeated identical calls indicate loops.
def trajectory_checks(steps: list[dict]) -> dict:
calls = [s for s in steps if s["type"] == "tool_call"]
names = [c["name"] for c in calls]
verified_before_write = (
"verify_identity" in names
and names.index("verify_identity") < names.index("refund_order")
) if "refund_order" in names else True
return {
"no_forbidden": "delete_account" not in names,
"verified_first": verified_before_write,
"within_budget": len(calls) <= 12,
"no_loops": len(calls) - len({(c["name"], str(c["args"])) for c in calls}) <= 2,
}Reliability: pass@k versus pass^k
Run every task several times. pass@k asks whether at least one of k attempts succeeds; it suits settings where you can check and retry, such as generating code against tests. pass^k asks whether all k attempts succeed; it measures consistency, which is what a customer-facing agent needs. An agent that succeeds 70% of the time per attempt has a much lower chance of succeeding on every one of 8 conversations in a row.
from math import comb
def pass_at_k(n: int, c: int, k: int) -> float:
"""P(at least one of k sampled attempts succeeds)."""
if n - c < k:
return 1.0
return 1 - comb(n - c, k) / comb(n, k)
def pass_hat_k(n: int, c: int, k: int) -> float:
"""P(all k sampled attempts succeed)."""
return comb(c, k) / comb(n, k)
print(pass_at_k(10, 7, 3), pass_hat_k(10, 7, 3)) # about 0.99 and 0.29Environments and simulated users
Agent evals need an environment: the tools, the data behind them and a way to reset to a known state before each run. Use fake implementations backed by an in-memory or containerised database for business tools, a fresh container or temporary directory for coding and file tools, and recorded or stubbed responses for external APIs. Never point evals at production systems.
Conversational agents also need a counterpart. A simulated user is a model prompted with a persona and a hidden goal ("you want a refund for order A-1042, you are impatient, you only reveal the order number when asked"). It makes multi-turn evals repeatable, but it is itself a model: check samples of simulated conversations to make sure the user behaves realistically and does not leak the answer or give up too early.
Give every task an ID, a starting state, the user goal, the end-state check and the trajectory checks. With those five things you can rerun any task at any time and compare agents fairly.
What to report
Report task success with confidence intervals, pass^k for reliability, and per-slice results (task type, difficulty). Next to them, report the costs of success: median and p90 steps, tokens and wall-clock time per task, and the rate of forbidden or unsafe actions, which should be zero. Finally, read failed trajectories and label the cause (wrong tool, bad arguments, misread result, gave up, looped, policy violation), because those labels tell you whether to change tools, prompts, context or the model.