Agentic Pattern Libraryby Vikas Goyal
Patterns / Math models / pass@k vs pass^k
No. M05 Evaluation Established Verification

pass@k vs pass^k

Capability, \(1-(1-p)^k\), versus consistency, \(p^k\)

Takeaway

An agent that passes % of tasks on one try solves 94% of them at least once in tries, but only 41% every time.

Change the blue numbers. Every figure on this page updates with them.

Why care

Most eval scores answer "can it?". Customers experience "does it, every time?".

pass@k, borrowed from code-generation benchmarks, counts a task as solved if any of \(k\) attempts succeeds. That suits a developer who reruns until something works. An agent in production gets one shot per customer, and the same task comes up again and again. pass^k counts a task as solved only if all \(k\) attempts succeed, which is what reliability looks like from the outside. The two numbers start equal at \(k=1\) and then move in opposite directions, and how far apart they drift tells you how consistent the agent is.

The intuition

Two agents both score 75% on one try. The first is a careful specialist: it always solves three tasks in four and never solves the fourth. The second is a gifted but erratic generalist: it solves every task 75% of the time.

Specialist, pass@8
75%
Specialist, pass^8
75%
Generalist, pass@8
100%
Generalist, pass^8
10%

pass@k rewards the generalist, because given enough tries it gets everything. pass^k rewards the specialist, because what it does, it does every time. Real agents sit between the two, and the gap between their pass@k and pass^k shows where.

The math

For one task that the agent solves with probability \(p\) on each try:

$$\text{pass@}k = 1-(1-p)^k \qquad\qquad \text{pass}^k = p^k$$

A benchmark averages over tasks, each with its own \(p_i\). Averaging first and then raising to a power gives the wrong answer, because \(\mathbb{E}[p_i^k] \neq (\mathbb{E}[p_i])^k\):

$$\text{pass@}k = \frac{1}{T}\sum_{i=1}^{T}\big(1-(1-p_i)^k\big) \qquad \text{pass}^k = \frac{1}{T}\sum_{i=1}^{T} p_i^{\,k}$$

From \(n\) runs per task with \(c_i\) successes, these unbiased estimators use every run rather than just the first \(k\):

$$\widehat{\text{pass@}k} = 1-\frac{\binom{n-c_i}{k}}{\binom{n}{k}} \qquad\qquad \widehat{\text{pass}^k} = \frac{\binom{c_i}{k}}{\binom{n}{k}}$$
\(p_i\)
probability the agent solves task \(i\) on a single try
\(k\)
number of tries being scored
\(T\)
number of tasks in the benchmark
\(n,\ c_i\)
runs per task, and how many of them succeeded on task \(i\); requires \(n \ge k\)
  • Same pass@1, different futures: two agents with equal pass@1 can have very different pass^k. The spread of \(p_i\) across tasks decides it.
  • The naive shortcut is pessimistic: \((\text{pass@}1)^k\) assumes every task is equally hard. Real tasks vary, so real pass^k is higher than the shortcut, often by a lot.
  • The gap is a consistency score: pass@k minus pass^k is the share of tasks the agent can do but does not do reliably.

Where each of these comes from is worked through in Derivations at the end of the page.

Interactive calculator

Per-task success rates are modeled as a Beta distribution with your average. Slide task similarity from "all-or-nothing" to "every task alike" and watch pass@k and pass^k pull apart.

Left: each task is either almost always or almost never solved. Right: every task is equally hard.
–
pass@k: solved at least once
–
pass^k: solved every time
–
Can do, but not reliably
–
Naive shortcut, (pass@1)^k
pass@k pass^k Naive (pass@1)^k

Worked example: two versions of a service agent

A team ran two versions of a customer-service agent on the same 50 tasks, eight times each: 400 runs per version. The leaderboard showed pass@1, and version A led, 72% to 70%. Counting successes per task told a different story:

MetricVersion AVersion B
pass@172.0%70.0%
pass@8, solved at least once88.0%90.0%
pass^262.0%65.4%
pass^451.1%62.1%
pass^8, solved every time40.0%60.0%

Version A solved 20 tasks perfectly and was shaky on 24 more. Version B solved 30 perfectly and failed outright on a small cluster of refund cases. For a customer who brings the same kind of request every week, B is right half again as often. The naive shortcut would have put A's pass^8 at \(0.72^8 = 7\%\), badly understating it, which is why the estimators above count per task.

The team shipped B, and turned B's cluster of failures into the next sprint's work, because failures concentrated in a few tasks are much easier to fix than failures spread thinly everywhere.

Assumptions and where it breaks

  • Runs of the same task are treated as independent. With temperature 0 and cached tools, reruns may be near-identical, which makes pass^k look better than real traffic would. Vary seeds, phrasings or user simulations between runs.
  • You need several runs per task. The estimators require \(n \ge k\), and with small \(n\) each task's estimate is coarse. Eight runs per task is a common practical floor for pass^k up to 8.
  • pass@k assumes you can pick the winner. It is the right metric only when something downstream (tests, a human, a verifier) chooses the successful attempt. Without a checker, see M10 on voting.
  • Tasks are weighted equally. If some tasks are far more common in production, weight each task's term by its traffic share.
  • Binary success hides partial credit. A run that gets 9 of 10 fields right counts as a failure. If partial results are useful, score them, and report consistency on the score instead.

