Research11 min read

Solve Early, Stop Late: Why AI Coding Agents Keep Working Long After They Have Fixed the Bug

A new study tracked every patch AI coding agents wrote and found they often have the right fix early, then spend a third to more than half of a successful run on extra work, occasionally breaking the fix they already had.

Imagine hiring a builder to fix a leaking tap. They fix it in ten minutes, then spend the next forty minutes running every tap in the house, peering under the sink, rereading the manual and, once in a while, loosening the fitting they had just tightened. You pay for the full hour. Occasionally you get back a tap that leaks again.

A new study from Pennsylvania State University suggests that this is roughly how today's AI coding agents behave. The paper, "Termination Lag: Coding Agents Solve Early but Stop Late" by Musa Cim, Burak Topcu and Mahmut Taylan Kandemir, was posted to arXiv on 11 November 2026. It asks a simple question that the usual benchmarks never ask: not just whether an agent fixes a bug, but when it first fixes it, and what it does afterwards.

The answer is that agents often have the right fix surprisingly early, then keep going for a long time. In the authors' main settings, a median of 35 to 60 per cent of each successful run happens after the problem is already solved. This article walks through what the researchers measured, what they found, what the limits of the work are, and why it matters for anyone paying for, building or relying on AI agents.

The problem with judging only the final answer

Coding agents are AI systems that work inside a software project. Given a description of a bug or feature request, they read files, run commands and tests, edit code and finally submit a patch, which is the set of changes they made. The standard way to score them is a benchmark called SWE-bench, which checks whether the final submitted patch passes a set of hidden tests drawn from the real project.

The authors point out a blind spot in this. Two agents might both make the same correct edit at step 10. One submits straight away. The other carries on for 40 more steps, rerunning tests and reviewing its changes, before it stops. Both get exactly the same score, even though one used far more time and computing power. Worse, an agent can write a correct fix halfway through and then overwrite it, so a failed run can hide the fact that the agent did, at one point, solve the task.

Their argument is that a final score mixes up two separate skills: producing a correct fix, and recognising that the fix is finished. The second skill, knowing when to stop, has received much less attention.

How they measured it

The clever part of the study is how it watches agents without interfering with them. The researchers placed a logging proxy between the agent and the model it calls. After every agent step, the proxy saved a snapshot of the project's current changes compared with the starting point, using a temporary copy of Git's index so the agent's working files were not touched.

Once the runs were finished, every distinct snapshot was tested offline in isolated containers using the benchmark's official tests. The agent never saw these results, so the measurement could not change how it behaved. This let the team pinpoint the exact step at which each run first had a correct patch.

From that, they defined two measures:

  • Time to first correct patch (TTFCP): the step at which the project first passes the official tests.
  • Termination lag (TL): the number of steps the agent takes after that point before it stops on its own.

They also used a normalised version of termination lag, the share of the whole run that happens after the first correct patch, so that short and long runs can be compared fairly.

Which agents and tasks were tested

The study is broad for a single paper. The main agent framework was OpenHands, an open platform for software agents. To check whether the findings depended on that framework, the team repeated one setting using a second, simpler framework called mini-SWE-agent.

Five models were tested:

  • Two closed models accessed through their makers' APIs: Claude Haiku 5.5 and GPT-6 Luna, both on SWE-bench Verified with a budget of 100 steps.
  • Three open models run on the Aurora supercomputer at Argonne: Qwen3-Coder-30B-A3B, Laguna-XS.2 and Seed-OSS-36B.

Three benchmarks were used. SWE-bench Verified has 500 Python tasks. SWE-bench Multilingual has 300 tasks across nine programming languages. SWE-bench Pro has harder tasks that need longer stretches of work. The "core" results in the paper come from Qwen3-Coder and Laguna-XS.2 on Verified and Multilingual, with the other models and benchmarks used to check whether the pattern holds more widely.

Finding one: the first fix is often the right one

