An agent adds one thing to the verifier loop: after a failed attempt it sees the failure and conditions on it.
In real systems that means putting the failing test, the expected output and the traceback in the next prompt (Chen, Lin, Schärli and Zhou, 2023, call this self-debugging). In our stand-in it means this: the failing test shows the model the expected output on one input, so the model never proposes again a program that is wrong on that input, and it samples from its own distribution restricted to the programs that are consistent with everything it has been shown. This is a modelling choice, chosen because it is mechanical and analyzable. It is not a claim about how a language model uses feedback.
Each step records the action (a fresh sample at the first step, a repair afterwards), the program chosen, the number of visible tests passed, whether it was accepted, and the running cost. A fresh sample costs 1.0, a repair 1.5 (longer prompt), and each test run 0.05. The loop stops at the first accepted program, at the step cap, or when no consistent program is left.
Before the experiment, a statement about what feedback can and cannot do.
Proposition 7.7 (feedback cannot raise the ceiling). Let be the set of programs the suite accepts. In the feedback agent with no step cap, the probability that the returned program is equals , the same as for resampling without feedback. Hence the correct-return probability and the wrong-return probability of Theorem 7.2 at are unchanged. Feedback changes how many steps are needed, not which program is eventually accepted.
Proof. Programs in pass every test, so they are never eliminated. At a step with alive set the agent draws with probability , so conditional on drawing from it draws with probability , whatever is. The loop stops at the first draw from , and it must stop, since each earlier draw is a rejected program which is removed from the alive set, so at most steps are possible. Let index steps and be the probability of reaching step without having drawn from . Then , because the second sum is the probability of eventually drawing from , which is 1.
The single episode (task 15, whose true pass@1 is 0.012) shows the failure the companion book is about. The agent samples a program that passes 2 of 4 examples, repairs to one that passes 3 (the crash program, which fails on the empty list), and repairs again to a program that passes 4 of 4 and is accepted at a cumulative cost of 4.60. It is a guard program, wrong on the hidden suite. The log makes the failure visible only if someone looks at the hidden-suite column, which a deployed system does not have.
In aggregate, over 36 tasks and 200 episodes each, with four small examples as the visible suite, resampling without feedback matches the iid theory: at cap 8 it returns a correct program in 0.5112 of episodes against 0.5219 predicted, and a wrong program in 0.4722. Feedback reaches the ceiling sooner: at cap 2 it is correct in 0.5071 of episodes against 0.4762 for resampling, by cap 4 every episode has accepted some program (gave up 0.0000) and it settles at 0.5224, the same as the ceiling of 0.523 from the companion book example, as Proposition 7.7 says it must. It reaches that value at lower cost: 1.832 per episode against 2.042. Per correct answer, cost is 3.507 against 3.995. The intervals (plus or minus 0.10 to 0.11 across tasks) are wide because tasks differ, but both arms use the same tasks and the ceilings are equal by proof.
With eight random real inputs as the suite, the picture is the same at a higher level: feedback gives 0.6115 correct at cap 8 against 0.6065 for resampling, with a wrong-return rate of 0.3885 against 0.3717 and a cost per correct answer of 3.957 against 4.649. A stronger suite lifts the ceiling from 0.523 to 0.617 and lowers the wrong-return rate of resampling from 0.4722 to 0.3717 of episodes, but more than a third of the returned programs are still wrong.
What the agent saves is steps and money, which is worth having. What it cannot save is the correctness gap, which only better tests, an independent check, or a human can close. Whether feedback can ever raise the ceiling depends on whether the feedback carries information about the hidden spec beyond the visible tests (a real model reading an error message might), and that is outside what a stand-in can answer.
Continue with the book
Explore the full treatment, worked examples, and exercises in Applied AI for Generation and Control.
Companion article for Applied AI for Generation and Control, published by Choral Software. Article text and original examples © 2026 Choral Software. All rights reserved.
