pass@k against pass^k: how sampling many attempts changes what a code or agent score means
Code and agent benchmarks sample each problem many times. pass@k asks whether at least one of k attempts works; pass^k asks whether all k do. Edit the pass counts, change n and k, and watch one set of results give an optimistic and a sobering score.
Interactive simulation. It needs JavaScript; the text below explains what it shows.
A coding model rarely gets the same answer twice. Sample it ten times on one problem and some attempts pass the unit tests while others fail. Code and agent benchmarks turn those repeated attempts into scores in two opposite ways, and the gap between them says a lot about a model.
What you are looking at
Each row of the table is one problem, with the number of attempts that passed out of n. The orange columns give, for every problem, its success rate, its pass@k, its pass^k, and the naive pass@k you get by plugging the success rate into a simple formula.
The results panel averages over problems: pass@1, pass@k, pass^k, the naive estimate and how far it falls short, and the share of problems solved by at least one of the n attempts. The chart shows, for a single problem, how both scores depend on its number of correct attempts. The dots are the unbiased pass@k values for the problems in the table, and the axis is drawn for n = 10.
The algorithm
Suppose a problem was attempted n times and c attempts passed.
- pass@1 is simply c divided by n, averaged over problems.
- pass@k asks: if we drew k of the n attempts at random, would at least one pass? All k fail only if they all come from the n − c failures. The number of ways to pick k failures is C(n − c, k) out of C(n, k) ways in total, so pass@k = 1 − C(n − c, k) / C(n, k).
- pass^k asks: would all k pass? That needs all k drawn from the c successes: pass^k = C(c, k) / C(n, k).
- Average each over problems to get the benchmark score.
Why not estimate the success rate p = c/n and use 1 − (1 − p)^k? Because that formula is curved, and plugging in a noisy estimate of p gives a biased answer: on average it is too low. Chen and colleagues introduced the counting formula in step 2 when they released Codex and the HumanEval benchmark, because it is unbiased. They generate n samples with n at least k and count the correct ones.
With the example (12 problems, 10 attempts each, k = 3), pass@1 is 40.0%, pass@3 is 62.9%, but pass^3 is only 19.0%. The naive formula gives 60.4%, short by 2.5 points. These values match the reference pass@k function from the HumanEval paper, run on the same counts.
The two metrics answer different questions. pass@k fits settings where you can check the answers, such as running unit tests and keeping any version that passes. pass^k fits agents that act for users, where every run has to work: a customer service agent that solves a task on one try out of three is not reliable.
Things to try
- Set k to 1: all three scores equal the mean success rate. Differences only appear when k grows.
- Raise k to 5 and then 10. pass@k climbs towards the share of problems solved at least once (83.3% here), while pass^k falls towards the share solved every time.
- Watch the bias: at k = 5 the naive formula is 3.9 points too low, at k = 10 the gap is larger still.
- Change a problem from 5 passes to 9. Its pass^k jumps much more than its pass@k: reliability rewards consistency.
- Set n to 50 and enter counts out of 50. More samples per problem make both estimates less noisy.
- Paste the pass counts from your own code or agent eval run and compare pass@k and pass^k for your model.
How it works in real systems
The Codex paper reported that its model solved 28.8% of HumanEval problems with one sample and 70.2% with 100 samples per problem. That gap is why reported pass@k numbers must always state k, and why a pass@100 figure says little about how a model behaves when used once. The paper's estimator is now the standard way to report pass@k, and the HumanEval repository contains the implementation.
The τ-bench paper introduced pass^k to measure the reliability of tool-using agents over repeated trials. Its authors report that even strong function-calling agents such as gpt-4o succeed on fewer than half of the tasks, and reach a pass^8 below 25% in the retail domain. A model can look strong on pass@k and weak on pass^k at the same time.
When you compare models, use the same n, k, sampling temperature and test harness, since all of these change the score. The Codex paper found that the best sampling temperature rises with k, because more diverse attempts give pass@k more chances. For how temperature shapes the sampling distribution, see sampling with temperature and top-p; to test whether a gap between two models on the same problems is real, see the paired evaluation simulation.