The first surprise is how often agents get it right first time. Among runs that ever reached a correct patch, the very first edit an agent made to the source code was already correct in:

  • 82 per cent of runs for Qwen3-Coder on SWE-bench Verified, and 66 per cent on Multilingual.
  • 70 per cent for Laguna-XS.2 on Verified, and 48 per cent on Multilingual.
  • 80 per cent for GPT-6 Luna on Verified.
  • 38 per cent for Seed-OSS on the harder SWE-bench Pro.

On average, agents produced between 1.3 and 3.6 distinct patches before reaching a correct one, counting the correct one itself. For Qwen3-Coder on Verified, the median step of the first edit and the median step of the first correct edit were the same: step 30. For GPT-6 Luna, both were step 9.

In other words, much of an agent's real thinking happens before it touches the code. It reads, searches and reasons, then makes an edit that is frequently correct. The harder benchmark, SWE-bench Pro, is the exception that proves the point: on tougher tasks, first attempts succeed less often and more revision is needed.

Finding two: then they keep going

The core of the paper is what happens next. For Qwen3-Coder on SWE-bench Verified, among solved tasks, the median termination lag was 16 steps, and the median share of the run spent after the fix was 35 per cent. On Multilingual it was 18 steps and 37 per cent.

Laguna-XS.2 was far more drawn out. On Verified, its median termination lag was 57 steps, or 60 per cent of the run. On Multilingual it was 56 steps, or 54 per cent. Put plainly, more than half of a typical successful Laguna-XS.2 run happened after it had already solved the problem.

The commercial models showed the same pattern. Claude Haiku 5.5 on Verified reached its first correct patch at a median of step 9, then carried on for a median of 10 more steps, meaning 54 per cent of its run came after the fix. GPT-6 Luna had a median lag of 6 steps, or 36 per cent of the run. Seed-OSS on SWE-bench Pro showed the same shape, and switching to mini-SWE-agent for Qwen3-Coder gave a median lag of 12 steps and 37 per cent.

Those extra steps are not free. Each one is another call to the model, carrying an ever longer history. The paper reports that from the first correct patch to the final step, the amount of input context the model was handling grew by a median of 30 per cent for Qwen3-Coder on Verified and 78 per cent for Laguna-XS.2 on Verified. The authors are careful to note that they measure steps, which approximate cost rather than measuring it directly, but the direction is obvious: more steps over bigger contexts means more tokens, more waiting and more compute.

To show the size of the opportunity, the researchers imagine an "oracle" that stops each run at the exact moment of its first correct patch, leaving unsolved runs alone. Among solved runs, this would remove a median of 35 and 37 per cent of steps for Qwen3-Coder on Verified and Multilingual, 60 and 54 per cent for Laguna-XS.2, and 54 per cent for Claude Haiku 5.5 on Verified, without losing a single originally solved task. No real system can be a perfect oracle, because the agent cannot see the hidden tests. But the figures set an upper bound on how much smarter stopping could save.

Finding three: most of the extra work is checking

What are agents actually doing in all those extra steps? The team sorted every post-fix step by the tool it used.

  • Verification, meaning running existing tests, writing and running new test scripts and building the project, was the biggest category everywhere, at 48 to 63 per cent of post-fix steps.
  • Exploration, meaning opening files, searching the codebase and reviewing changes with Git, took another 15 to 29 per cent.
  • Further source edits were rare for most models, at 2 to 6 per cent, though Seed-OSS on SWE-bench Pro edited much more, at 19 per cent.
  • The rest was wrap-up, such as deleting temporary files and submitting, plus reasoning and other actions.

This is an important nuance. The agents are not wandering aimlessly. They are mostly doing what a careful human developer would do: checking their work. The paper acknowledges that some checking is necessary, because the agent cannot see the official tests and has to rely on its own evidence. The problem is that they do a lot of it, and they are not good at deciding when they have checked enough.

Finding four: sometimes the checking breaks the fix

The final question is whether all this extra work helps or hurts. Once a patch passes the official tests, more work cannot make it more correct by the benchmark's standard. It can only keep it correct or break it.

Most of the time, the fix survives. Across settings, 61 to 96 per cent of runs that reached a correct patch kept it to the end. But a meaningful share of runs broke their own fix and then had to repair it: 11 per cent of Laguna-XS.2 runs on Verified, 31 per cent on Multilingual, and 17 per cent of Seed-OSS runs on Pro.

