groundy
agents & frameworks

How Far Ahead Can a Coding Agent Plan? The Horizon Bottleneck

A July 2026 preprint says coding agents plan edits roughly 25 steps ahead before their latent program model collapses, so context length and pass@k may mismeasure failures.

8 min···3 sources ↓

A July 2026 preprint puts a number on how far ahead a coding agent can “see” the program it is building: roughly 25 steps, after which the model’s internal representation of whether its edits will succeed collapses toward chance. Latent Programming Horizons in Coding Agents names that ceiling the “latent programming horizon” and argues it is the quantity worth watching. If the horizon is the binding constraint on agentic coding, the context-window arms race and the pass@k benchmarks vendors quote are aimed at the wrong target.

How the latent programming horizon was measured

The authors fit logistic-regression probes on the residual streams of the language models running inside coding agents and showed those hidden states linearly encode properties of the evolving program: whether the current code parses, whether it passes its test suite, whether an edit reduces the failing-test count, and whether it introduces regressions. Correctness reached AUC up to 0.83 across two models and two benchmarks (arXiv:2607.05188).

A residual stream is the model’s running scratch space between layers; a linear probe is the cheapest possible readout, a logistic regression asking whether a given property is present in those activations. That a straight line through the hidden states recovers program correctness means the model tracks the program’s state internally, not just token by token.

The second finding is the headline. Probes trained to predict the outcome of edits that have not yet been written stayed above chance up to roughly 25 steps in advance. The model appears to carry a forward model of the program’s trajectory before committing edits to disk, and that forward-looking reach is what the authors call the latent programming horizon.

There is a generalizability check built in. The probes transfer across benchmarks without retraining, so a probe trained on one task suite still decodes program properties on a different one (arXiv:2607.05188). That is the paper’s external-validity argument: the latent representations appear to capture something general about program structure rather than memorizing the quirks of a single benchmark.

Two caveats the paper itself invites. “Above chance up to roughly 25 steps” describes the upper bound where a statistical signal is still detectable, not a clean 25-step working window; the probe’s accuracy almost certainly decays continuously across that range. And a probe that can predict an outcome is not the same as an agent that acts on that prediction. The representation may be present without the agent using it to choose better edits.

Why token budgets and pass@k miss the point

The metrics the market optimizes, context length and isolated-file accuracy, describe capacity and locality. Neither measures how many intermediate edits an agent can hold together as a coherent plan.

Context windows have grown by orders of magnitude, and vendors market coding agents on that growth; Anthropic lists Claude Code among the features of its Pro and Max plans (claude.com). A longer window holds more tokens. The horizon frame says that holding more tokens does not extend the distance over which the model’s internal plan stays valid. You can fit the whole repository into context and still watch the structure fall apart at step 18, because the bottleneck is how far ahead the activations cohere, not how much input they can ingest.

pass@k has the same blind spot from the other direction. It samples k completions and asks whether any one passes, treating each attempt as independent and each task as a single file. A latent horizon is a sequential, dependent property: the value of the next edit depends on the one before it. A metric built around independent single-shot attempts cannot see how long a dependency chain an agent can sustain.

What the multi-file refactor failure looks like through horizons

A refactor that touches ten files along a dependency chain is itself a sequential program: each edit changes what the next edit has to do. If the agent’s internal representation of correctness only stays coherent for roughly 25 steps, then any chain longer than that is being written without a valid forward model.

An agent step here is one reasoning-edit-test cycle, the unit that compounds over a real refactor. Twenty-five of those is not a lot. A migration that renames a symbol across a dozen call sites, updates the tests, and re-runs the suite can blow through it.

That matches the lived experience of anyone who has watched an agent complete the first four files cleanly and then emit something incoherent on the fifth. The horizon frame recasts that from a context bug into a planning-depth ceiling. Adding the missing file to context does not help if the problem is that the model can no longer hold the chain in working shape.

A second July 2026 benchmark points at the same wall from a different angle. PolyWorkBench, 67 tasks across five domains, reports that state-of-the-art agents suffer significant performance degradation in long-horizon workflows and that the degradation compounds across reasoning and execution steps. PolyWorkBench studies multilingual workflows, not planning horizons, so it is corroboration of the symptom rather than direct evidence for the mechanism. But “compounding across steps” is exactly the failure signature you would expect if each step past the horizon adds independent error.

