Open a pull request from a coding agent and the diff often runs to hundreds of lines. The reflex is to call it over-editing, and the reflex has data behind it: a Microsoft team measures the median model at 2.33 times the lines of the developer's reference patch on SWE-bench Verified, and the earlier RECAP study (paper) found successful agent patches carry about twice as many changes as developers', barely reduced by minimality prompts. But does bigger mean sloppier? A paper released on November 25 by Aakash Goel, Benjamin Steenhoek and Yu Hu at Microsoft (arXiv:2611.34875) makes 'unneeded' measurable, and the one-line answer is: agent patches are bloated, not watered down.

How a block of code gets graded as unneeded

The method, Delta Residue Attribution (DRA), replays the agent's full trajectory, 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 and reruns the task tests: if the tests still pass, the unit is unneeded; if they fail, it is needed. The share of needed units is NP, and over code units it is NP_code. Because passing tests does not make code correct (Wang et al. found 7.8% of plausible patches actually fail the developer-written test suite), the paper adds behavioral probes and grades developer patches with the same pipeline, so nobody gets a friendlier yardstick.

The sample: 7,660 resolved GitHub Copilot CLI trajectories from 18 frontier models; 6,728 on SWE-bench Verified (30,265 units) and 932 on DeepSWE (26,209 units), a benchmark of 113 original long-horizon engineering tasks graded by hand-written verifiers. 96.7% of trajectories replay exactly. The developer control group covers 470 instances and 1,317 code units.

Where the bloat sits

The lines are real: the median model changes 2.33 times the developer's lines; strip test files and the ratio drops to 1.09; count code units only and it is 0.86, below the developer. Of the extra edits, 61% are tests, 13% documentation, 21% code, and 5% comments or formatting; 81.5% of agent patches touch a test file, and 60% of all changed lines live in test files. The bloat, in other words, is mostly tests.

Genuinely unneeded code averages 11% of code units, and 89% of it still changes program behavior under the probes (altering outputs or exception paths), so it is not inert dead code. The paper reports a mean agent NP_code of 0.887 against a developer baseline of 0.864; 11 of 18 models leave less unneeded code than developers, four show no significant difference, and only Gemini 3.8, 3.7 and 3.6 Flash are significantly worse. On DeepSWE agents land at 0.797 versus 0.785 for developers, on par. For reference, under the plain test oracle 33% of developer code units are graded unneeded too, so the two populations are not that far apart.

Where the unneeded code comes from

The authors pre-registered a hypothesis that unneeded code is mostly debug residue; if true, its share would be at least 0.40. The data kill it: only 154 of 3,987 unneeded code units come from debug steps (a code debug share of 0.039), 83% are written at fix steps, and revisions contribute 11%; code written while revising is graded unneeded at 0.29 versus 0.25 for first-fix code, nearly identical. The surplus is baked into the fix from the start, not left behind by debugging, so a cleanup pass at the end aims at the wrong target.

A counterintuitive side finding concerns the tests agents add: over 271 instances passing validity checks, 1,962 mutants were injected, and the agent's new tests kill 68.1% of them, above the 45.6% of the repository's existing regression tests (below the task tests at 77.1%), and they catch 22.7% of the bugs the task tests miss. The extra tests are not extra at all.

Unrelated to resolve rate, and opposite on DeepSWE

Code necessity is uncorrelated with resolve rate on SWE-bench Verified (Spearman -0.10) and negatively correlated on DeepSWE (-0.59, p=0.01): models that resolve more do not write cleaner code. Per-model all-unit NP runs from 0.273 (GPT-6.1 Sol) to 0.848 (Sonnet 5.5), mostly tracking how many tests a model writes rather than code quality. The authors' recommendation is blunt: leaderboards should report NP_code with a developer baseline next to resolve rate, instead of using patch size as a proxy.

Can the surplus be removed automatically

Three routes were tried. Self-audit, asking the model to justify every hunk of its own diff, is precise (65.7%) but finds only 35.5% of the unneeded code and breaks 1.8% of resolved patches. Pruning with the tests the agent can see (its own tests plus the repository's regression tests) recovers 67.3% at 46.3% precision on the 2,495 eligible patches, and 89.1% of the pruned patches still pass the task tests. Stopping at the first all-green run barely helps: NP_code moves only from 0.700 to 0.710, because most unneeded code is already in the patch before the agent's tests first pass. One reversal deserves a note: once behavioral probes join the oracle, developer NP_code climbs from 0.864 to 0.970 while agents go only from 0.887 to 0.925, flipping the gap from +2.3 to -4.5 percentage points, so the agents' necessity edge widens under the stricter yardstick.

Boundaries and the takeaway

The paper states its own limits plainly: necessity depends on the oracle, and the DeepSWE numbers are an upper bound on unneeded code; the behavioral probes are LLM-written; units are reverted one at a time, so jointly needed pairs can be misjudged; only resolved trajectories were studied; the main results use a single harness, Copilot CLI; and SWE-bench Verified is Python-only and possibly contaminated, with human labeling left to future work. Combine that with the finding from Wang et al. that 29.6% of plausible patches behave differently from the reference implementation, and a bit of caution is warranted when reading these numbers.

So the next time an agent hands you a several-hundred-line PR, do not judge it by line count alone: check what share is tests, then ask what share of the code is unneeded. Patch size is body weight; necessity is body fat.