Latent Programming Horizons in Coding Agents

2026-07-07

Authors: André Silva, Han Tu, Martin Monperrus

ArXiv: 2607.05188v1

PDF: Download PDF

When a coding agent like Claude Code or Cursor works on a bug, it spends dozens of steps reading files, editing code, and running tests. From the outside, it looks like the agent is "thinking" about the program. But is it actually building an internal mental model of the code — or just pattern-matching its way from one edit to the next? This paper cracks open the black box and finds a surprisingly rich answer.

The authors trained a very simple statistical tool (a logistic regression probe) on the internal activations — the "residual streams" — of the language model powering a coding agent. Think of the residual stream as the neural network's working scratchpad: a big vector of numbers that flows through the model as it processes tokens. The probe's job was to look at this scratchpad and predict things about the code the agent was editing.

Here's what they found the model quietly keeps track of, without ever being told to:

That last finding is the eye-opener. The model isn't just reacting to feedback like compiler errors; it's internally representing something like "if I do this, things will get better." The paper calls this a latent programming horizon — a hidden look-ahead about where the program is going.

Why does this matter beyond curiosity? Two practical reasons:

The bigger picture: coding agents are often described as "just" LLMs bolted to tools. This paper is evidence that when you put a model inside an agentic loop, it develops implicit representations of program state that mirror how a human programmer holds the code in their head. That has implications for how we evaluate, interpret, and eventually control these systems.

Why it matters: It shows coding agents don't just react step-by-step — they build hidden internal models of program state that predict future outcomes, opening the door to interpretable and more efficient agent design.

All newsletters