It is already the latest posts!
It is already the oldest posts!

Agent Evaluation Engineering: From First Principles to Systems

Part 1

〇一What Are We Evaluating in an Agent: Distributions, Reliability, and the Pareto Frontier

The same 70.0% single-run pass rate can hide two systems with opposite operational behaviour

欤冰 10 min read 中文

Two agents run on the same 100-task benchmark (a fixed suite of tasks used to compare systems under identical conditions). Both score 70.0% on a single run. Looking at that number alone, they are tied.

Run every task 5 times in a row, and the tie breaks in opposite directions:

  • In an interactive coding assistant where a user can click retry and 1 success out of 5 attempts is enough: Agent B reaches 99.8%, while Agent A stops at 79.1%.
  • In an unattended background workflow where all 5 consecutive runs must succeed to be considered reliable: Agent A holds at 60.1%, while Agent B collapses to 16.8%.

The same 70.0% flips winner and loser depending on what question you ask. Nothing changed in the model or the code; the single-run pass rate simply threw away the shape of the underlying distribution. Before writing any evaluation harness, the first problem is deciding what an agent evaluation actually needs to measure.

Why unit tests and static LLM benchmarks both break on agents

Engineers approaching agent evaluation usually reach for one of two familiar tools: software unit tests or static language-model benchmarks such as MMLU and GSM8K. Both break down on agents for four structural reasons.

First, an agent's output is a probability distribution, not a deterministic value. A pure function given the same input returns the same output ten thousand times. An agent samples from a language model (governed by sampling temperature, where higher temperature increases randomness) while interacting with external tools whose responses and latencies vary. Passing a task once only shows that one sample landed in the success region; it does not establish the system's steady-state reliability.

Second, errors compound exponentially across multi-step trajectories. Static question answering is a single-turn mapping. An agent often makes $L$ sequential decisions: searching, assembling arguments, calling an API, reading the output, and choosing the next action. If each step were independent with accuracy $s$, the probability of completing all $L$ steps without error is $s^L$:

Steps $L$99% / step95% / step90% / step85% / step
1 step99.0%95.0%90.0%85.0%
3 steps97.0%85.7%72.9%61.4%
5 steps95.1%77.4%59.0%44.4%
8 steps92.3%66.3%43.0%27.2%
12 steps88.6%54.0%28.2%14.2%
20 steps81.8%35.8%12.2%3.9%

90% per step sounds respectable until a 12-step task shrinks end-to-end completion to 28.2%. In practice steps are not independent: the harness (the code wrapped around the model that handles tool routing, context assembly, argument validation, and retries) can either recover from an earlier mistake through retries or poison every subsequent step by dumping an unparsed error trace into the context.

Third, a correct final answer does not imply a valid process. Static benchmarks check only the final string. In agent tasks, outcome-only grading misses two opposite failure modes:

  • False pass: the model skips the lookup tool and guesses a number from training memory that happens to match, or retrieves an unauthorized internal document to assemble the answer. Outcome grading marks it passed even though the system is broken.
  • Near miss: the first eight steps of retrieval, reasoning, and tool calls are completely sound, and only the final JSON formatting drops one field. Outcome grading scores it zero, lumping it together with a system that derailed on step one.

Fourth, latency, step count, and token cost are first-class quality dimensions, not footnotes. Completing a task in 3 steps, 2 seconds, and USD 0.01 is not operationally equivalent to completing it in 18 steps, 45 seconds, and USD 0.50. Agent evaluation has to place outcome quality and resource expenditure in the same coordinate system.

From single-run accuracy to pass@k and pass^k

Return to the 70.0% puzzle. Suppose a benchmark has 100 tasks, and each task $i$ has a true single-trial success probability $p_i$.

  • Agent A (sharp capability boundary): 70 tasks are mastered reliably at $p_i = 0.97$; the remaining 30 tasks are barely solvable at $p_i = 0.07$. Mean single-run accuracy is $0.70 \times 0.97 + 0.30 \times 0.07 = 70.0%$.
  • Agent B (uniform variance): every one of the 100 tasks sits at $p_i = 0.70$. Mean single-run accuracy is also $70.0%$.