And in 1 to 8 per cent of runs, depending on the setting, the agent broke a correct fix and never recovered, submitting a wrong answer. In each of those cases, stopping at the first correct patch would have turned a failure into a success. The paper notes that earlier work by Kim and colleagues, describing a "coherence collapse" in coding agents, found that a correct mid-run fix can be lost to later edits. This study puts numbers on how often that happens across several models.

A related finding about training agents

The termination lag paper is not alone in suggesting that headline success rates hide important behaviour. A separate November 2026 arXiv paper, "What Does Multi-Turn Reinforcement Learning Really Improve in LLM Agents?" (arXiv 2611.06483), looked at agents trained with reinforcement learning over many turns. Its authors report that, given the same situation, the trained models did not consistently pick better next actions than the base models; the trained model made the better step-level decision in only 46.8 per cent of matched states on one task and 42.8 per cent on another. Their advantage showed up mainly in recovering from errors and in the later stages of long runs.

That paper also found that the benefit depended heavily on how many steps the agent was allowed, and proposed a training method called BudgetMix, which varies the step budget during training. The authors report gains of 7.5, 5.3 and 4.0 percentage points over standard training at 25, 50 and 75 per cent of the full budget, with no loss at the full budget. Taken together with the termination lag study, the message is consistent: how many steps an agent takes, and how it uses them, is a property worth measuring and training for in its own right, not just a side effect.

Limitations worth keeping in mind

The authors are open about the study's limits, and they matter when interpreting the numbers.

  • Each task was run once per setting, so there is no measure of how much results vary between repeated runs.
  • The study covers three benchmarks, five models and two frameworks. Results may not carry over to other models, other frameworks or real-world projects that look different from SWE-bench.
  • Steps approximate cost but are not a direct measure of money or energy.
  • Post-fix steps were classified by rules based on which tools were called, which is a reasonable but imperfect proxy for intent.
  • Seed-OSS on SWE-bench Pro solved few tasks, so its statistics rest on a small sample.
  • A "correct" patch here means one that passes the benchmark's tests. Real software quality involves more than that, and some of the agents' extra checking may catch issues the benchmark tests do not.

That last point deserves emphasis. It would be wrong to read this paper as saying agents should simply stop after their first edit. The study shows that a large share of post-fix work is wasted by the benchmark's measure, and that a small share is actively harmful. It does not show that all extra checking is useless in practice.

Why this matters

For people building agents, the takeaway is that stopping is a skill, and it can be measured. The paper frames termination lag as a reference point for any practical stopping rule: it shows the most that perfect stopping could save, and the runs that broke their own fix show what carrying on can cost. Better stopping could come from training, from smarter prompts, or from a separate monitor that judges when the evidence is strong enough to submit. The authors' related work section notes several efforts along these lines, from predicting success or failure partway through a run to capping turns and cost.

For people paying for agents, the implication is more direct. If a third to more than half of a typical successful run happens after the job is already done, a meaningful part of the bill is for reassurance rather than progress. That is not automatically bad, since reassurance has value, but it is worth knowing. Simple habits can help: setting sensible step or cost limits, asking agents to report as soon as tests pass, and reviewing the diff yourself rather than letting the agent review it many times over.

For people judging agents, including anyone reading leaderboard results, the paper is a reminder that a single success rate compresses a lot of behaviour. Two agents with the same score can differ greatly in speed, cost and the risk of undoing their own good work. The authors argue that agent evaluation should look at when correctness is reached and whether it is kept until the end, not just at the final answer.

Back to the builder and the tap. Nobody wants a builder who leaves without checking. But nobody wants to pay for forty minutes of checking either, especially if, once in a while, the checking is what causes the leak. The next generation of coding agents will be judged not only on whether they can fix the problem, but on whether they know when they have.

Sources

  1. arXiv: Termination Lag: Coding Agents Solve Early but Stop Late (Cim, Topcu, Kandemir, 2026)arxiv.org
  2. arXiv: What Does Multi-Turn Reinforcement Learning Really Improve in LLM Agents?arxiv.org