Skip to content
Agents2026-11-0810 min read

Best-of-N Sampling With a Verifier for Terminal Agents

A terminal agent can sample several commands and check them before running one. A short model shows why the check, not the sample count, sets what that buys.

Predict first. A terminal agent samples 8 candidate commands, and 30% of what it samples is good. A verifier scores good commands one standard deviation higher than bad ones and runs the top scorer. What are the chances the command it runs is good? Decide before you read on.

Key takeaways β€” after your prediction
  • Mid-Harness (arXiv 2609.39982) samples several candidate actions from a terminal agent, has a verifier pick one, and runs only that one. Its largest reported gain, 50.00% to 68.03% Pass@1 on TerminalBench-Lite, uses a frontier verifier and eight samples, and the authors use it to probe whether the generator's candidates contain better actions, not as self-verification.
  • In a one-decision model where 30% of sampled commands are good, eight samples and a verifier one standard deviation sharp pick a good command 61.8% of the time. The ceiling, at least one good sample, is 94.2%. With a verifier that cannot tell good from bad, eight samples give the base 30.0%.
  • In the model, a sharper verifier beats more samples: 16 samples with a weak verifier (0.5 standard deviations) give 50.2%, while 8 samples with a sharp one (2 standard deviations) give 83.8%.
  • A task that needs five good actions in a row succeeds 16.8% of the time at 70% per step and 59.0% at 90%, so a per-step gain compounds.
  • The paper says action reliability does not establish that generated commands are safe, so a verifier that picks better commands does not replace safeguards.

Rod Rivera

Author

Best-of-N Sampling With a Verifier for Terminal Agents

Rod's note: read with a pencil; the margins are for you.

An agent that runs shell commands makes a decision at every step: which command to run next. Running a bad one can break the task, and some bad commands cannot be undone. A paper posted on September 30, 2026 asks what happens if the agent samples several candidate commands, has a verifier choose one, and runs only that one. This article builds the smallest model of that idea, reads what the paper does and does not measure, and ends on the part a model cannot settle: whether the chosen command is safe.

What is read and what is executed

The paper (arXiv 2609.39982) was read on October 16, 2026: the abstract and the first 200,000 of 220,917 characters of the full text. We read only the abstract of HarnessDev (arXiv 2609.01437). The code below was executed that day with Python 3.14.6 and 3.9.6, and the output was identical on both. It is a model with invented numbers. We did not rerun any paper's experiments.

Sample, verify, execute

In Mid-Harness, as the paper describes it, the agent's model samples N candidate actions from the same history at each step. A verifier picks one, and only that one reaches the harness, the code that runs the commands. The other candidates are discarded. The model, the harness and the model's weights stay as they were, so the method is a wrapper around the call.

The paper compares three ways to verify. A listwise verifier sees all N candidates in one call and returns a choice. A pointwise verifier scores each candidate on its own. A pairwise verifier compares pairs of candidates, which at N = 8 takes 28 calls, against 1 for listwise and 8 for pointwise. In self-verification the generator and the verifier are the same model.

One step of sample, verify, execute. Discarded; Agent history; Sample N candidate commands; Verifier scores or compares them; Run only the top choice; Observe the result; The other N minus 1 candidates
One step of sample, verify, execute
View full-size diagram

What the paper reports

The generator is TMAX-9B, a model fine-tuned from Qwen3.5-9B, in a harness the paper calls Vanillux2, with three runs per task. The main benchmark is TerminalBench-Lite. Pass@1 is the mean success rate across the three runs.

The headline number is a rise in Pass@1 from 50.00% to 68.03%. It comes from using GPT-5.6 Sol as a listwise verifier with eight samples, and the paper uses it as a probe: with no ground-truth labels for candidate actions, a strong verifier shows whether the generator's candidates contain better alternatives. It is not a self-verification result, and it does not show that the generator can find those alternatives itself. When TMAX-9B verifies its own candidates, the paper reports Pass@1 of 51.02% for a zero-shot listwise verifier with eight samples and 54.76% for zero-shot pairwise verification. After training the 9B model on a frontier verifier's pairwise judgments, it reports 57.14%.

The paper's own summary of the pattern is that with a weak verifier, adding samples helps little, and a capable verifier can pick better alternatives from the same generator. The rest of this article shows why that has to be true.

A model of one decision

Take one decision. Each sampled command is good with probability 0.30. The verifier gives every candidate a score: good candidates score around a mean of d, bad ones around 0, with one standard deviation of noise on each. The verifier runs the highest score. The larger d is, the better the verifier separates good from bad.