On a single trial, both systems have the exact same expected score. Now run each task independently $k$ times and ask two different questions:

  1. pass@k (capability ceiling): the probability of at least 1 success in $k$ trials. For a single task this is $1 - (1 - p_i)^k$. It measures how many tasks the system can cover when retries or human selection among candidates are allowed.
  2. pass^k (production reliability): introduced in the τ-bench paper (Yao et al., 2024), the probability that all $k$ consecutive trials succeed. For a single task this is $p_i^k$. It measures how likely an unattended workflow is to run $k$ times without a single failure.

Sweeping $k$ from 1 to 8, both curves start at the same 70.0% point and immediately diverge in opposite directions:

Identical pass@1 (70.0%), opposite rankings on pass@k and pass^k

The mechanics in Fig 1-1 are straightforward. For Agent B, every task has a 70% chance of succeeding, so failing all 5 attempts happens with probability $0.3^5 = 0.24%$, pushing pass@5 to 99.8%; yet succeeding 5 times in a row drops to $0.7^5 = 16.8%$. For Agent A, the 30 unmastered tasks rarely succeed even in 5 tries (pass@5 stays at 79.1%), while the 70 mastered tasks stay steady across repeats (pass^5 holds at 60.1%).

The practical takeaway is clear: pass@1 reports only the mean and hides whether variance lives across tasks or inside each task. Interactive copilots where users happily hit regenerate care about pass@k; automated customer support, billing reconciliation, and enterprise operations live or die by pass^k.

The plug-in bias trap: why you should not compute $\hat{p}^k$ directly

In a real evaluation, the true $p_i$ is unknown. You run each task $n$ times and observe $c$ successes.

Start with a small concrete example: one task runs $n = 8$ times and succeeds $c = 6$ times. We want to estimate pass^3 (the probability that 3 runs all succeed).

The naive approach computes the empirical rate $\hat{p} = 6 / 8 = 0.75$ and raises it to the third power: $0.75^3 = 0.4219$. This estimate is biased and systematically overstates true reliability.

Because $f(x) = x^3$ is strictly convex (curving upward), Jensen's inequality (for a strictly convex function, the expectation of the function exceeds the function of the expectation) guarantees $E[\hat{p}^3] > p^3$ whenever $\hat{p}$ has sampling variance. Conversely, $1 - (1 - x)^k$ is concave, so plugging $\hat{p}$ in directly systematically underestimates pass@k.

The fix is to sample $k$ runs without replacement from the $n$ observed trials, using the binomial coefficient $\binom{n}{k}$ (the number of ways to choose $k$ items from $n$) to form an unbiased estimator (an estimator whose average over repeated experiments equals the true parameter):

  • Unbiased pass@k estimator (Chen et al., 2021, Codex): among all $\binom{n}{k}$ subsets of size $k$, $\binom{n - c}{k}$ subsets contain only failures. Subtracting the all-failure probability from 1 gives:

$$\widehat{\mathrm{pass@}k} = 1 - \frac{\binom{n - c}{k}}{\binom{n}{k}}$$

  • Unbiased pass^k estimator (Yao et al., 2024, τ-bench): the fraction of size-$k$ subsets drawn entirely from the $c$ successes:

$$\widehat{\mathrm{pass}^k} = \frac{\binom{c}{k}}{\binom{n}{k}}$$

Back to $n = 8, c = 6, k = 3$: $\binom{8}{3} = 56$ and $\binom{6}{3} = 20$, so the unbiased pass^3 is $20 / 56 = 0.3571$ — 6.5 percentage points lower than the naive $0.75^3 = 0.4219$. Since only $n - c = 2$ failures occurred, no subset of size 3 can consist solely of failures ($\binom{2}{3} = 0$), so unbiased pass@3 is $1.0000$ rather than $1 - 0.25^3 = 0.9844$.

