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 Hu

Published

TL;DR

A method that replays coding-agent runs, reverts each block of the final patch and reruns the tests to see whether it was needed, applied to 7,660 resolved runs from 18 frontier models.

Why builders care

Editor's note

Big agent diffs are often blamed on over-editing. On SWE-bench Verified most of the extra lines are tests and docs, but 11% of an agent's code units are still unneeded, and 89% of those change behavior.

How to apply it

Editor's note
  1. 1Review agent diffs for code that isn't needed, not just for size. Most unneeded code here changed behavior.
  2. 2Try pruning with the tests the agent can see: revert each changed block and keep it only if a test needs it. In the paper that removed most unneeded code and 89% of pruned patches still resolved the task, though it also cut some needed code.
  3. 3When you compare models, track unneeded code next to resolve rate. The two were unrelated on one benchmark and negatively correlated on the other.

Key results

From the abstract
  1. 1

    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).

  2. 2

    On average, 11% of an agent patch's code units on SWE-bench Verified are still unneeded, and 89% of those change behavior.

  3. 3
    67% recall

    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).

  • 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 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.

Everything on this page is written from this abstract. For methods and full results, read the paper PDF.

Ask the paper

Answers come from the paper summary and abstract.

Ask anything about “How Much Do Coding Agents Over-Edit, and Why? An Empirical Study of Unneeded Edits in Repository-Level Agent Patches”, or start with one of these: