Coding agents that keep editing the same program as requirements evolve tend to leave behind code that passes today's tests but is harder to change tomorrow. They copy logic instead of factoring it out, and they pile complexity into functions that are already too complex. The usual fix is to put an evaluator in the loop, often an LLM asked to "rate maintainability." That evaluator is exactly what an optimizing loop learns to fool. LLM judges reward verbosity and confident presentation, and they hide the shortcuts they rely on. We propose to replace the opinion with a measurement. Before committing an edit, the agent drafts a few plausible future requirement changes, tries to implement each one on top of every candidate version of the code, and keeps the candidate whose simulated futures were cheapest and least likely to break tests. This is model predictive control (MPC), the control strategy that plans a few steps ahead with a predictive model, executes only the first step, then replans when new information arrives. Here it is applied to software evolution: the "model" is an LLM forecaster of upcoming specifications, and the "cost" is measured on executed code rather than asserted by a judge.
The question matters because the two existing ingredients point in opposite directions. Test-Time Alignment for Large Language Models via Textual Model Predictive Control (TMPC) shows that receding-horizon search over text segments beats preference optimization at test time (61% vs. 48% on MBPP). It treats its reward model as ground truth, and its own limitations section warns that it will amplify any blind spots that reward model has. Meanwhile SlopCodeBench finds structural erosion rising in 77% of agent trajectories and verbosity in 75.5%, with quality-aware prompting unable to stop it. The open problem is how to plan across checkpoints without handing the planner a biased objective to exploit.
Core Claim
Our central claim is that a lookahead planner over future specification changes should be scored by consequences, not by a judge's verdict. Consequences here means test failures, edit size and erosion metrics measured after actually implementing forecasted changes. We expect a consequence-scored planner to reduce erosion and improve completion on later, unseen checkpoints. We also expect the same planner scored by an LLM maintainability judge to show bias amplification: the stronger the search, the further the judge's score rises above the true downstream quality.
Concretely, at checkpoint $t$ the agent produces $K$ candidate implementations $c_1,\dots,c_K$ that pass the current tests. A forecaster proposes $M$ plausible next specifications $\hat s_1,\dots,\hat s_M$ using only the current and past specifications. The agent implements each $\hat s_m$ on top of each $c_k$ with a fixed small budget. The candidate committed is
$$ c^\star = \arg\min_k \frac{1}{M}\sum_{m=1}^{M}\Big[\,F(c_k,\hat s_m) + \lambda\,\Delta E(c_k,\hat s_m) + \mu\,D(c_k,\hat s_m)\Big], $$
where $F$ is the fraction of the agent's own generated tests for $\hat s_m$ that fail after the simulated edit, $\Delta E$ is the increase in the structural-erosion and verbosity metrics defined by SlopCodeBench, and $D$ is the number of changed lines. The weights $\lambda,\mu$ are tuned on held-out problems. The simulated futures are thrown away, only $c^\star$ is kept, and the process repeats when the real next specification arrives. That last step is the receding-horizon part.
Bias amplification is measured as the gap between proxy gain and true gain under increasing search width $K$. The proxy gain is the improvement in the planner's internal score. The true gain is the improvement in completion and erosion on the real next checkpoint, which the planner never sees. The reasoning is the standard selection argument: if a proxy equals true quality plus a correlated error, then picking the argmax of more candidates increasingly selects for the error. So a biased judge's gap should grow with $K$, while a measured cost's gap should stay flat.
Relation to Prior Work
TMPC supplies the method: receding-horizon search with segment-level subgoals and no retraining. We differ in three ways. Our horizon spans specification checkpoints rather than segments of one response. Our predictive model forecasts the environment (future requirements) rather than continuing the policy's own text. And our cost is measured rather than judged.
SlopCodeBench motivates the work and supplies the benchmark and erosion metrics. It is purely diagnostic. Rollback guardrails (Fang et al.) and Adversarial Review are greedy, single-checkpoint defenses. The latter reports over-editing as an unresolved failure, and our edit-size term $D$ penalizes it directly.
The judge-bias literature constrains our design. The Silent Judge shows that verdicts shift by up to 30% on metadata cues while judges acknowledge those cues 0% of the time, so judges cannot be audited through their explanations. Local Coherence or Global Validity? shows that locally polished traces can hide global invalidity, and that GPT-4o catches only 57.8% of tagged errors. Self-Preference Bias in LLM-as-a-Judge is especially relevant because the judge here would grade its own family's code.
Two papers improve judges themselves: MCTS-Judge does so with search and simulated execution, and Trust or Escalate does so with calibrated abstention. Both evaluate single static artifacts and never close the loop into an editor. We use them as the strongest judge-side competitors rather than as components.
Finally, the analogy to residual-model correction in robotics (Optimizing Control-Friendly Trajectories with Self-Supervised Residual Learning) gives a principled way to repair a poor forecaster. After each real checkpoint, the forecaster is conditioned on its past forecast errors.
Research Program
We will build three pieces on SlopCodeBench's 36 problems and 196 checkpoints.
The first is the forecaster, a prompted LLM that sees past and current specifications and emits $M$ diverse candidate next specifications. It is strictly blind to real future checkpoints, which are kept in a separate process and audited for leakage.
The second is the lookahead executor. It implements forecasted changes in a sandbox, generates its own tests for each forecast, and computes $F$, $\Delta E$ and $D$.
The third is a bias probe for code-quality judges, modeled on The Silent Judge but using code-native cues. We take pairs of functionally identical code and swap cosmetic features: comments claiming "refactored for maintainability," inflated docstrings, the model-family of the author, and "reviewed by senior engineer" tags. We then measure how often the verdict shifts. This tells us in advance which cues an LLM-judged planner could exploit, and lets us check after the fact whether search pressure drove the agent's code toward those cues.
The analysis then has three parts. We trace the proxy-vs-true gap as $K$ grows for each scoring signal. We measure forecast quality as the semantic overlap between forecasts and the real next spec, and how it relates to downstream gains. And we check whether the benefit concentrates on problems whose real future changes were forecastable.
Baselines
The naive reference is a single agent that implements each checkpoint once. The best agents in SlopCodeBench complete 14.8% of checkpoints end to end, the number to beat on completion, alongside the reported erosion and verbosity rates. We rerun this agent with our base model so that every comparison is paired.
The quality-prompting baseline adds SlopCodeBench's quality-aware instructions. It tests whether asking the model to write maintainable code accounts for any gains.
The strongest existing method is TMPC adapted to multi-checkpoint coding. It uses the same receding-horizon search and the same $K$, but scores candidates with an LLM maintainability judge plus current unit tests, as TMPC would. TMPC reports 61% on MBPP versus 48% for test-time preference optimization and 34% for the base model. There is no reported result on Lacuna for TMPC on SlopCodeBench, so we run it ourselves. Beating it means higher completion on the real next checkpoint and lower erosion at matched tokens, with non-overlapping paired bootstrap intervals across problems and seeds.
The greedy-metric baseline is a serious threat. It picks among $K$ candidates by current-code erosion metrics and edit size, with rollback on test regression in the style of Fang et al., and uses no lookahead.
Best-of-N under a stronger judge pairs Best-of-N with MCTS-Judge-style deliberate evaluation, or with a Trust-or-Escalate cascade that escalates uncertain comparisons. This tests whether a better judge closes the gap. For reference, MCTS-Judge reports 80.0% accuracy on APPS versus 41.0% for its base model, and Adversarial Review reports 87% on LiveCodeBench. Neither has a reported number on SlopCodeBench.
The key ablation keeps our lookahead identical but swaps the measured cost for an LLM judge's rating of each simulated future. A second ablation gives the planner the real next specification as an oracle forecast, which bounds what better forecasting could buy. A third replaces forecasts with random, irrelevant specifications, which tests whether gains come from forecasting or merely from extra exercise of the code.
All methods get the same base model, the same per-checkpoint token budget (Best-of-N and greedy baselines spend the lookahead's tokens on more candidates), the same sandbox, and the same hyperparameter-tuning budget on a held-out split of problems.
Why not just…?
Why not just score candidates with deterministic erosion metrics and roll back on regressions? This is the most likely competitor, because the erosion metrics are cheap and cannot be flattered by style. Its weakness is that it judges code as it stands. Code that is compact now may be rigid later: a hard-coded branch is less complex than an extension point until the next requirement arrives. The greedy-metric baseline is designed to settle this. If it matches the lookahead planner at equal tokens, we will report that lookahead adds nothing beyond metrics, and the contribution narrows to the bias-amplification analysis.
Why not just use a better judge? MCTS-Judge and Trust or Escalate do make single verdicts more accurate. However, both are validated on static correctness or pairwise text preference, and The Silent Judge's 0% cue-acknowledgment result means residual biases cannot be detected from the judge's own explanations. The proxy-vs-true gap curve is the test. If an MCTS-style judge's gap stays flat as $K$ grows, the bias concern is overstated for code, and we will say so.
Why not just sample more candidates and pick the best? TMPC's own comparison favors structured search over flat sampling. More directly, our design spends the lookahead's tokens on additional Best-of-N candidates. If wider sampling under current tests and metrics matches lookahead, forecasting is not earning its cost.
Why not just prompt for maintainability? SlopCodeBench already reports that quality-aware prompting does not stop erosion from accumulating across checkpoints. We include it only to confirm that result under our model.
Proposed Experiments
The decisive experiment is the full paired comparison on SlopCodeBench, using held-out real future checkpoints as ground truth. We report checkpoint completion, the change in structural erosion and verbosity per checkpoint, and lines changed, all at matched tokens. Because the benchmark is small, we run five seeds per problem and use paired tests at the problem level.
The second experiment is the bias-amplification sweep. With $K \in \{2,4,8,16\}$, we plot proxy gain against true gain for the LLM-judge planner and the measured-cost planner. Alongside it, we track the code-native bias probe: does the share of cosmetic cues in committed code rise with $K$ under judge scoring?
The third experiment is the forecasting ablation, comparing oracle, LLM-forecast and random-forecast planners. It separates "planning against the future" from "stress-testing the code."
Three findings would each be informative: the consequence-scored planner beating the greedy-metric baseline, the judge-scored planner showing a gap that grows with search width, and real-forecast gains sitting well above random-forecast gains. If none of these appear, the evidence would argue against lookahead planning for code evolution at current model strength.
References
- Test-Time Alignment for Large Language Models via Textual Model Predictive Control
- SlopCodeBench: Measuring Code Erosion Under Iterative Specification Refinement
- MEIC: Re-thinking RTL Debug Automation using LLMs
- Adversarial Review: Structured Disagreement for Grounded Agentic Code Review
- The Silent Judge: Unacknowledged Shortcut Bias in LLM-as-a-Judge
- Local Coherence or Global Validity? Investigating RLVR Traces in Math Domains
- Self-Preference Bias in LLM-as-a-Judge
- MCTS-Judge: Test-Time Scaling in LLM-as-a-Judge for Code Correctness Evaluation
- Trust or Escalate: LLM Judges with Provable Guarantees for Human Agreement
- Optimizing Control-Friendly Trajectories with Self-Supervised Residual Learning