In the figure you can change the number of samples n, the share of good candidates p, and the separation d. Make a prediction first, then let the figure show the chance that the command that runs is good.

Which candidate wins the check?

More candidates help only if the verifier can pick a good one. It scores every candidate and executes the highest scorer.

is the chance a candidate is good; separates the average good score from the average bad score, in standard deviations; candidates compete.

A good candidate scores d + z; a bad one scores z. Here z has a standard normal distribution. Its density is Ο†(z), and Ξ¦(z) is the chance a standard normal score lies below z.

P(good choice)= n p βˆ«βˆ’βˆžβˆž Ο†(z) [pΞ¦(z)+(1βˆ’p)Ξ¦(z+d)]nβˆ’1dz

The bracket is the chance one rival scores below a particular good candidate. All n βˆ’ 1 rivals must score below it. The integral adds these possibilities; n p accounts for which candidate is good and wins.

Worked values: n = 8, p = 0.30, d = 1.

Start with one candidate

With one candidate and p = 30%, the chance of a good choice is 30%. There is nothing to rank. What changes when eight candidates compete?

Now change a value. Predict the percentage of decisions that choose a good candidate, then check.

Your example

Record a prediction to check your example.

Invented probabilities, not measurements of any paper's agents. Candidates are independent; scores have independent Gaussian noise with equal variance. Real candidates and verifier mistakes can be correlated. Choosing a better command does not establish that executing it is safe.

Quick check β€” With 8 samples where 30% of candidates are good, and a verifier whose scores for good commands average one standard deviation above bad ones, what are the chances the command that runs is good?

Check the prediction

Between the two bounds, nearer the lower one

With no signal, the verifier's choice is random and the chance stays at 30%. With a perfect verifier the chance is the chance that at least one of the eight samples is good, 1 minus 0.7 to the eighth power, which is 94.2%. A verifier one standard deviation sharp lands between them, at about 62%.

Save this as select_actions.py:

python
import math
import random

P_GOOD = 0.30      # chance one sampled candidate action is good
STEPS = 5          # a task needs this many good actions in a row

def phi(x):
    return math.exp(-x * x / 2) / math.sqrt(2 * math.pi)

def big_phi(x):
    return 0.5 * (1 + math.erf(x / math.sqrt(2)))

def p_pick_good(k, d, p=P_GOOD):
    """Chance the top-scored of k candidates is good. A good candidate scores
    N(d, 1) and a bad one N(0, 1); the verifier picks the highest score."""
    if k == 1:
        return p
    total, lo, hi, n = 0.0, -10.0, 10.0 + d, 4000
    h = (hi - lo) / n
    for i in range(n + 1):
        x = lo + i * h
        w = 0.5 if i in (0, n) else 1.0
        below = (1 - p) * big_phi(x) + p * big_phi(x - d)       # a rival scores under x
        total += w * k * p * phi(x - d) * below ** (k - 1)
    return total * h

def covered(k, p=P_GOOD):
    """Chance at least one of k candidates is good: the ceiling for any verifier."""
    return 1 - (1 - p) ** k

def simulate(k, d, trials, rng, p=P_GOOD):
    def normal():
        u1, u2 = rng.random(), rng.random()
        return math.sqrt(-2 * math.log(1 - u1)) * math.cos(2 * math.pi * u2)
    wins = 0
    for _ in range(trials):
        best, best_good = -1e9, False
        for _ in range(k):
            good = rng.random() < p
            s = normal() + (d if good else 0.0)
            if s > best:
                best, best_good = s, good
        wins += best_good
    return wins / trials

