Research
Agent patches are 2.33x bigger than developers'. Only 11% of their code is unneeded, but 89% of that changes behavior
Everyone says coding agents write bloated patches. A new Microsoft study reverted every block of 7,660 resolved patches one at a time and reran the tests. The bloat is mostly tests, agent code is about as necessary as human code, and the leftover 11% is the part reviewers can't skip.
"The agent rewrote fifty lines to fix a three-line bug" is the most common complaint about coding agents in code review. It's also mostly untested. Patch size tells you an agent changed more. It doesn't tell you whether the extra changes were needed, what they were, or where in the run they came from.
A Microsoft paper posted to arXiv on November 25, 2026 (Aakash Goel, Benjamin Steenhoek and Yu Hu) measures exactly that. The team replayed 7,660 resolved GitHub Copilot CLI trajectories from 18 models, reverted every block of every final patch one at a time, and reran the tests. Then they graded human developer patches the same way.
The short version: agent patches are bigger, but the bloat is mostly tests. Agent code is about as necessary as human code. The roughly 11% that isn't needed is the dangerous part, because 89% of it changes behavior.
Key findings
- 2.33x the lines, but not 2.33x the code. On SWE-bench Verified the median model changes 2.33 times as many lines as the developer patch. On code units alone the ratio is 0.86; outside test files it's 1.09.
- The extra is mostly tests. Of all extra edits on SWE-bench Verified, 61% are test-file edits, 21% code, 13% documentation, 5% comments or formatting. 81.5% of agent patches touch a test file.
- Agent code is at least as necessary as developer code. Mean code necessity (NP_code) is 0.887 for agents vs 0.864 for developers on SWE-bench Verified, and 0.797 vs 0.785 on DeepSWE. 11 of 18 models leave significantly less unneeded code than the developer baseline.
- The leftovers aren't harmless. About 11% of an agent patch's code units are unneeded, and behavioral probes show 89% of those change behavior (for example, raising or swallowing an exception on nearby inputs).
- It's not debug junk. Debug steps wrote only 154 of 3,987 unneeded code units. Fix steps wrote 83%.
- Better benchmark scores don't mean leaner patches. Necessity is unrelated to resolve rate on SWE-bench Verified (Spearman −0.10) and negatively correlated on DeepSWE (−0.59, p = 0.01).
How the study measured "unneeded"
The method is called Delta Residue Attribution (DRA), and it borrows from Zeller and Hildebrandt's delta debugging. In plain terms:
- Replay. Re-run every file edit the agent made on the original files, recording line-level blame after each step. Trajectories that don't reproduce the submitted patch exactly are dropped (96.7% of SWE-bench Verified runs replayed cleanly).
- Split into units. A unit is one contiguous block of changed lines in one file. Each unit is tagged as code, test, docs, config or formatting.
- Trace provenance. Each unit is attributed to the latest step that wrote it, and that step is labeled debug, fix or cleanup.
- Revert and retest. Revert one unit, rerun the task's FAIL_TO_PASS and PASS_TO_PASS tests. If the tests now fail, the unit was needed.
Necessity precision (NP) is the share of a patch's units that are needed. NP = 1 means no single block can be removed without breaking the tests. Because tests miss behavior, the authors also ran LLM-written behavioral probes against units flagged unneeded, and graded developer patches with the identical yardstick. That calibration matters: the plain test oracle calls 33% of developer code units unneeded, which tells you how much any test-based measure overstates "waste."
The data: SWE-bench Verified (500 Python tasks; 6,728 agent patches, 30,265 units) and DeepSWE (113 long-horizon tasks in Go, TypeScript, Python, Rust and JavaScript; 932 patches, 26,209 units). SWE-bench Verified resolve rates in the pool ranged from 64.0% to 89.4%.
So where does the "bloat" come from?
Mostly from agents writing tests nobody asked for, and those tests are often good. The authors injected 1,962 mutants (small artificial bugs) into patched code across 271 instances:
| Test suite | Share of injected bugs caught |
|---|---|
| Task tests (benchmark's own) | 77.1% |
| Tests the agent added | 68.1% |
| Existing regression tests in the same files | 45.6% |
Of the bugs that slipped past the task tests, 22.7% were caught by tests the agent added or strengthened. If you're a reviewer deleting agent-written tests to "keep the diff small," you're deleting real coverage.
The picture changes on harder work. On DeepSWE, where tasks are feature implementations with about six times more units per patch, code is 58% of extra edits and tests only 26%. Long-horizon tasks are where genuine code over-editing shows up.
Model by model
Per-model results on Copilot CLI, SWE-bench Verified, from the paper's Table 11. NP_code is the share of code units needed; Δ dev is agent minus developer NP_code on matched tasks (positive = less unneeded code than the human); "Lines/dev" is code lines changed relative to the developer.
| Model | Resolve rate | NP_code | Δ dev | DeepSWE NP_code | Lines/dev |
|---|---|---|---|---|---|
| Claude Opus 5.5 | 89.4% | 0.900 | +0.042 | 0.790 | 0.82 |
| Kimi K3 | 88.4% | 0.897 | +0.024 | 0.822 | 0.86 |
| Claude Opus 5 | 87.2% | 0.898 | +0.031 | 0.808 | 0.94 |
| Claude Opus 4.8 | 85.0% | 0.912 | +0.045 | 0.866 | 0.91 |
| GPT-6 Astra | 84.4% | 0.889 | +0.025 | 0.749 | 0.85 |
| GPT-5.6 Sol | 83.6% | 0.924 | +0.042 | 0.787 | 0.84 |
| Gemini 3.8 Flash | 82.4% | 0.765 | −0.095 | 0.748 | 1.32 |
| Gemini 3.7 Flash | 81.4% | 0.789 | −0.074 | 0.730 | 1.36 |
| Claude Sonnet 5 | 80.6% | 0.922 | +0.052 | 0.814 | 0.86 |
| Claude Haiku 5.5 | 79.8% | 0.913 | +0.044 | 0.834 | 0.81 |
| GPT-6.1 Sol | 79.4% | 0.887 | +0.024 | 0.767 | 0.84 |
| GPT-6 Sol | 78.6% | 0.886 | +0.011 | 0.770 | 0.89 |
| GPT-5.6 Terra | 77.4% | 0.928 | +0.058 | 0.840 | 0.77 |
| Claude Sonnet 5.5 | 76.4% | 0.929 | +0.055 | 0.821 | 0.72 |
| GPT-5.6 Luna | 76.0% | 0.946 | +0.059 | 0.798 | 0.74 |
| Gemini 3.6 Flash | 73.2% | 0.791 | −0.076 | 0.801 | 1.36 |
| GPT-6 Luna | 71.6% | 0.921 | +0.048 | 0.805 | 0.79 |
| Claude Haiku 4.5 | 64.0% | 0.873 | −0.003 | n/a | 1.15 |
| Developer patch | — | 0.864 | — | 0.785 | 1.00 |
Three things stand out.
The Gemini Flash models are the outliers. All three are the only models significantly worse than developers, and they're the only ones changing ~1.3x the developer's code lines. At nearly identical resolve rates, Sonnet 5 (80.6%, NP 0.922) and Gemini 3.7 Flash (81.4%, NP 0.789) differ by 3.6x in unneeded code units per task (0.34 vs 1.23).
The top resolver isn't the leanest. Claude Opus 5.5 solves the most tasks; GPT-5.6 Luna and Claude Sonnet 5.5 leave the least unneeded code. If your bottleneck is review time rather than raw solve rate, those are different rankings.
On long-horizon work, solving more correlates with leaving more. The DeepSWE anti-correlation (−0.59) suggests the behaviors that push an agent through a hard task (adding defensive branches, broadening a fix) are the same ones that leave residue.
One caveat the authors flag: the SWE-bench Verified developer gap depends on the oracle. Under the strengthened oracle with behavioral probes, the average agent advantage of +2.3 points flips to −4.5 points. "Agents are cleaner than humans" is oracle-dependent. "Agents are roughly comparable, and model choice matters more than agent vs human" is the robust reading.
Why the 11% matters more than the 2.33x
Reviewers can skim tests and docs. They can't skim behavior changes. The study finds that 89% of unneeded code units change behavior, and only 11% are inert guards or duplicate checks. That's consistent with prior work the paper cites: in one maintainer study roughly half of SWE-bench-passing patches wouldn't have been merged, and plausible patches often behave differently from the developer fix on untested inputs.
So the practical risk isn't "agent diffs are long." It's that roughly one in nine code blocks in a passing agent patch does something the task didn't require, and most of those somethings are observable.
Can you strip it out automatically?
The paper tested three post-generation cleanups on SWE-bench Verified:
| Strategy | Precision | Recall | NP_code before → after | Patches still resolving |
|---|---|---|---|---|
| Stop at the agent's first green test run | — | — | 0.700 → 0.710 | 97.3% |
| Self-audit (model justifies each hunk, drops the rest) | 65.7% | 35.5% | 0.924 → 0.944 | 98.2% |
| DRA pruning with the agent's own tests | 39.6% | 66.5% | 0.936 → 0.974 | 86.6% |
| DRA pruning with agent tests + existing regression tests | 46.3% | 67.3% | 0.936 → 0.975 | 89.1% |
Pruning applied only to the 2,495 of 6,724 patches that had a standalone, repeatably passing agent test command.
What this means for teams running coding agents:
- "Stop as soon as tests pass" doesn't help. Most unneeded code is already written by the first green run.
- A self-audit prompt is cheap and safe (it breaks only 1.8% of resolved patches) but catches about a third of the problem.
- Revert-and-retest pruning catches two thirds but drops needed code more than half the time it acts, and about 11% of pruned patches stop resolving. Use it to flag hunks for a human, not to auto-delete.
- Debug cleanup hooks are aimed at the wrong target. Scratch scripts and debug prints almost never survive into resolved patches; the residue is written while building and revising the fix.
Limitations worth knowing
- One harness. Main results are all GitHub Copilot CLI. Other harnesses get an appendix, not the headline.
- Tests define "needed." NP inherits the test suite's blind spots, so unneeded counts are upper bounds. On DeepSWE, 33.4% of patches contain at least one unit without exact provenance.
- One-at-a-time reverts. Two blocks that are only needed together can both look unneeded.
- Resolved patches only. Over-editing in failed runs is out of scope.
- SWE-bench Verified is Python-only and possibly contaminated. Role labels came from an LLM judge (GPT-6.1 Sol), cross-checked by a second LLM (Claude Opus 5.5) at 84.4% agreement, with no human audit of roles.
The takeaway
The "agents write bloated code" story is mostly a story about tests, and those tests catch real bugs. The real problem is smaller and sharper: about one in nine agent code blocks isn't needed, nearly all of them change behavior, and higher benchmark scores don't make the problem go away. The authors' recommendations are the right ones: benchmarks should report code necessity next to resolve rate, and over-editing should be fixed in training data and at the harness level rather than with prompts.
If you're picking a coding agent, look past the leaderboard number. Compare tools in our best AI coding agents guide, see how GitHub Copilot's coding agent works in practice, and read our earlier research on Terminal-Bench 2.1's benchmark repairs for another case of scores hiding what matters. For the evaluation side, start with how to evaluate an AI agent harness.
Source: Goel, Steenhoek and Hu, "How Much Do Coding Agents Over-Edit, and Why? An Empirical Study of Unneeded Edits in Repository-Level Agent Patches," arXiv:2611.34875, November 25, 2026. All figures are from the paper's v1.
FAQ
Do AI coding agents over-edit?
By line count, yes: on SWE-bench Verified the median model in Microsoft's November 2026 study changed 2.33 times as many lines as the developer patch. But 61% of the extra edits were tests and 13% documentation. Measured by whether each code block is needed to pass the tests, agent code scored 0.887 versus 0.864 for developer patches, so most agent code is necessary.
How much of an AI agent's patch is unneeded code?
On average 11% of an agent patch's code units on SWE-bench Verified were not needed by the task tests. On the harder DeepSWE benchmark, necessity was 0.797, so roughly 20% of code units were unneeded, close to the 0.785 developer baseline. The authors treat these figures as an upper bound because tests don't cover every intended behavior.
What is Delta Residue Attribution (DRA)?
DRA is the method introduced in arXiv paper 2611.34875. It replays an agent's trajectory, splits the final patch into independently revertible blocks, traces each block to the step that wrote it, then reverts each block and reruns the task tests. A block is needed if reverting it makes the tests fail. The share of needed blocks is the patch's necessity precision.
Which models leave the most unneeded code?
In the study's 18-model pool on Copilot CLI, three Gemini Flash models (3.6, 3.7 and 3.8) left significantly more unneeded code than developers, with necessity between 0.765 and 0.791. GPT-5.6 Luna scored highest at 0.946. Claude Opus 5.5 had the top resolve rate (89.4%) with necessity 0.900.
Can unneeded agent code be removed automatically?
Partly. Asking the model to justify each hunk and drop the rest was precise (65.7%) but found only 35.5% of unneeded code. Pruning by reverting blocks while the agent's own tests and existing regression tests still pass found 67.3% at 46.3% precision, and 89.1% of pruned patches still resolved the task. Stopping at the agent's first green test run barely helped.
Does a higher SWE-bench score mean cleaner patches?
No. Across 18 models, code necessity was unrelated to resolve rate on SWE-bench Verified (Spearman -0.10) and negatively correlated on DeepSWE (-0.59, p = 0.01), meaning models that solved more long-horizon tasks left more unneeded code. The authors recommend benchmarks report necessity next to resolve rate.