Coding Agents Predict Their Own Future Edits 25 Steps in Advance, New Paper Finds
A paper published July 6 on arXiv (2607.05188) opens a window into what a coding agent actually knows about the code it is working on — and the answer is more than its own outputs suggest.
The study, “Latent Programming Horizons in Coding Agents,” trains logistic-regression probes on the hidden states of language models running inside coding agent loops. The finding: residual streams linearly encode properties of the evolving codebase in real time. Probes trained on those representations can decode whether the current code parses, whether it passes its test suite, whether the most recent edit reduces the number of failing tests, and whether it introduces regressions. AUC reaches 0.83 for correctness prediction across two models and two benchmarks.
That result is noteworthy but not shocking — language models are known to track program state internally. What the researchers describe as the surprising finding is something different.
The Latent Programming Horizon
Probes trained to predict the outcome of future edits, before those edits are written to disk, perform above chance up to roughly 25 steps in advance. The model, in other words, internally represents where the program is going before it takes the steps that get it there.
The researchers call this the agent’s latent programming horizon. A 25-step horizon in an agent solving software engineering tasks translates to a non-trivial lookahead — typical SWE-bench Verified trajectories span 60–100 steps, so the model appears to carry partial knowledge of near-future program states for roughly a quarter of a full task.
The practical interpretation is careful: probe accuracy above chance is not the same as full predictive foresight. The representation is probabilistic and becomes noisier at greater horizons. But the direction is clear — the model is not operating one step at a time with no internal plan. It carries latent structure about where the edit sequence is headed.
Transferability
A third result bears on how these probes scale as interpretability tools. Probes trained on one benchmark transfer to a second benchmark without retraining and retain meaningful performance. If probes required retraining per-task or per-distribution, they would be analytically interesting but practically inert. Transferability makes them a candidate for monitoring tools embedded in production agent loops.
Why This Matters for Agent Safety
The finding sits at the intersection of mechanistic interpretability and agent deployment. Current agent safety monitoring largely tracks outputs — what the agent writes, what tools it calls. This paper proposes that the agent’s internal state carries earlier signals than its outputs: the program-correctness probe fires before the incorrect edit lands on disk.
The researchers frame this as a call for more research rather than a production recommendation. The results were produced on two models and two benchmarks. Probe reliability across the full diversity of agent tasks and architectures is an open question.
The implication for agent infrastructure is that residual stream monitoring is technically feasible as a pre-output intervention layer. Whether it is reliable enough to act on remains to be established.
Context
The paper tests on mini-SWE-agent trajectories, a well-established coding agent harness. Two models are evaluated but not named in the abstract; the full results are in the PDF. The authors are affiliated with academic institutions; the paper is submitted to cs.LG and cs.SE.
At the frontier, coding agents now handle trajectories hundreds of steps long on production codebases. A mechanism that predicts edit outcomes 25 steps in advance — even imperfectly — is the kind of internal structure that can be exploited for debugging, steering, and safety monitoring. The latent programming horizon is a concrete enough result that it will draw follow-on work.