Evaluating agents: trajectories, pass^k and cost

Outcome and process metrics, repeated trials, environment-based graders and the benchmarks worth knowing.

Expert about 5 h

The picture

  1. 01

    Task + environment

    reset each run

  2. 02

    Run k times

    stochastic

  3. 03

    Grade outcome

    state check

  4. 04

    Grade trajectory

    tools, steps

  5. 05

    Report

    pass^k, cost

Agents are harder to evaluate

An agent's answer depends on a sequence of decisions, tools return changing data, and runs vary. A single pass/fail on one run says little. You need repeated trials, graders that look at outcomes, and metrics for the process.

Grade the outcome, not the story

An agent can claim "I booked the flight" without doing it. Grade by inspecting the final state of the environment: the database row exists, the file contains the expected content, the test suite passes.

def grade_booking_task(env, task):
    booking = env.db.find_booking(task["customer"])
    return {
        "success": bool(booking) and booking["flight"] == task["expected_flight"] and booking["price"] <= task["budget"],
        "side_effects_ok": env.db.count_unexpected_changes() == 0,       # did it break anything else?
    }

Include checks for unintended side effects: an agent that "succeeds" by deleting a constraint has not succeeded.

Repeated trials: pass@k versus pass^k

Run each task nn times. With cc successes:

  • pass@k: probability that at least one of kk attempts succeeds. Good for "can it ever solve this" (and for best-of-n setups with a verifier).
  • pass^k: probability that all kk attempts succeed, approximately (c/n)k(c/n)^k. This measures reliability, which is what a customer-facing agent needs.
from math import comb

def pass_at_k(n, c, k):
    if n - c < k:
        return 1.0
    return 1.0 - comb(n - c, k) / comb(n, k)

def pass_pow_k(n, c, k):
    return comb(c, k) / comb(n, k) if n >= k else float("nan")

for c in (5, 8, 10):
    print(c, "/10", "pass@3", round(pass_at_k(10, c, 3), 3), "pass^3", round(pass_pow_k(10, c, 3), 3))

A task solved 8 times in 10 has a high pass@3 and a much lower pass^3. If you promise users consistency, report pass^k.

Process metrics

  • Steps and tool calls to success; sudden growth signals a regression.
  • Tool error rate and invalid-argument rate, which point at bad tool descriptions.
  • Wasted calls: repeated identical calls, loops.
  • Cost and latency per task, at p50 and p95.
  • Recovery: after an injected tool failure, does it recover or give up?
def summarise(runs):
    ok = [r for r in runs if r["success"]]
    return {
        "success": len(ok) / len(runs),
        "median_steps": statistics.median(r["steps"] for r in ok) if ok else None,
        "tool_error_rate": sum(r["tool_errors"] for r in runs) / max(sum(r["tool_calls"] for r in runs), 1),
        "p95_cost_usd": sorted(r["cost"] for r in runs)[int(0.95 * len(runs)) - 1],
    }

Simulated users and failure injection

For conversational agents, simulate the user with another model following a script, and inject failures (a timeout, an empty result, a contradictory record) to see whether the agent degrades gracefully. Keep the simulation seeded where possible.

Benchmarks: useful, with caveats

SWE-bench, GAIA, AgentBench and τ-bench test general competence. Read how each was graded, the scaffold used, the number of attempts, and whether the data may have leaked into training. For your system, a small benchmark built from your own tasks and tools is worth more than any leaderboard.

Common mistakes

  • Grading by reading the transcript instead of checking state.
  • One run per task.
  • Reporting success without cost, so a 2-point gain at 5× the spend looks like progress.

Exercises

  1. Run your agent 10 times on 10 tasks and report pass@1, pass@3 and pass^3.
  2. Add one injected tool failure per task and measure recovery rate.

You are done when you can…

  • Compute pass@k and pass^k from repeated trials and explain which one matters for reliability
  • Write an outcome grader that inspects the final state of the environment, not the transcript
  • Track steps, tool errors and cost per task alongside success