Delta Residue Attribution: Where Coding Agents' Unneeded Edits Actually Come From
Coding-agent pull requests routinely look bloated next to human developer patches—on average, resolved agent patches touch 2.33 times as many lines. That raw line-count gap is usually blamed on sloppy exploration or leftover debugging code, yet patch size alone cannot tell you which lines are unnecessary, what behavior they alter, or which step in the agent's trajectory produced them. In How Much Do Coding Agents Over-Edit, and Why?, Microsoft researchers introduce Delta Residue Attribution (DRA) and apply it to 7,660 resolved GitHub Copilot CLI trajectories across 18 frontier models to answer those questions at the level of individual diff blocks.
The headline finding flips the standard assumption: outside test files, agents change only 1.09 times as many lines as developers, and on SWE-bench Verified, 11 of 18 models actually leave behind a lower share of unneeded code than human developers do. The real catch lies in the 11% of code units that are unneeded—89% of them change program behavior on untested paths, and 83% are written during fix steps rather than debugging.
How Delta Residue Attribution Works
Comparing patch sizes against a single "minimal" reference patch breaks down at the repository level because valid software fixes often take different structural paths. Instead, DRA adapts delta debugging to run counterfactual removal directly on resolved agent trajectories.
Replay, Line-Level Blame, and Unit Provenance
Given a repository base state S_0 and a resolved trajectory τ ending in submitted patch Δ = diff(S_0, S_T), DRA executes four stages:
- Trajectory replay with line-level blame: Agent logs record tool calls rather than intermediate git trees, so DRA replays every structured file-edit and file-create call onto
S_0while tracking line-level blame after each step. Any trajectory whose replayed final state diverges fromΔis excluded. - Unit decomposition and classification: DRA splits
Δinto units—contiguous blocks of changed lines within a single file that can be reverted independently—and classifies each unit ascode,test,docs,nonsemantic, orconfig. - Provenance and step-role labeling: Each unit
uis attributed to the latest step that wrote or deleted any of its lines. Rules and an LLM judge assign that step a role:debug(exploring, reproducing, probing),fix(implementing or refining the patch), orcleanup(reverting earlier edits). - Counterfactual necessity grading: For each code unit
u, DRA constructs a state withureverted and runs an oracleO. Under the task-test oracleO_test,uis needed if reverting it causes anyFAIL_TO_PASSorPASS_TO_PASStest to fail. A patch's necessity precision (NP_code) is the fraction of code units that are needed;NP_code = 1.0means the patch is 1-minimal under that oracle.
Because unit tests rarely cover every branch, the authors also evaluate an augmented oracle O+ modeled on PatchDiff. Any unit whose reversion still passes O_test is checked with behavioral probes on untested inputs; a unit counts as needed if removing it breaks behavior matching the developer fix. Human developer patches are graded with the exact same pipeline for calibration.
What Extra Agent Edits Actually Contain
Applying DRA to 6,728 resolved patches on SWE-bench Verified (500 tasks) and 932 resolved patches on DeepSWE (113 contamination-resistant, long-horizon tasks) reveals that "over-editing" shifts sharply with task complexity:
- SWE-bench Verified: 61% of extra lines added by agents sit in test files, 13% are documentation, and only 21% are production code. Mean
NP_codeis 0.887 for agents versus 0.864 for human developers, with 11 of 18 models scoring higher necessity precision than the developer baseline. - DeepSWE: On longer-horizon tasks across five languages, 58% of extra edits are production code. Mean
NP_codedrops to 0.797 for agents and 0.785 for developers, with no individual model significantly outperforming humans.
Crucially, the extra tests agents add are valuable. In mutation-testing experiments, agent-authored tests detect 68.1% of injected bugs—beating existing repository regression tests (45.6%) while trailing task evaluation tests (77.1%) — and catch 5% of injected bugs that the benchmark's own task tests miss.
At the same time, the production code that is unneeded poses real review risk. On SWE-bench Verified, 11% of agent code units are unnecessary, and 89% of those unneeded units alter runtime behavior outside the test suite rather than leaving harmless dead code or whitespace edits.
Why Fix Steps—Not Debugging—Create Residue
Before running the study, the researchers pre-registered a natural hypothesis: if unneeded edits are leftover logging, temporary workarounds, or exploratory probes, debug steps should account for at least 40% of code residue.
The trajectory blame data refutes that hypothesis. On code units, the debug share is just 0.039—only 154 out of 3,987 unneeded code units trace back to debugging steps. Instead, 83% of all unneeded code is written during fix steps, when the model is actively trying to solve the issue.
Model-level comparisons sharpen this point:
- On SWE-bench Verified,
NP_codevaries substantially across the 18 models and has virtually no correlation with resolve rate (Spearman-0.10). - On DeepSWE, code necessity is negatively correlated with resolve rate (Spearman
-0.59,p = 0.01): models that solve more long-horizon tasks write a higher share of unnecessary code while doing so.
Higher capability at passing behavioral verifiers does not automatically produce minimal diffs.
Can Harnesses Prune Unneeded Code Automatically?
Because unneeded edits originate in fix steps rather than debug steps, stopping early at the "first green" test run barely helps—on eligible SWE-bench Verified patches, early stopping shifts NP_code from 0.700 to 0.710 (97.3% still resolve).
The authors therefore compare two post-generation cleanup strategies on SWE-bench Verified:
| Cleanup Method | Recall | Precision | NP_code Shift | Patches Still Resolving |
|---|---|---|---|---|
| Agent Self-Audit | 35.5% | 65.7% | 0.924 to 0.944 | 98.2% |
| DRA + Visible Tests | 67.3% | 46.3% | 0.936 to 0.975 | 89.1% |
Asking the agent to audit its own diff is safe (98.2% of patches still resolve, 65.7% precision) but misses nearly two-thirds of unneeded code units. Running automated DRA pruning at the harness level—using only the tests visible to the agent (its own generated tests plus the repository's existing regression suite)—removes 67.3% of unneeded code and lifts NP_code to 0.975. However, because visible tests do not cover every required edge case, 53.7% of dropped units are actually needed, reducing the resolve rate of pruned patches to 89.1%.
Practical Takeaways for Agent Benchmarks and Harnesses
Evaluating coding agents solely by pass rate hides behavioral sprawl that reviewers must still audit and maintain. Reporting NP_code alongside resolve rate distinguishes models that fix issues cleanly from models that rely on speculative edits. Because 83% of unneeded code originates inside fix steps while visible-test pruning risks deleting needed edge-case logic, curbing over-editing requires edit-minimality objectives during model training paired with stronger test synthesis before harness-level pruning.