How Much Do Coding Agents Over-Edit, and Why? An Empirical Study of Unneeded Edits in Repository-Level Agent Patches

Aakash Goel, Benjamin Steenhoek, Yu HuarXiv 2026

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.

Figure 1: Overview of DRA. A resolved trajectory is replayed, each unit of the final patch is traced to the step that wrote it, the step is labeled with a role, and each unit is reverted to test whether it is needed. Unneeded units are attributed to the role of the step that wrote them. The example is the parse_date() fix of Appendix B.1.

DRA takes a successful agent run and works in four stages:

  1. Replay & Units: It replays the agent's step-by-step history and breaks the final code diff into independent, contiguous blocks called units.
  2. 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), or CLEANUP.
  3. 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}}$).
  4. 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).
Figure 2: Agent minus developer NPcode (∆dev) per model under Otest, with 95% bootstrap CIs. (a) SWE-bench Verified instances with developer patches (6,728 agent patches, 470 developer patches). (b) DeepSWE tasks with developer patches (914 agent patches from 17 models, 103 developer patches). Each panel is sorted by ∆dev. Red: the CI excludes 0 below; blue: above.
  • 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

Abstract

Agent patches are larger than developers', which is widely read as over-editing. But patch size does not say whether the extra edits are needed, what they are, or where they come from. We introduce Delta Residue Attribution (DRA), which replays agent trajectories, traces every block (unit) of the final patch to the step that wrote it, reverts each unit, and reruns the task tests to decide whether the unit is needed. We apply DRA to 7,660 resolved GitHub Copilot CLI trajectories from 18 frontier models on SWE-bench Verified (6,728) and DeepSWE (932), and grade developer patches using the same method. Agent patches do change more lines than developers'; on SWE-bench Verified the majority of extra edits add tests (61%) and documentation (13%) while on DeepSWE, most extra edits are code (58%). On both benchmarks, agents' code is on average at least as necessary as developers' (mean $NP_{code}$ 0.887 vs. 0.864 on SWE-bench Verified, where 11 of 18 models leave less unneeded code than developers, and 0.797 vs. 0.785 on DeepSWE). On average, 11% of an agent patch's code units on SWE-bench Verified are still unneeded, and 89% of those change behavior. Debug steps write almost none of the unneeded code. Code necessity differs substantially by model; it is unrelated to resolve rate on SWE-bench Verified and negatively correlated with it on DeepSWE (Spearman -0.59, p = 0.01). On SWE-bench Verified, pruning with DRA using only the tests the agent can see (its own tests and the repository's) removes the majority of unneeded code but also some needed code (67% recall, 46% precision), and 89% of pruned patches still resolve the task; asking the agent to audit its own diff is more precise but less effective (36% recall, 66% precision). We recommend that benchmarks report code necessity next to resolve rate and that over-editing be addressed through model training and harness-level pruning.
BibTeX
@misc{goel2026how,
  author = {Aakash Goel and Benjamin Steenhoek and Yu Hu},
  title = {{How Much Do Coding Agents Over-Edit, and Why? An Empirical Study of Unneeded Edits in Repository-Level Agent Patches}},
  year = {2026},
  eprint = {2611.34875},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.34875},
}
Figure