Language models that fix code in a loop (write a program, run the tests, read the failures, try again) help for two or three rounds and then stop helping. Beyond that point they begin to game the tests they are shown. Boosting theory has long studied the same failure in a different setting. A boosting algorithm builds a strong classifier by repeatedly training a "weak learner" on reweighted data. It works only while the weak learner keeps an edge, meaning it does measurably better than chance on whatever weighting of the examples it is handed. It breaks when the weights pile up on examples that cannot be fit, usually because they are mislabeled.
This note proposes treating each repair round as a weak learner and measuring its edge directly. In repair, "chance" is not a coin flip. The right reference point is drawing a fresh program from scratch at the same cost. We would estimate this edge on held-out tests for each problem while the loop runs, and use it for two things. The first is deciding, per problem, whether to keep refining, restart, or stop. The second is flagging surrogate tests the refiner persistently cannot satisfy without breaking others. These are the code analogue of mislabeled examples, and they are a likely source of test overfitting.
Core Claim
Our hypothesis is that three documented symptoms have one mechanism: edge collapse relative to fresh sampling, concentrated on a small set of tests that conflict with each other. The symptoms are the plateau after 3–4 turns (Conversational Automated Program Repair; CodeTransOcean), the rise in overfitting under refinement (Investigating Test Overfitting on SWE-bench), and structural erosion (SlopCodeBench).
We define the edge of refinement round $t$ as
$$\gamma_t = \Pr[\text{refine}(p_t, D_t) \text{ passes } V] - \Pr[\text{fresh sample passes } V],$$
where:
- $p_t$ is the current program;
- $D_t$ is the weighting over failing feedback tests that decides which failures the model is shown;
- $V$ is a held-out half of the available tests the model never sees;
- both probabilities are taken at equal token budget.
Refining is worth it only while $\gamma_t > 0$. This is the weak learning assumption rewritten with the correct baseline.
The claim has two parts. First, a cheap Monte Carlo estimate of $\gamma_t$ predicts when further rounds will stop helping, or will hurt on hidden tests, better than a fixed turn budget does. Second, tests that stay failing under every feedback weighting identify wrong or contradictory surrogate tests. This mirrors the split in The Rate of Convergence of Adaboost, where some examples can be driven to zero loss and the rest settle at a strictly positive loss the algorithm can only trade off. Down-weighting the flagged tests should reduce overfitting.
Relation to Prior Work
The closest work is PREFER. It runs AdaBoost over prompts for text classification, reweighting misclassified examples and asking an LLM to reflect on them. It then ensembles the prompts at inference time. We deliberately do not ensemble. A program is a single hypothesis, and executable behaviour does not add up across pieces; one wrong index breaks the whole program. Ensemble Methods for Structured Prediction shows this constraint concretely. Its guarantees require losses that decompose over parts, and ESPBoost still terminated early when its experts lost the edge.
We therefore borrow the diagnostic half of boosting, which is edge measurement and control of the weights, rather than its aggregation half. CodeLutra uses "boosting" only as a metaphor for iterative preference training on its own passing and failing samples. It has no mechanism for problems where no sample passes, and it trains weights, whereas we work at inference time.
Two papers constrain the design:
- Smooth boosting, as operationalized in Private Boosted Decision Trees via Smooth Re-Weighting, caps how much weight any single example may carry. We reuse that cap, $D_t(i) \le 1/(\kappa n)$, where $n$ is the number of feedback tests and $\kappa \in (0,1]$ sets how spread out the weights must stay. This keeps feedback from fixating on one pathological test.
- Limitations of refinement methods for weak to strong generalization proves that refining against a weak supervisor plateaus at an irreducible error. LLM-generated tests are exactly such a supervisor. Our response is not to claim the floor away. Instead we try to detect which supervision is the problem and route around it.
Research Program
The system wraps any refiner in an outer controller.
Test split. For each problem, the available tests (surrogate or visible) are split at random into a feedback half $F$ and a validation half $V$.
Feedback distribution. The controller keeps a distribution $D_t$ over failing tests in $F$. Each round it samples a small feedback set from $D_t$ for the prompt.
Weight update. $D_t$ is updated multiplicatively toward tests that stay failing, as AdaBoost does, and then projected back under the smoothness cap.
Edge estimate. Every round the controller draws $r$ refinements and $r$ fresh samples at matched cost and scores both against $V$. It then forms a confidence interval on $\gamma_t$.
Decision rule. The controller keeps refining while the lower confidence bound is positive. It restarts from a fresh sample when the upper bound is negative, and stops when the budget runs out.
Conflict score. Each test gets a score counting how often it fails under feedback weightings that concentrate on it, while flipping other tests from pass to fail when it is forced to pass. High-scoring tests are reported as suspected wrong specifications and receive capped weight.
The analysis has three parts:
- Measure how $\gamma_t$ evolves across rounds, models and benchmarks, to test whether the known 3–4 turn plateau is where $\gamma_t$ crosses zero.
- Check whether the conflict score recovers deliberately corrupted tests.
- Check whether smoothing delays the crossing.
Baselines
Naive reference points. The first is single-shot generation with no refinement. The second is best-of-N fresh sampling at the same total token budget as our controller, choosing the candidate that passes the most feedback tests. This matters because $\gamma_t$ is defined relative to fresh sampling. If best-of-N matches us, our measured edges were never meaningfully positive.
Strongest existing inference-time method. This is conversational refinement with a fixed turn budget, following Conversational Automated Program Repair, run at K=3. That setting is its reported sweet spot; it reports 28 of 30 QuixBugs Python bugs fixed within three turns. On translation, CodeTransOcean reports DSR@0 of 48.57% and DSR@3 of 52.57% for GPT-3.5-turbo on LLMTrans, where DSR@K is the share of programs that run and pass after K rounds of compiler feedback.
Overfitting-focused comparison. On SWE-bench Verified the comparison is the critic-guided refinement loop from Investigating Test Overfitting on SWE-bench. It rewards surrogate test status plus line coverage. That paper reports overfitting rising from 21.8% to 25.5% for Claude-3.7 Sonnet and from 33.0% to 35.9% for GPT-4o under refinement. Overfitting here means a patch passes the surrogate tests but fails the hidden gold tests.
Fairness. All methods use the same base model, the same surrogate tests, and the same token budget. Budget counts all forward passes, including our edge-estimation samples, which are charged to our method. Any hyperparameter search (K for fixed-turn methods; $\kappa$, $r$ and the confidence level for ours) uses one shared held-out problem set of equal size.
What counts as winning. Beating the baselines means two things at equal compute. On QuixBugs and LLMTrans, hidden-test pass rate must be higher than both best fixed-K refinement and best-of-N. On SWE-bench Verified, the overfitting rate must be lower than the unrefined baseline, not merely lower than the refined one, without losing resolved instances.
Ablations. The key ablations isolate each ingredient:
- validation-based stopping with uniform feedback weights (no reweighting);
- unsmoothed AdaBoost-style weights (reweighting without the cap);
- conflict flagging turned off.
Why not just…?
Why not just stop at three turns? The plateau is well documented, so a fixed small budget is a serious competitor. Our bet is that the crossing point varies per problem. Some problems fail at turn one and should be restarted immediately, and others keep improving longer. The experiment that settles this compares the oracle-best fixed K against adaptive stopping at matched average compute. If fixed K matches us, the edge estimate adds nothing for allocation, and the contribution reduces to conflict detection.
Why not just sample many fresh candidates and pick one? Best-of-N is the literal baseline in our edge definition, so this question is built into the method. Conversational Automated Program Repair reports that generate-and-validate needs more samples than conversational repair. Investigating Test Overfitting on SWE-bench shows that selecting by surrogate passage imports the overfitting problem, and best-of-N has no protection against wrong tests. If our controller mostly chooses "restart," the result is still informative: it would mean refinement rarely has edge.
Why not just hold out tests and early-stop, without any boosting machinery? This is the real threat. Our stopping rule is essentially validation early stopping with a matched-compute reference. The boosting-specific content is the smoothed feedback weighting and the conflict score. The uniform-weight ablation above measures exactly what they add. If it matches the full method on pass rate and overfitting, we will report that the weak learning lens contributes the right baseline for the edge, namely fresh sampling rather than zero, but not the reweighting.
Proposed Experiments
Mechanism check. On QuixBugs and CodeTransOcean LLMTrans, we plot estimated $\gamma_t$ against round, for open and API models. We then test whether the round at which $\gamma_t$'s upper bound turns negative predicts per-problem hidden-test regression. The measure is AUROC against the realized pass-to-fail flips on hidden tests.
Ground-truth corruption check. On CanItEdit, which ships hidden test suites, and on QuixBugs, we corrupt a known 10–20% of feedback tests by flipping their expected outputs. We measure precision and recall of the conflict score, and compare hidden pass rates under smoothed versus unsmoothed weighting. Recovering corrupted tests well above a random-flag baseline is necessary for the rest of the story.
Overfitting check. On SWE-bench Verified with generated surrogate tests, we report resolved rate and overfitting rate against the refinement loop of Investigating Test Overfitting on SWE-bench. The target is an overfitting rate below the 21.8% unrefined Claude-3.7 figure at equal resolution.
Secondary check. On SlopCodeBench, we test whether edge-gated restarts reduce the erosion and verbosity it measures. The prediction is that fewer rounds are spent in low-edge regimes, where rounds mainly accumulate patches.
Falsification. The core claim fails if $\gamma_t$ does not predict regressions better than turn count, or if corrupted tests go undetected.
References
- Conversational Automated Program Repair
- CodeTransOcean: A Comprehensive Multilingual Benchmark for Code Translation
- Investigating Test Overfitting on SWE-bench
- SlopCodeBench: Measuring Code Erosion Under Iterative Specification Refinement
- The Rate of Convergence of Adaboost
- PREFER: Prompt Ensemble Learning via Feedback-Reflect-Refine
- Ensemble Methods for Structured Prediction
- CodeLutra: Boosting LLM Code Generation via Preference-Guided Refinement
- Private Boosted Decision Trees via Smooth Re-Weighting
- Limitations of refinement methods for weak to strong generalization