The self-contained Python script below verifies both the small example and a 100-task × 10-trial simulation of Agents A and B:

import math
import random
import statistics


def pass_at_k_unbiased(n: int, c: int, k: int) -> float:
    """Compute the unbiased pass@k estimator for a single task.

    Args:
        n: Total number of trials executed for the task.
        c: Number of successful trials.
        k: Target attempt budget (k <= n).
    """
    if n - c < k:
        # Fewer than k failures exist, so every k-subset contains at least one success.
        return 1.0
    return 1.0 - math.comb(n - c, k) / math.comb(n, k)


def pass_power_k_unbiased(n: int, c: int, k: int) -> float:
    """Compute the unbiased pass^k estimator for a single task.

    Args:
        n: Total number of trials executed for the task.
        c: Number of successful trials.
        k: Number of consecutive successes required (k <= n).
    """
    if c < k:
        # Fewer than k successes exist, so no k-subset can be all successes.
        return 0.0
    return math.comb(c, k) / math.comb(n, k)


def main() -> None:
    # 1. Small concrete example comparing naive plug-in vs. unbiased estimators
    n, c, k = 8, 6, 3
    p_hat = c / n
    print(f"Mini-example (n={n}, c={c}, k={k}):")
    print(f"  Naive pass^3 = {p_hat**k:.4f} | Unbiased pass^3 = {pass_power_k_unbiased(n, c, k):.4f}")
    print(f"  Naive pass@3 = {1 - (1 - p_hat)**k:.4f} | Unbiased pass@3 = {pass_at_k_unbiased(n, c, k):.4f}")

    # 2. 100-task simulation: both Agent A and Agent B have true pass@1 = 70.0%
    probs_a = [0.97] * 70 + [0.07] * 30
    probs_b = [0.70] * 100

    rng = random.Random(42)
    n_trials = 10
    counts_a = [sum(1 for _ in range(n_trials) if rng.random() < p) for p in probs_a]
    counts_b = [sum(1 for _ in range(n_trials) if rng.random() < p) for p in probs_b]

    print("\nSimulated (100 tasks x 10 trials, seed=42) unbiased estimates:")
    print(f"{'k':>2} | {'A pass@k':>9} | {'B pass@k':>9} | {'A pass^k':>9} | {'B pass^k':>9}")
    for kk in (1, 2, 3, 5, 8):
        a_at = statistics.mean(pass_at_k_unbiased(n_trials, cnt, kk) for cnt in counts_a)
        b_at = statistics.mean(pass_at_k_unbiased(n_trials, cnt, kk) for cnt in counts_b)
        a_pw = statistics.mean(pass_power_k_unbiased(n_trials, cnt, kk) for cnt in counts_a)
        b_pw = statistics.mean(pass_power_k_unbiased(n_trials, cnt, kk) for cnt in counts_b)
        print(f"{kk:>2} | {a_at*100:8.1f}% | {b_at*100:8.1f}% | {a_pw*100:8.1f}% | {b_pw*100:8.1f}%")


if __name__ == "__main__":
    main()

Typical output (with fixed seed=42):

Mini-example (n=8, c=6, k=3):
  Naive pass^3 = 0.4219 | Unbiased pass^3 = 0.3571
  Naive pass@3 = 0.9844 | Unbiased pass@3 = 1.0000

Simulated (100 tasks x 10 trials, seed=42) unbiased estimates:
 k |  A pass@k |  B pass@k |  A pass^k |  B pass^k
 1 |     69.0% |     70.4% |     69.0% |     70.4%
 2 |     72.5% |     91.2% |     65.5% |     49.6%
 3 |     73.8% |     97.5% |     63.3% |     35.2%
 5 |     76.3% |     99.9% |     59.2% |     18.2%
 8 |     79.8% |    100.0% |     53.5% |      7.4%