def calls(k, kind):
    return {"listwise": 1, "pointwise": k, "pairwise": k * (k - 1) // 2}[kind]

if __name__ == "__main__":
    print("chance the chosen action is good (one good action = 30% of samples):")
    print("  k   d=0   d=0.5   d=1.0   d=2.0   d=4.0   ceiling")
    for k in (1, 2, 4, 8, 16):
        row = [p_pick_good(k, d) for d in (0.0, 0.5, 1.0, 2.0, 4.0)]
        print(f"{k:3d}  " + "  ".join(f"{v:.3f}" for v in row) + f"   {covered(k):.3f}")
    rng = random.Random(5)
    print(f"check k=8, d=1: exact {p_pick_good(8, 1.0):.4f}, simulated {simulate(8, 1.0, 20000, rng):.4f}")
    print(f"a {STEPS}-step task, per-step 0.70 vs 0.90: {0.70 ** STEPS:.3f} vs {0.90 ** STEPS:.3f}")
    print("verifier calls for k=8:", {kind: calls(8, kind) for kind in ("listwise", "pointwise", "pairwise")})

Run python3 select_actions.py. The output was identical on Python 3.14.6 and 3.9.6:

text
chance the chosen action is good (one good action = 30% of samples):
  k   d=0   d=0.5   d=1.0   d=2.0   d=4.0   ceiling
  1  0.300  0.300  0.300  0.300  0.300   0.300
  2  0.300  0.358  0.409  0.477  0.509   0.510
  4  0.300  0.411  0.519  0.675  0.757   0.760
  8  0.300  0.459  0.618  0.838  0.939   0.942
 16  0.300  0.502  0.700  0.932  0.996   0.997
check k=8, d=1: exact 0.6176, simulated 0.6212
a 5-step task, per-step 0.70 vs 0.90: 0.168 vs 0.590
verifier calls for k=8: {'listwise': 1, 'pointwise': 8, 'pairwise': 28}

The d = 0 column is a verifier with no signal: the chance never leaves 30%, whatever the number of samples. Each other column rises with k toward the ceiling at the right, and the gap between a column and the ceiling is the price of an imperfect verifier. Sixteen samples with a weak verifier (d = 0.5) give 50.2%. Eight samples with a sharp one (d = 2) give 83.8%. In this model, spending on the verifier beats spending on samples. The exact value is a numerical integral, and the simulation agrees with it within sampling noise: 0.6212 against 0.6176 over 20,000 trials.

From one decision to a task

A terminal task is a chain. If a task needs five good actions in a row, a 70% chance per step gives 16.8% and a 90% chance gives 59.0%. A step-level gain compounds, which is why a modest improvement in the chosen action can move a task-level number a long way. The model says nothing about how large the paper's per-step gains are. It shows only why they are worth measuring at the step.

What the paper's numbers can and cannot tell you

Three points about reading the table, using the paper's own statements.

  • The ceiling is unmeasured. The paper says there are no gold action labels, so verification correctness and candidate coverage, the right-hand column above, cannot be measured directly. Without it, you cannot tell whether a small gain is a weak verifier or a generator whose samples are all bad.
  • The offline checks measure agreement with the teacher, not correctness. The distilled verifier's agreement with the teacher on pairwise judgments rises from 59.01% to 74.58% on 21 held-out tasks. Agreement with a stronger model is not agreement with the truth.
  • Small gaps need error bars. The main table gives point estimates. Appendix B.1 says TerminalBench-Lite has 100 tasks, two of which were excluded for sandbox service errors, leaving 98, so with three runs each the Pass@1 values are multiples of 1/294 and the distillation gain from 54.76% to 57.14% is 7 runs. Appendix C.4 reports a paired bootstrap over the 98 tasks, 95% intervals against the base agent: +4.76 points with an interval of -0.68 to +10.20 for zero-shot 9B pairwise verification, and +7.14 with an interval of +1.36 to +12.93 for the distilled verifier. The first interval includes zero. The paper does not report an interval for the step from 54.76% to 57.14% itself.

Questions to ask before adding a verifier

Measure how often a good candidate exists

Sample N candidates on real tasks and have a person label which are good. If one is good in only a few cases, no verifier will help.

Measure the verifier on its own

Score its choices against those labels before wiring it into the agent. Agreement with a stronger model is a proxy.

Count the calls

Pairwise verification at eight samples takes 28 calls, and the paper reports that its decision-only variant, which outputs only the choice, lowers reference-priced token cost by 20.9% and 24.1% for the zero-shot and distilled verifiers at 9B.

Keep the safeguards

The paper's ethics statement says that action reliability does not establish that generated commands are safe. A verifier that picks better commands is not a permission system.

What to take from it

Sampling gives a verifier something to choose from, and the choice is only as good as the verifier's ability to separate good from bad. In the model, that ability moves the result more than the sample count does. The paper's headline gain uses a frontier verifier, and its self-verification gains are smaller. This is a reading of one preprint and a model, not a ranking of agents or verifiers.

For a related exercise in checking what a signal rewards, see how to build an RL environment with a verifier in Python.

Read: build an agent eval environment that resists reward hacking

Once you can reason about a verifier, design the task so it can be checked.

Learn the mechanism. Test the claim.

Join the Prof Rod newsletter for one educational lesson a week, with worked examples attached. It is free to register for and separate from the Zero Employee community.