Would a bigger context window fix it?

Probably not, and the reason is structural rather than empirical. Context length is an input-side quantity; the latent horizon is a property of how the model’s activations evolve over a sequence of its own actions. Nothing in the probe results suggests the two axes are coupled.

That claim is this article’s inference, not a result the paper demonstrates. The preprint measures the horizon; it does not run the controlled experiment of holding model size fixed and scaling context to see whether the horizon moves. The horizon frame predicts that context length will buy little on long refactors, and the prediction is testable, but this work has not tested it. Anyone quoting the paper as proof that bigger contexts are useless is reading past what was shown.

What a horizon-aware evaluation would look like

A horizon-aware eval scores agents on the length and dependency depth of the edit chains they complete, rather than on whether any of k samples fixes one isolated file. pass@k yields a probability over independent attempts. A horizon metric is sequential: how long a chain holds before the agent’s predictions of its own future edits decay to chance.

The probe methodology could become the instrument. Fit a probe, step it forward, record where its AUC crosses chance, and read the horizon off the curve. That turns an interpretability result into a benchmark signal and gives buyers a number that tracks the failure mode they actually hit in production, instead of the one that is easy to score. The authors frame their work as a call for more mechanistic interpretability of coding agents (arXiv:2607.05188), which is researcher-speak for “this is early.”

Why this makes agent evaluation harder

The horizon finding does not simplify benchmarking. It adds a dimension the leaderboards do not track, and it means a model can score well on SWE-bench while carrying a short latent horizon on exactly the tasks that break in production.

The practical effect widens the eval gap rather than closing it. Buyers cannot yet compare vendors on horizon because nobody ships a probe-based measurement, and the methodology is research-stage. So they default to the metrics that do exist, context length and pass@k, even though the horizon frame says those metrics are misaligned with the failure modes that matter. The numbers get better every release; the refactors keep failing for the same reasons.

This paper makes planning depth a plausible binding constraint. It does not yet prove it. Until someone runs the experiment that scales context against horizon, or ships a probe-based leaderboard, the claim is a well-grounded hypothesis with a clean measurement behind it. Treat the 25-step figure as a first estimate of how far an agent can plan, not as a settled answer.

Frequently Asked Questions

Do the 25-step findings generalize beyond the models and benchmarks in the paper?

The probes transfer across benchmarks, which suggests the representations are general, but the paper tested only two model families on two coding benchmarks. The 25-step figure is an estimate for those specific models, not a universal constant for Claude Code, GPT-4, or agents trained with different architectures. Buyers should treat it as a proof of concept that horizon exists and can be measured, rather than as a spec sheet number that applies to every product.

What is the relationship between the two July 2026 papers?

The horizon paper appeared on arXiv on July 6, 2026, and PolyWorkBench followed on July 7. PolyWorkBench’s 67 tasks span five domains and focus on multilingual long-horizon workflows, not internal representations. Its finding that errors compound across reasoning and execution steps is consistent with the horizon model, but it is corroboration of the symptom, not direct evidence for the mechanism.

How should teams change their internal evaluation of coding agents?

Teams should stop treating context-window size as a proxy for long-horizon capability and start scoring agents on their own multi-file refactor chains, recording where correctness drops as dependency depth grows. Until vendors publish probe-based horizon numbers, the cheapest operational signal is to classify production failures by whether they occur after a long edit sequence, then compare that distribution across tools.

Could the probe AUC be high while the agent still performs badly?

Yes. The probe only shows that program properties are linearly decodable from residual activations; it does not show that the agent’s action-selection policy uses those properties. A model can internally represent that an edit will break a test while still committing it, in the same way a chess player can see a losing move and play it anyway. The gap between representation and action is the main reason the horizon is an upper bound, not a guarantee.

What would prove or disprove the claim that planning depth, not context length, is the binding constraint?

A controlled experiment that fixes model size and training data while varying only context length, then remeasures the latent horizon. If the horizon stays near 25 steps while context grows, context length is not the limiting factor. If it stretches, the bottleneck is input capacity. The original paper did not run that experiment, so the structural distinction between input-side capacity and activation-side planning remains a testable inference.

sources · 3 cited

  1. Latent Programming Horizons in Coding Agentsarxiv.orgprimaryaccessed 2026-07-08
  2. Claudeclaude.comvendoraccessed 2026-07-08