Notice the $k = 1$ row: across 1,000 samples, Agent B's empirical mean (70.4%) edges out Agent A (69.0%). Choosing by pass@1 alone picks Agent B; looking at pass^5 (59.2% vs. 18.2%) reveals a more than three-fold gap in production reliability.

Escaping the single-metric trap with the Pareto frontier

Replacing a scalar pass rate with pass@k and pass^k captures reliability, but real system selection also requires latency and cost.

For latency, teams track P50 (median latency, faster than 50% of runs) alongside P95 (95th-percentile latency, capturing the slow tail that users actually notice). Consider five realistic agent configurations evaluated on 200 tasks (120 standard + 80 hard) with 5 trials each:

  • C1: Fast-Small: lightweight model, minimal steps, lowest latency and cost.
  • C2: Balanced-Router: routes routine tasks to a small model and escalates hard tasks to a larger model, with basic argument validation.
  • C3: Heavy-Reasoner: sends every task to a strong reasoning model with multi-step reflection.
  • C4: Verbose-Retry: mid-tier model paired with aggressive retries and verbose prompts that bloat the context on failure.
  • C5: Max-Ensemble: multi-model voting plus multi-round verification to push accuracy as high as possible.

The script below evaluates all five configurations and identifies which ones sit on the Pareto frontier (the set of non-dominated options where improving any single metric requires giving up ground on at least one other metric):

import math
import random
import statistics


def pass_at_1(n: int, c: int) -> float:
    return c / n


def pass_power_5(n: int, c: int) -> float:
    return math.comb(c, 5) / math.comb(n, 5) if c >= 5 else 0.0


def is_dominated(target: dict, others: list[dict]) -> bool:
    """Return True if another configuration strictly dominates target.

    A configuration dominates target when its pass^5 is at least as high,
    its P95 latency is at least as low, its cost is at least as low, and
    at least one of those three inequalities is strict.
    """
    for o in others:
        if o["name"] == target["name"]:
            continue
        better_or_equal = (
            o["pass_pow5"] >= target["pass_pow5"]
            and o["p95"] <= target["p95"]
            and o["cost"] <= target["cost"]
        )
        strictly_better = (
            o["pass_pow5"] > target["pass_pow5"]
            or o["p95"] < target["p95"]
            or o["cost"] < target["cost"]
        )
        if better_or_equal and strictly_better:
            return True
    return False