How to apply it

  1. Run every eval task several times. At least five, ideally eight, with varied seeds or simulated users.
  2. Report both numbers. pass@1 for headline capability, pass^k at the \(k\) that matches how often users repeat a request.
  3. Use the per-task estimators. Compute pass@k and pass^k from each task's \(n\) and \(c_i\), then average. Never raise the average to a power.
  4. Sort tasks by consistency. Tasks with \(0 < c_i < n\) are the flaky ones; they are where prompt, tool and guardrail fixes pay off most.
  5. Compare versions on pass^k before shipping anything customer-facing, and put a confidence interval on the gap (M06).

How to explain it to a stakeholder

"pass@k asks whether the agent can do the job. pass^k asks whether it does the job every time your customer asks. We ship on the second number."

For coding agents

A machine-readable summary and a reference implementation. The same spec is embedded in this page as <script type="application/json" id="model-spec">, and the whole series is listed in models.json.

Model spec (YAML)
id: pass-at-k
number: M05
name: pass@k vs pass^k
family: evaluation
answers: "Is the agent capable (solves at least once) or consistent (solves every time)?"
formula:
  pass_at_k_task: "1 - comb(n - c, k) / comb(n, k)"
  pass_hat_k_task: "comb(c, k) / comb(n, k)"
  benchmark: "mean over tasks of the per-task estimate"
inputs:
  n: {type: int, meaning: runs per task, must be >= k}
  c: {type: int, meaning: successful runs for a task}
  k: {type: int, meaning: tries being scored}
assumptions:
  - runs of a task are independent draws
  - tasks weighted equally unless traffic weights are applied
  - success is binary
use_when:
  - comparing agent versions before shipping
  - separating capability gaps from consistency gaps
related_patterns: [llm-as-judge, learning-loop, test-first-loop]
Reference implementation (Python)
from math import comb

def pass_at_k(n, c, k):
    """Unbiased estimate that at least one of k tries succeeds (Chen et al., 2021)."""
    if n - c < k:
        return 1.0
    return 1 - comb(n - c, k) / comb(n, k)

def pass_hat_k(n, c, k):
    """Unbiased estimate that all k tries succeed (Yao et al., 2024)."""
    return comb(c, k) / comb(n, k)

def benchmark(successes, n, k):
    """successes: list with one success count per task, each out of n runs."""
    at = sum(pass_at_k(n, c, k) for c in successes) / len(successes)
    hat = sum(pass_hat_k(n, c, k) for c in successes) / len(successes)
    return at, hat

if __name__ == "__main__":
    version_a = [8]*20 + [7]*10 + [5]*8 + [3]*6 + [0]*6
    version_b = [8]*30 + [6]*5 + [1]*10 + [0]*5
    for k in (1, 8):
        print(k, benchmark(version_a, 8, k), benchmark(version_b, 8, k))
    # 1 (0.72, 0.72) (0.70, 0.70)
    # 8 (0.88, 0.40) (0.90, 0.60)

Derivations

For the math-curious: where each result in The math comes from. Nothing above depends on reading this.

One task: at least once versus every time

With independent tries, all \(k\) fail with probability \((1-p)^k\), so at least one succeeds with \(1-(1-p)^k\). All \(k\) succeed with \(p^k\). At \(k=1\) both equal \(p\). As \(k\) grows, the first rises toward 1 and the second falls toward 0, unless \(p\) is exactly 0 or 1.

Why the shortcut \((\text{pass@}1)^k\) understates consistency

The function \(x \mapsto x^k\) is convex for \(k \ge 1\). Jensen's inequality says that for a convex function, the average of the function is at least the function of the average:

$$\frac{1}{T}\sum_i p_i^{\,k} \;\ge\; \Big(\frac{1}{T}\sum_i p_i\Big)^k.$$

Equality holds only when every task has the same \(p_i\). The more tasks differ, the more real pass^k exceeds the shortcut. The same argument applied to \((1-p_i)^k\) shows real pass@k is below \(1-(1-\text{pass@}1)^k\).

The unbiased estimators

Suppose a task was run \(n\) times with \(c\) successes. Pick \(k\) of the \(n\) runs at random, without replacement. The chance all \(k\) picked runs are successes is \(\binom{c}{k}/\binom{n}{k}\), and the chance none are is \(\binom{n-c}{k}/\binom{n}{k}\). Averaged over the randomness in which runs succeeded, these equal \(p^k\) and \((1-p)^k\) exactly, so they are unbiased. They also use all \(n\) runs, which gives lower variance than scoring only the first \(k\).

The calculator's Beta model

The calculator treats each task's \(p_i\) as drawn from a Beta distribution with mean \(\bar p\) and concentration \(\kappa\): \(\alpha = \bar p\kappa,\ \beta = (1-\bar p)\kappa\). Small \(\kappa\) puts most tasks near 0 or 1; large \(\kappa\) makes every task close to \(\bar p\). Beta moments have a closed form:

$$\mathbb{E}[p^k] = \prod_{j=0}^{k-1}\frac{\alpha+j}{\kappa+j}, \qquad \mathbb{E}[(1-p)^k] = \prod_{j=0}^{k-1}\frac{\beta+j}{\kappa+j},$$

so pass^k \(= \mathbb{E}[p^k]\) and pass@k \(= 1-\mathbb{E}[(1-p)^k]\), with no simulation needed.

References

  1. Chen, M. et al. (2021). Evaluating Large Language Models Trained on Code. Introduces pass@k and its unbiased estimator.
  2. Yao, S. et al. (2024). τ-bench: A Benchmark for Tool-Agent-User Interaction in Real-World Domains. Introduces pass^k and shows agents' consistency falling far below their single-try success.