← all writing
01 · 26 Nov 2026 · 7 MIN READ

Agent diffs aren't bloated where you think: 11% of their code is unneeded

The standard complaint about coding agents is that their diffs are bloated. Ask for a one-line fix, get back forty lines across three files. I've made that complaint myself, usually while scrolling past a test file nobody asked for.

It turns out the complaint is right about the size and mostly wrong about the danger. How Much Do Coding Agents Over-Edit, and Why? by Aakash Goel, Benjamin Steenhoek and Yu Hu takes 7,660 resolved GitHub Copilot CLI trajectories from 18 models, on SWE-bench Verified and DeepSWE, and asks a narrower question than "is the diff big": for each changed block, would the tests still pass without it?

The answer splits the bloat story in two. The visible extra lines are mostly harmless. The invisible extra lines are a smaller slice, and nearly all of them change what your program does.

Revert one block, rerun the tests, repeat

The method is called Delta Residue Attribution, and it's mechanical enough that I wish I'd thought of it. They replay each trajectory's file edits so every line in the final patch is tied to the step that wrote it. The patch is cut into units: contiguous changed blocks in a file, with blocks one unchanged line apart merged, and new or deleted files counted as one unit. Then each unit is reverted on its own and the task tests rerun.

If reverting a unit breaks the tests (or the revert won't apply or parse), the unit was needed. If everything stays green, it wasn't. The share of needed units is the patch's necessity precision. They grade developer patches the exact same way, which is the part that makes the comparison honest: humans don't get a free pass as the gold standard.

The bloat everyone notices is tests and docs

Yes, agent patches are bigger. The median agent patch changes 2.33× as many lines as the developer's fix. But restrict the count to code units and the ratio falls to 0.86. On SWE-bench Verified, the extra edits break down like this:

And the code itself is about as necessary as what developers write: mean code necessity of 0.887 for agents versus 0.864 for developers on SWE-bench Verified, and 0.797 versus 0.785 on DeepSWE. Eleven of the 18 models left less unneeded code than the human patches did.

The extra tests aren't junk either. In a mutation-testing run over 271 instances, agent-added tests killed 68.1% of mutants, against 45.6% for the existing regression tests. So the part of the diff that makes reviewers sigh is, on this evidence, roughly the most useful part of the bloat.

Debug steps don't explain the leftovers either. The authors trace provenance and find almost none of the unneeded code was written during debugging. It's not stray print statements that never got cleaned up.

The 11% that tests can't see is the part that bites

Here is where I stopped skimming. About 11% of agent code units on SWE-bench Verified are unneeded: revert them and the tests still pass. The authors then probed 3,559 of those units with behavioural checks.

89% of them change behaviour when reverted.

Their example is the kind of thing that ships unnoticed: code that raises or swallows an exception on inputs near the ones the issue described. The remaining 11% are inert guards and duplicate checks. Developer patches aren't clean here either; their unneeded units change behaviour 84% of the time. But a human usually wrote that extra code on purpose. An agent writing behaviour-changing code that no test demanded and no issue asked for is a different kind of risk, because nobody decided it.

This reframes what I look for in review. The test file at the bottom of the diff is not the problem. The extra conditional in the middle of the function, the one that reads like defensive programming, is.

Resolve rate tells you nothing about it

Code necessity varies a lot by model, and leaderboard position doesn't predict it. Sonnet 5 sits at 0.922 while Gemini 3.7 Flash sits at 0.789, both around an 81% resolve rate. On SWE-bench Verified the correlation between necessity and resolve rate is essentially zero (Spearman −0.10, p = 0.69). On DeepSWE it turns negative: −0.59, and still −0.52 after adjusting for task difficulty. The models that resolve more DeepSWE tasks leave more unneeded code behind.

We recommend that benchmarks report code necessity next to resolve rate

I agree, and I'd go further for anyone choosing a model for a team: a resolve rate is a measure of whether the tests went green, not of how much unrequested behaviour came along for the ride. Those are separate axes, and only one is on the leaderboard.

Self-review is precise and timid; revert-and-rerun is the opposite

The most practical result is the pruning comparison, run under the strengthened test oracle on SWE-bench Verified:

So the self-audit prompt, the thing most of us would reach for first, finds about a third of the unneeded code. The dumb mechanical loop finds two thirds, at the cost of cutting some code that was actually wanted and breaking roughly one patch in nine. On the eligible patches, the combined version lifted code necessity from 0.936 to 0.975.

Neither is a gate you'd run unattended. But they fail in opposite directions, which suggests the obvious composition: use revert-and-rerun to nominate candidates, then show the reviewer (human or model) only those hunks with the question "which test or requirement needs this?" That's a much smaller, sharper review than reading the full diff.

Where I'd hold back

The limitations are real and the authors list most of them. Everything runs through one harness, Copilot CLI, so a Claude Code or sub-agent setup with different editing habits could look different. Only resolved trajectories are studied. Units are reverted one at a time, so two blocks that are only needed together can both look unnecessary. The behavioural probes are LLM-written, and "unneeded" by the tests is not the same as unwanted by the developer. A third of DeepSWE patches have at least one unit without provenance, and SWE-bench Verified is Python-only and plausibly contaminated. The paper doesn't report what DRA costs to run, and rerunning a test suite once per changed block is not free on a real repo.

None of that undoes the core finding, which is about where to look rather than an exact percentage.

What I'm changing in my own loop

Two things. First, I'm going to stop treating diff size as the review signal and stop asking the agent to trim its tests and docs; that's the cheap, useful part. Second, I want a post-run step in the harness that reverts each non-test hunk, reruns the relevant tests, and flags any hunk that survives. Those flagged hunks get the reviewer's attention first, with a sub-agent asked to name the requirement each one serves.

My prediction: within a year, serious agent evals will report something like necessity next to pass rate, and the models that look best on resolve rate will not all look best on that second number. This paper already shows the gap on DeepSWE. I'd rather know which of my agent's extra conditionals nobody asked for before a user finds them.


Working on something similar?

Say hello — I read every email.