def main() -> None:
    # (name, easy_p, hard_p, base_lat_s, step_lat_s, mean_steps, cost_per_step_usd)
    configs = [
        ("C1: Fast-Small",      0.86, 0.35, 0.8, 0.45, 3.2, 0.002),
        ("C2: Balanced-Router", 0.96, 0.65, 1.2, 0.70, 4.4, 0.008),
        ("C3: Heavy-Reasoner",  0.98, 0.82, 2.5, 1.45, 6.1, 0.024),
        ("C4: Verbose-Retry",   0.92, 0.62, 1.8, 1.15, 7.8, 0.015),
        ("C5: Max-Ensemble",    0.99, 0.86, 4.2, 2.10, 8.5, 0.048),
    ]

    rng = random.Random(2026)
    rows = []
    for name, p_easy, p_hard, lat0, lat_step, steps_mu, cost_step in configs:
        task_ps = [p_easy] * 120 + [p_hard] * 80
        p1_list, p5_list, latencies, costs, steps_all = [], [], [], [], []
        for p in task_ps:
            c = 0
            for _ in range(5):
                ok = rng.random() < p
                c += int(ok)
                # Failed trajectories typically take ~30% more retry/detour steps.
                st = max(1, round(rng.gauss(steps_mu * (1.0 if ok else 1.3), 1.0)))
                lat = max(0.5, lat0 + st * rng.gauss(lat_step, lat_step * 0.15))
                cost = st * cost_step * rng.uniform(0.9, 1.1)
                steps_all.append(st)
                latencies.append(lat)
                costs.append(cost)
            p1_list.append(pass_at_1(5, c))
            p5_list.append(pass_power_5(5, c))
        latencies.sort()
        rows.append({
            "name": name,
            "pass1": statistics.mean(p1_list) * 100,
            "pass_pow5": statistics.mean(p5_list) * 100,
            "p50": latencies[len(latencies) // 2],
            "p95": latencies[int(len(latencies) * 0.95)],
            "cost": statistics.mean(costs),
            "steps": statistics.mean(steps_all),
        })

    print(f"{'Config':<22} | {'pass@1':>6} | {'pass^5':>6} | {'P50(s)':>6} | {'P95(s)':>6} | {'Cost($)':>8} | {'Status'}")
    for r in rows:
        status = "Dominated" if is_dominated(r, rows) else "Pareto"
        print(
            f"{r['name']:<22} | {r['pass1']:5.1f}% | {r['pass_pow5']:5.1f}% | "
            f"{r['p50']:6.2f} | {r['p95']:6.2f} | ${r['cost']:7.4f} | {status}"
        )


if __name__ == "__main__":
    main()

Typical output:

Config                 | pass@1 | pass^5 | P50(s) | P95(s) |  Cost($) | Status
C1: Fast-Small         |  64.6% |  31.0% |   2.35 |   3.40 | $ 0.0070 | Pareto
C2: Balanced-Router    |  84.9% |  53.5% |   4.43 |   6.13 | $ 0.0372 | Pareto
C3: Heavy-Reasoner     |  92.6% |  69.5% |  11.48 |  15.32 | $ 0.1495 | Pareto
C4: Verbose-Retry      |  79.7% |  44.0% |  11.16 |  15.04 | $ 0.1243 | Dominated
C5: Max-Ensemble       |  92.9% |  72.0% |  22.43 |  29.01 | $ 0.4176 | Pareto

Plotting mean cost per task against pass^5 reliability, with marker size encoding P95 latency:

Pareto frontier of five agent configurations: cost, P95 latency, and pass^5

Two engineering decisions fall directly out of this plot:

  • Eliminate strictly dominated configurations immediately: C4: Verbose-Retry loses to C2: Balanced-Router on pass^5 (44.0% vs. 53.5%), P95 latency (15.04s vs. 6.13s), and mean cost (USD 0.1243 vs. USD 0.0372). No budget or latency target can justify deploying C4.
  • Pick on the frontier by operational constraints, not by highest raw score: C5: Max-Ensemble sits on the frontier with the highest score, yet compared to C3: Heavy-Reasoner it adds only 0.3 percentage points on pass@1 and 2.5 percentage points on pass^5 while multiplying cost by 2.8x (USD 0.1495 to USD 0.4176) and nearly doubling P95 latency (15.32s to 29.01s). That trade-off makes sense only for high-value offline jobs; interactive products usually land on C2 or C3.

The four-part object an agent evaluation actually measures

Putting the three sections together, a serious agent evaluation does not return a single scalar score; it measures a four-part tuple:

  1. Capability and reliability distribution: repeat every task across multiple trials and report unbiased pass@k alongside pass^k, separating "can solve it once" from "solves it every time".
  2. Trajectory validity: separate the final output from the execution path so false passes and near misses do not cancel each other out.
  3. Resource and latency envelope: track P50/P95 latency, step count, and per-task cost, using the Pareto frontier to cut dominated designs.
  4. Safety and permission boundaries: treat unauthorized access, sensitive-identifier leakage, and irreversible side effects as hard red lines rather than weighted terms in an average score.

All four depend on one prerequisite: when you repeat a task 5 or 10 times, the world state the agent interacts with must reset cleanly to the exact starting point, so side effects from trial 1 (sent messages, mutated rows) never contaminate trial 2. The next article turns to that foundation — building resettable stateful sandboxes, state-based assertions, and user simulators for multi-turn evaluation.

Back to top