Anyone who has reviewed a coding agent's pull request knows the pattern of a small bug and a large diff. Earlier research found successful agent patches run to about twice the size of the human fix, and "agents over-edit" has become received wisdom. A team at Microsoft set out to check what that extra material actually is.
They took 7,660 successful runs of GitHub Copilot's command-line agent, driven by frontier models from four providers on two public sets of real repository tasks. For each final patch they removed one block of changes at a time and reran the task's tests. A block the tests didn't miss counted as unneeded. They graded the original human fixes the same way, which matters, because by that measure a fair amount of human-written code also looks unneeded.
By size alone, the agents' patches really were bloated, changing more than twice as many lines as the developers did. But on the main benchmark, 61% of the extra lines were tests the agent had added, and much of the rest was documentation. Counting only the code, most models left no more unneeded code than the human developers. A few left noticeably more.
"So agents produce more non-test changes, but most of the code they write is needed."
That doesn't make the leftovers harmless. On average, 11% of the code blocks in an agent's patch weren't needed to pass the tests. When the researchers wrote small probe programs to exercise that code directly, 89% of it changed how the program behaved, such as raising or swallowing an error on nearby inputs. Some of those changes matched what the human developer had done in places the tests didn't check. Others were behaviour nobody had asked for.
Nor was the excess what reviewers usually blame. Leftover debugging scaffolding almost never made it into the final patch; the unneeded code was written as part of the fix itself.
"Scratch scripts and debug prints almost never survive into resolved patches."
How much unneeded code a model wrote bore no relation to how many tasks it solved. On the harder, longer benchmark the models that solved more tasks tended to leave more of it.
Two clean-up approaches were tested after the fact. Asking the agent to justify each part of its own diff and drop the rest was cautious but caught only about a third of the unneeded code. Removing blocks automatically while the agent's own tests still passed caught about two thirds, but also cut code that was needed, and roughly one patch in ten stopped working.
An engineering leader can use the tests-versus-code split straight away. A team judging agents by diff size or lines changed is, on these numbers, mostly measuring how many tests each one writes, which counts in the agent's favour if those tests are any good, and the researchers found they did catch a useful share of deliberately planted bugs. A dashboard that counts lines would penalise exactly that.
The 11% is harder to deal with. Because the unneeded code is written into the fix rather than left behind by debugging, a reviewer can't spot it by looking for stray print statements. And because most of it changes behaviour, it can't be waved through as cosmetic. On this evidence, the riskiest lines in an agent's patch are the plausible-looking extras inside the fix: an added guard, a broadened exception, a second code path. Those deserve the question "which test needs this?" more than the obvious leftovers do.
The differences between models leave any leaderboard score incomplete. If two agents solve the same share of tasks and one leaves several times as much untested behaviour behind, the headline number hides the difference that reviewers will actually pay for. A team comparing tools would do better to sample merged agent patches and ask, block by block, what each change was for.
The paper lists its own limits. Every verdict depends on how good each task's tests are, the probe programs were written by an AI model, and only successful runs in one agent harness were studied. What it could not establish is the question a reviewer cares about most, which is whether a human would have removed the code it flagged. The authors prepared a human labelling exercise to check that and left it for future work, so for now "unneeded" means "the tests didn't miss it", not "a maintainer would reject it".
Sources
- Goel, A., Steenhoek, B., Hu, Y., "How Much Do Coding Agents Over-Edit, and Why? An Empirical Study of Unneeded Edits in Repository-Level Agent Patches" — https://arxiv.org/abs/2611.34875
