TL;DR
AI coding agents write software patches roughly twice as large as human developers', leading many to assume they chronically "over-edit." By replaying thousands of agent workflows and systematically deleting chunks of their final code to see what breaks, researchers discovered a surprise: most of that extra bulk is actually helpful new tests and documentation, and the core code agents write is often leaner than human code. Still, the ~11% of agent code that is unnecessary silently alters program behavior—and you can't predict which models do it just by looking at benchmark leaderboards.
What Problem Does This Paper Address?
When an AI coding agent fixes a bug, passing the test suite isn't enough. If a human engineer can fix a bug in three lines, an AI patch that rewrites fifty lines is exhausting to review and likely hides unintended side effects. Because AI patches are about twice the size of human patches on average, the conventional wisdom is that agents severely "over-edit."
However, raw line counts are a blunt instrument. Patch size alone doesn't tell us what those extra lines are, whether they are actually required to solve the problem, or when during the agent's problem-solving process they crept in. Knowing the origin of bloat matters: if extra edits are just forgotten print() statements from debugging, the agent's wrapper tool (the "harness") can easily sweep them up. If they are baked directly into the logic of the fix, the underlying AI model itself needs better training.
Methods
To dissect patches with surgical precision, the authors introduce Delta Residue Attribution (DRA), inspired by classic delta debugging.
DRA takes a successful agent run and works in four stages:
- Replay & Units: It replays the agent's step-by-step history and breaks the final code diff into independent, contiguous blocks called units.
- Provenance & Role Labeling: It traces each unit back to the exact step that wrote it, using rules and an LLM judge to label that step's intent:
DEBUG(exploring/probing),FIX(writing/refining the solution), orCLEANUP. - Counterfactual Necessity: One by one, DRA reverts each unit and reruns the benchmark's test suite. If the tests fail, the unit is needed; if they still pass, it is unneeded. The fraction of needed code units gives a clean metric: Code Necessity Precision ($\text{NP}_{\text{code}}$).
- Behavioral Probes & Human Calibration: Because test suites have blind spots, an LLM generates extra edge-case inputs ("behavioral probes") to check if "unneeded" code changes how the program behaves. Crucially, the authors also run DRA on the original human developer patches to establish a fair baseline.
Datasets
No new benchmarks were created; instead, the authors analyzed 7,660 successful trajectories generated by 18 frontier models inside the GitHub Copilot CLI agent across two existing benchmarks:
- SWE-bench Verified (6,728 patches across 500 Python bug-fixing tasks).
- DeepSWE (932 patches across 113 complex, multi-language feature-implementation tasks in Go, TypeScript, Python, Rust, and JavaScript).
Key Insights and Ideas
- The "bloat" illusion is mostly tests: Agents look verbose on bug-fixing tasks primarily because they proactively write regression tests and documentation—additions human reviewers usually welcome! And these tests aren't fluff: mutation testing (injecting artificial bugs) showed agent-written tests caught 22.7% of bugs that slipped right past the official benchmark tests.
- Debugging isn't leaving a mess: A natural hunch is that agents forget to delete scratch code from exploring the codebase. Not true. Debug steps account for almost none of the leftover code (<4%). Instead, 83% of unneeded code is written while the agent is actively constructing the fix.
- Unneeded code isn't harmless: Some 89% of unneeded code units aren't just dead weight or redundant checks—they actively change program behavior (like swallowing or raising exceptions on nearby inputs), meaning human reviewers cannot safely ignore them.
- Smarter doesn't mean cleaner: A model's bug-solving score (resolve rate) has zero correlation with how lean its code is on SWE-bench Verified, and is negatively correlated on DeepSWE. Models that solve harder feature tasks tend to leave more excess code behind.
Key Results
- Agents vs. Humans: While the median agent patch on SWE-bench Verified changes 2.33x as many total lines as a human, 61% of extra edits are tests and 13% are docs (on feature-heavy DeepSWE, 58% of extra edits are code). Grading strictly on code necessity ($\text{NP}_{\text{code}}$), agents average 0.887 vs. 0.864 for humans on SWE-bench Verified (11 of 18 models beat the human baseline; 3 Gemini Flash models left significantly more bloat). On DeepSWE, agents and humans tie (0.797 vs. 0.785).
- Model Variance: Two models with ~81% resolve rates can have wildly different habits—Claude Sonnet 5 ($\text{NP}_{\text{code}} = 0.922$) leaves 3.6x fewer unneeded code blocks per task than Gemini 3.7 Flash ($0.789$).
- Automated Cleanup Trade-offs: Trying to clean patches automatically at deployment reveals a sharp precision-recall trade-off. Asking a model to self-audit its diff is precise (65.7%) and rarely breaks working patches (98.2% still pass), but catches only 35.5% of bloat. Conversely, test-based DRA pruning (using only the repo's existing tests and the agent's new tests) catches 67.3% of unneeded code, but accidentally deletes untested-yet-necessary code, dropping patch survival to 89.1%.
Limitations and Future Work
DRA reverts blocks one at a time, meaning two mutually dependent redundant blocks (say, defining an unused helper and calling it) won't be caught together. Furthermore, necessity is ultimately bound by what tests and LLM probes can see—just because a test suite doesn't require a defensive check doesn't mean a human maintainer wouldn't want it. Finally, the study only examines successful runs within a single agent harness (Copilot CLI).
For future work, the authors suggest collecting human code-review labels to see how well maintainers agree with test-based necessity, testing open-source harnesses (like OpenHands), and "debloating" training trajectories with DRA before fine-tuning next-generation models.
Summary updated