About 11% of the code that AI coding agents write in a successful bug fix isn't needed for the fix, according to a Microsoft study posted to arXiv on Wednesday, Nov. 25. The researchers say that's no worse than human developers on the same tasks, and that most of the extra size in agent patches comes from tests.
Aakash Goel and Benjamin Steenhoek led the preprint with co-author Yu Hu, and all list Microsoft as their employer. It hasn't been peer reviewed. The paper says the team studied 7,660 resolved runs of GitHub Copilot CLI, Microsoft's command-line coding agent, across 18 models from four providers.
How they measured it
A patch is the set of code changes an agent submits to fix an issue. Agent patches are known to be larger than developers', which is often read as "over-editing."
The authors built a method they call Delta Residue Attribution. It replays each agent run, splits the final patch into small blocks it calls units, then removes each unit one at a time and reruns the task's tests. If the tests still pass without a unit, that unit counts as unneeded.
The runs came from two benchmarks, according to the paper. SWE-bench Verified supplied 6,728 runs on 500 Python tasks, and DeepSWE supplied 932 runs on 113 longer tasks in several languages.
Bigger patches, mostly tests
On SWE-bench Verified, 61% of the extra edits agents made beyond the developer's fix were tests and 13% were documentation, the paper says. On DeepSWE, most of the extra edits were code, at 58%.
The tests weren't wasted. The agents' own tests caught 68% of deliberately injected bugs, against 77% for the benchmark's task tests, according to the study.
Agents compared with people
The authors graded the original developer fixes with the same method. On SWE-bench Verified, the study reports, the average share of needed code was 0.887 for agents and 0.864 for developers, and 11 of the 18 models left less unneeded code than the humans did. On DeepSWE the two were close, at 0.797 and 0.785.
Of the unneeded code that remained, 89% changed how the program behaved, so the authors say reviewers can't safely skip it. Fix steps wrote 83% of that leftover code, while debugging steps wrote almost none of it, just 154 of 3,987 units.
Model choice matters more than score
How much unneeded code a model left didn't track how many tasks it solved. At nearly the same SWE-bench Verified solve rate, Anthropic's Sonnet 5 at 80.6% and Google's Gemini 3.7 Flash at 81.4% differed sharply, the paper says. Gemini 3.7 Flash left about 3.6 times as many unneeded code units per task, 1.23 against 0.34.
On DeepSWE the relationship flipped, the authors wrote. Models that solved more tasks tended to leave more unneeded code, with a Spearman correlation of -0.59, a measure of how closely two rankings move together.
Trimming the extra code
The team tested two cleanup approaches after a fix was done. They reported that asking each model to justify every chunk of its own diff and drop the rest was precise, at 66%, but caught only 36% of the unneeded code.
According to the paper, automatically pruning with the tests the agent could see found 67% of it, at 46% precision, and 89% of the pruned patches still solved the task. Stopping the agent at its first passing test run barely helped.
Caveats
The authors call their unneeded-code share an upper bound, since tests don't cover every behavior a developer might want. The main results use a single agent harness, and SWE-bench Verified is Python-only. They also note that removing units one at a time can mislead when two blocks are needed together.
The researchers recommend that coding benchmarks report code necessity next to solve rates. They also suggest stripping unneeded edits from training data before fine-tuning models.
Source: arXiv abstract, Aakash Goel, Benjamin Steenhoek, Yu Hu, Microsoft (company researchers, preprint), “How Much Do Coding Agents Over-Edit, and Why?”
Additional sources: arXiv full text, Microsoft researchers (preprint, not peer reviewed), “Unneeded Edits in Coding-Agent Patches”
