How Much Do Coding Agents Over-Edit, and Why? An Empirical Study of Unneeded Edits in Repository-Level Agent Patches: what it means for business leaders
A Microsoft study of 7,660 resolved coding-agent patches finds the extra bulk is mostly tests and documentation, while about 11% of the code blocks are unneeded and most of those change behavior.
1. What the method is
Delta Residue Attribution, or DRA, is a measurement method for the patches coding agents produce. It replays an agent's recorded session, splits the final patch into units (contiguous blocks of changed lines that can be reverted on their own), traces each unit to the step that wrote it, then reverts each unit in turn and reruns the task's tests. A unit whose removal leaves the tests passing is counted as unneeded. The share of needed units is the patch's necessity precision, reported separately for code. The authors, from Microsoft, apply it to 7,660 resolved GitHub Copilot CLI sessions from 18 frontier models on two benchmarks, SWE-bench Verified (6,728 patches) and DeepSWE (932), and grade the human developers' patches for the same tasks in the same way. The result is an empirical study, not a product: it says how much agent code is surplus, what kind it is, where it comes from, and how well it can be removed automatically.
2. Why the method was developed
Agent patches are larger than the ones developers write for the same task, roughly twice the size in earlier work, and that has been read as over-editing. Size matters because larger changes take longer to review and predict more defects, and a cited maintainer study found that about half of benchmark-passing agent patches would not have been merged. But patch size cannot say whether the extra lines are needed, what they are, or when they were written, and the remedy depends on the answer. If the surplus is leftover debugging, the tool around the model can clean it up. If it is tests, we may want it. If it is written into the fix itself, the model has to change. Earlier measurements compared against a single known minimal fix, mostly on individual functions, or counted lines at repository level. Coverage metrics confuse code the tests execute with code the task requires. DRA measures necessity by removal and needs no reference patch.
3. Who should care
Engineering leaders who are rolling out coding agents should read this as evidence about review load: the extra volume in agent pull requests is mostly tests and documentation, but the surplus code that remains is not harmless padding. Whoever selects or procures coding models should note that the amount of unneeded code differs substantially by model and is not predicted by the headline resolve rate, so two models with the same benchmark score can impose different review costs. Teams that build our internal agent tooling get measured numbers on two cleanup steps they could add after generation. Quality and test engineering should note that agent-written tests have real bug-catching value. Anyone fine-tuning code models on agent sessions gets a concrete recommendation to strip unneeded blocks from training data first. Security and risk reviewers should register that most unneeded blocks alter behavior on inputs the tests do not cover, which is where unreviewed changes hide.
4. How the method works
The pipeline has four steps. Replay applies the session's file-editing calls to the task's starting files and records, line by line, which step last wrote each line; sessions whose replayed result does not match the submitted patch exactly are dropped, and 96.7% of SWE-bench Verified sessions replay. Changed blocks separated by at most one unchanged line are merged into one unit, and each unit is classed as code, test, documentation, configuration, or comment and formatting. Each step that introduced a unit gets a role, debug, fix or cleanup, from two fixed rules and then an LLM judge. Grading reverts one unit at a time in the official evaluation container and reruns the task tests. Because tests miss behavior, an LLM also writes probe scripts for each unneeded code unit and runs them against the agent patch, the reverted state and the developer patch, to see whether the unit changes behavior. Test-file edits cannot be graded this way and are reported separately.
5. How it was evaluated
The data are resolved sessions from 18 models from four providers running under one agent harness, GitHub Copilot CLI, on SWE-bench Verified (500 Python tasks) and DeepSWE (113 long-horizon tasks in five languages). That yields 30,265 units on the first and 26,209 on the second. The baseline is the developers' own patches graded by the same procedure, on 470 SWE-bench Verified instances and 103 DeepSWE tasks, with 95% bootstrap confidence intervals over instances. A second LLM judge relabeled 10,000 sampled steps and agreed on 84.4% of role labels. The usefulness of agent-written tests was measured by injecting 1,962 small artificial bugs across 271 instances. Three cleanup strategies that do not rely on the hidden task tests were tried on SWE-bench Verified: stopping at the agent's first passing test run, asking the model to justify every block of its own diff, and pruning with DRA using the agent's own tests plus the repository's existing regression tests. Hypotheses were pre-registered, and deviations are listed.
6. How it performed
Agents change 2.33 times the lines developers do, but on SWE-bench Verified 61% of the extra edits are tests and 13% documentation; on DeepSWE 58% are code. Agent code is about as necessary as developer code (0.887 against 0.864, and 0.797 against 0.785), though that comparison reverses under the stricter oracle. About 11% of agent code units are unneeded, 89% of those change behavior, and fix steps, not debugging, write 83% of them. Agent tests caught 68.1% of injected bugs against 77.1% for the task tests. Self-audit found 35.5% of unneeded code at 65.7% precision and broke 1.8% of patches; test-based pruning found 67.3% at 46.3% precision, applied to only 2,495 patches, and 89.1% still resolved. Limits: necessity is relative to the tests, no human labeled the flagged code, only successful sessions on one harness were studied, and SWE-bench Verified may be contaminated. Our call: pilot, by separating test from code changes when we review agent pull requests and trialing self-audit before any automatic pruning. (Source: arXiv 2611.34875, 2026)
← Back to dossier index