When a coding agent hands you a patch twice the size of the one a developer would have written, most of the extra is tests and documentation, and the code itself is roughly as lean as a human's. That is the headline from a new study by Aakash Goel, Benjamin Steenhoek and Yu Hu at Microsoft, posted on 25 November. The catch is in the remainder: about 11% of an agent patch's code blocks are not needed to pass the tests, and 89% of those still change how the program behaves. So the practical rule for reviewers is to split an agent's diff into test hunks and code hunks, and spend your attention on any code hunk you cannot tie to a failing test.

The study in one paragraph

The authors built a method they call Delta Residue Attribution (DRA). It replays an agent's full working session, splits the final patch into units (contiguous blocks of changed lines that can be undone on their own), traces each unit back to the step that wrote it, then reverts each unit and reruns the task's tests. If the tests still pass without a unit, that unit was not needed. This is an old idea, delta debugging, applied to agent output.

They ran it over 7,660 resolved sessions from 18 models, all driven through GitHub Copilot CLI, GitHub's terminal coding agent. The tasks came from SWE-bench Verified, a set of 500 real Python bug fixes, and DeepSWE, 113 longer feature-building tasks across Go, TypeScript, Python, Rust and JavaScript. Crucially, they graded the developers' own patches the same way, so every agent number has a human baseline beside it.

Where the extra lines actually go

By raw size, agent patches look bloated. On SWE-bench Verified the median model changes 2.33 times as many lines as the developer did. Strip out test files and the ratio falls to 1.09.

On SWE-bench Verified, the extra edits break down like this:

  • 61% test-file edits. 81.5% of agent patches touch a test file.
  • 21% code.
  • 13% documentation.
  • 5% comments or formatting.

On the code alone, agents come out slightly ahead. The share of code units that are needed averages 0.887 for agents against 0.864 for developers on the same tasks. Eleven of the 18 models leave significantly less unneeded code than the developers did; four show no significant difference; three (Gemini 3.6, 3.7 and 3.8 Flash) leave significantly more.

DeepSWE tells a different story. Those are feature tasks with roughly six times as many units per patch, and there 58% of the extra edits are code. Agents and developers are about level (0.797 against 0.785).

Who this finding is for: anyone whose team has a standing rule like "agent PRs are too big, reject them." Size is mostly measuring how many tests the agent wrote. Who it is not for: teams doing feature work that looks like DeepSWE, where the extra really is code.

The 11% you cannot wave through

Here is the part that should change how you review. On SWE-bench Verified, 11% of an agent patch's code units are unneeded on average. The authors ran behavioural probes on those units and found 89% of them change behaviour, for example by raising or swallowing an exception on inputs near the ones the tests cover. Only 11% were inert, such as a duplicate guard.

An analogy I find useful: you call a plumber about a dripping tap. The invoice is three pages longer than you expected, and most of the extra is the inspection report and the photos. Fine. But on the last page there is a line saying they also adjusted the pressure valve in the basement. Nobody asked for it, the tap now works, and your shower will behave differently from tomorrow. That line is the one worth a phone call.

There is a second wrinkle. How much unneeded code a model writes does not track how good it is at solving tasks. On SWE-bench Verified the authors find the two unrelated, and on DeepSWE it runs the wrong way (Spearman -0.59): models that solved more tasks left more unneeded code. At nearly the same resolve rate, Sonnet 5 (80.6%) and Gemini 3.7 Flash (81.4%) differ by about 3.6 times in unneeded code per task (0.34 units against 1.23). A leaderboard that reports only resolve rate tells you nothing about this.

Where the unneeded code comes from

The comfortable assumption is that the junk is leftover scratch work: debug prints, a test script the agent forgot to delete. The data points elsewhere. Of 3,987 unneeded code units, only 154 came from debugging steps. Fix steps wrote 83% of it, and revisions of a fix wrote 11%.

That matters because it rules out the cheapest cleanup. The authors tried stopping each session at the agent's first all-green test run and grading the patch from there. 97.3% of those earlier patches still passed the task tests, but the code barely shrank (7,419 units to 7,269). The unneeded code was already written into the fix by the time the tests first went green.

Two cleanup methods, two different failure modes

The study tested two cleanups that work without the hidden benchmark tests, which is the situation you are in at work.

Ask the agent to justify every hunk of its own diff and drop the ones it cannot. This is precise: 65.7% of what it dropped really was unneeded, and the drops broke only 1.8% of patches. But it found only 35.5% of the unneeded code.

Revert units automatically while the agent's own tests and the repository's existing regression tests still pass. This found 67.3% of the unneeded code, nearly twice as much, at 46.3% precision. 89.1% of pruned patches still solved the task. The false drops were mostly code implementing behaviour that no test exercised.

Read those together and the trade-off is plain. The self-audit is a cautious reviewer who misses a lot. The test-based pruner is an aggressive one that will delete real behaviour your tests do not cover. Neither replaces a human looking at the code hunks, but either is a decent first pass, and the second one doubles as a report on where your test coverage is thin.

The agent's tests are worth keeping

One more result cuts against the "agents pad their PRs" story. The authors injected 1,962 small artificial bugs (mutants) into patched code. The tests the agents added caught 68.1% of them, more than the existing regression tests in the same files (45.6%), though fewer than the benchmark's own task tests (77.1%). Of the bugs that slipped past the task tests, 22.7% were caught by tests the agent added or strengthened.

So the 61% of "extra" that is test edits is often doing real work. Deleting it to shrink the diff throws away coverage.

Caveats the authors state themselves

The main results use one harness, Copilot CLI, and the paper says SWE-bench Verified is Python-only and may be contaminated. The model judges that labelled each step's role were checked against a second model judge, not a human audit. The debugging finding rests on 154 units. And "unneeded by the tests" is not the same as "unwanted by a reviewer"; the authors say human labels are the next step. None of that undoes the central split between test edits and code edits, which is the part you can act on.

What to do with this

On the next agent pull request you review, sort the hunks into tests and code. For each code hunk outside the function the issue is about, revert it locally and run the tests: if nothing fails, either write the test that should fail or drop the hunk.