How Much Do Coding Agents Over-Edit, and Why? An Empirical Study of Unneeded Edits in Repository-Level Agent Patches
Organizations: Microsoft
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 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.
Figures & tables
| First green | Self-audit | DRA + | DRA + | |
| Patches / units graded | 3,031 / 7,419 | 6,345 / 13,729 | 2,495 / 5,060 | 2,495 / 5,060 |
| Dropped units | 150 (2.0%, net) | 1,238 (9.0%) | 997 (19.7%) | 863 (17.1%) |
| Precision | – | 65.7% | 39.6% | 46.3% |
| Recall | – | 35.5% | 66.5% | 67.3% |
| before after | 0.700 0.710 (3%) | 0.924 0.944 (26%) | 0.936 0.974 (59%) | 0.936 0.975 ( 61% ) |
| Patches still resolving | 97.3% | 98.2% | 86.6% | 89.1% |
Appendix figures & tables21 assets
Supplementary material from the paper’s appendix.
Appendix
| H | RQ | Hypothesis | Support if | Kill or redirect if |
|---|---|---|---|---|
| H1 | RQ3 | Residue dominance: much of the unneeded code in resolved patches is debug residue. | Pooled . | : unneeded code is in the fix; redirect to training-time causes. |
| H2 | RQ4 | Second axis: separates models that resolve rate does not. | Spearman(resolve, ) and at least one pair within 3 pp with non-overlapping CIs. | Spearman . |
| H3 | Validity | Metric validity: tracks human “should remove” labels better than edit-distance. | AUROC gain . | No advantage. |
| H4 | RQ5 | Harness fix: revert-on-reject plus a diff audit cut by . | Resolve rate within 1 pp. | Resolve loss pp. |
| H5 | RQ3 | Preservation prompts act on , not . | drops but drops . | Both drop alike. |
| H | Status | What the data show |
|---|---|---|
| H1 | Depends on statistic | Pooled over all units falls between the kill (0.15) and support (0.40) thresholds. Almost all of it is regression-test hunks; over code units , below the kill threshold. The conclusion therefore rests on switching to . |
| H2 | Met, with a changed statistic | The registered criteria used the all-unit (Spearman ); the main text uses ( , 19 separated pairs). Both pass. |
| H3 | Stage 1 only | Only the developer-patch proxy (stage 1) was run: AUROC gain (0.718 vs. 0.478), above the 0.1 bar on the proxy. The human stage has LLM pre-labels ( ) and no human labels, so H3 is not confirmed. |
| H4 | Deferred | Not run; it targets debug-step edits, which leave little code residue. RQ5 tests offline proxies. |
| H5 | Deferred | Not run, for the same reason. |
| Registered | Done | Reason and effect |
|---|---|---|
| Statement-level AST units with dependency closure (GumTree). | Contiguous line blocks; new file = one unit. | Language-independent and exactly revertible. Coarser units make single-unit patches more common; the multi-unit and line-weighted checks address this ( Section 5.4 ). |
| Strengthened oracle with property-based differential testing ( Live / Inert ). | Strengthened oracle combining with 8 LLM-written differential behavioral probes per test-unneeded code unit ( Section 3.4 ; Appendix C.1 ). | Property-based testing is future work ( Section 6 ). counts developer-equivalent untested code as needed and splits remaining unneeded units into live vs. inert. |
| Debug share over all units as the H1 statistic. | Reported, plus over code units. | The pilot showed most extra edits are test-file edits, which the test oracle cannot grade. |
| Agent compared with the developer baseline. | Matched on as the main comparison. | Developer patches have no test-file units in the oracle’s sense; comparing code with code is like for like. |
| All resolved SWE-bench Verified instances per model. | All resolved instances for RQ1–RQ5, the cleanup analyses, the strengthened oracle, and the mutation analysis (eligible frame). | Grading cost for the probe-based analyses; task fixed effects and the 99-task paired comparison control for task mix. |
| Single role/probe judge. | Role and probe judges are GPT-6.1 Sol. | Roles were validated against a second judge (Appendix B.4 ). |
| Notion | Definition | Cost to establish | Main weakness |
|---|---|---|---|
| Global minimum | Fewest units among all patches accepted by . | Search over subsets of candidate edits; exponential in general [ Zeller and Hildebrandt, 2002 ] . | Infeasible at repository scale; still oracle-relative. |
| 1-minimal | Removing any single unit makes reject. | Verification: oracle calls; reduction via delta debugging (ddmin) and related reducers [ Zeller and Hildebrandt, 2002 , Misherghi and Su, 2006 , Sun et al., 2018 ] . | Inherits oracle incompleteness; sensitive to unit granularity and interactions. |
| Semantic minimum | Smallest semantic change satisfying a specification, e.g., via MaxSMT [ Mechtaev et al., 2015 ] . | Requires a specification (often tests) and constraint solving. | Specifications are rarely available; tests used as specifications overfit [ Smith et al., 2015 ] . |
| Role | Description |
|---|---|
| Explore | Reads, searches, or lists code without modifying tracked files. |
| Reproduce | Creates or edits a script or test whose purpose is to reproduce or check the issue. Rule: a newly created file that is executed ( python , pytest , node , bash ) within the next three steps. |
| Probe | Inserts instrumentation or tries a change to test a hypothesis. Rule: an edit whose added lines are all print, logging, pdb / breakpoint , or console.log statements. |
| Fix | Applies the change the agent presents as its solution. |
| Refine | Modifies an existing fix after test or self-review feedback. |
| Cleanup | Reverts or deletes earlier changes. |
| Units ( pre-filter) | Checked | Changes behavior |
| Needed agent units (positive control) | 112 | 112 (100%) |
| Test-unneeded agent units | 3,559 | 3,151 (88.5%) [87, 90] |
| Test-unneeded developer units | 432 | 363 (84.0%) [80, 87] |
| Test-unneeded agent units, by how the developer patch behaves on the differing probes | ||
| Like the full agent patch (needed under ) | 3,559 | 1,263 (35.5%) [34, 37] |
| Like the patch without the unit (unrequested change; unneeded under ) | 3,559 | 1,586 (44.6%) [43, 46] |
| Model | Tasks | [95% CI] | vs. developer [95% CI] | ||
|---|---|---|---|---|---|
| Developer patch | 470 | 0.864 ∗ | 0.864 | – | n/a |
| Claude Opus 5.5 | 424 | 0.451 | 0.900 [0.879, 0.919] | +0.042 [+0.018, +0.065] | 0.39 |
| Kimi K3 | 410 | 0.479 | 0.897 [0.876, 0.917] | +0.024 [+0.000, +0.047] | 0.36 |
| Claude Opus 5 | 420 | 0.657 | 0.898 [0.877, 0.919] | +0.031 [+0.009, +0.055] | 0.25 |
| Claude Opus 4.8 | 404 | 0.657 | 0.912 [0.892, 0.930] | +0.045 [+0.022, +0.069] | 0.34 |
| GPT-6 Astra | 400 | 0.279 | 0.889 [0.867, 0.910] | +0.025 [+0.002, +0.047] | 0.24 |
| Benchmark | Harness | Models | Resolve (%) | ||
|---|---|---|---|---|---|
| SWE-bench Verified | Copilot CLI | 18 | 64.0–89.4 | 0.887 | |
| DeepSWE | Copilot CLI | 17 | 21.2–68.1 | 0.797 | |
| SWE-bench Verified | Claude Code | 3 | – | 0.926 (CLI 0.923) | – |
| SWE-bench Verified | Copilot coding agent | 1 | – | 0.903 (CLI 0.910) | – |
| SWE-bench Verified | VS Code agent mode | 1 | – | 0.911 (CLI 0.909) | – |
| DeepSWE | Claude Code | 3 | – | 0.828 (CLI 0.835) | – |
| Count | Cohort | Used for |
|---|---|---|
| 6,728 | Resolved SWE-bench Verified patches analyzed (18 models) | Main results |
| 6,345 | Resolved SWE-bench Verified patches in the self-audit (17 models; 13,729 code units) | RQ5 self-audit |
| 5,482 | Patches that edit tests | RQ2 test analyses |
| 2,945 | Patches with a standalone test selector, run in containers | |
| 2,495 | Repeatably passing | cleanup |
| 3,035 | Patches that keep editing after first green (of 4,860 that reach it) | Post-green analysis |
| Model | Resolve | Tasks | vs. dev. | DeepSWE | Lines/dev. | |||
|---|---|---|---|---|---|---|---|---|
| Developer patch | n/a | 470 | 0.864 | 0.864 | – | n/a | 0.785 | 1.00 |
| Claude Opus 5.5 | 89.4 | 424 | 0.451 | 0.900 | +.042 | 0.39 | 0.790 | 0.82 |
| Kimi K3 | 88.4 | 410 | 0.479 | 0.897 | +.024 | 0.36 | 0.822 | 0.86 |
| Claude Opus 5 | 87.2 | 420 | 0.657 | 0.898 | +.031 | 0.25 | 0.808 | 0.94 |
| Claude Opus 4.8 | 85.0 | 404 | 0.657 | 0.912 | +.045 | 0.34 | 0.866 | 0.91 |
| GPT-6 Astra | 84.4 | 400 | 0.279 | 0.889 | +.025 | 0.24 | 0.749 | 0.85 |
| SWE-bench Verified | DeepSWE | |||||
|---|---|---|---|---|---|---|
| Introducing role | Needed | Unneeded | Rate | Needed | Unneeded | Rate |
| Fix | 9,799 | 3,315 (83%) | 0.25 | 7,869 | 2,547 (72%) | 0.24 |
| Refine | 1,074 | 438 (11%) | 0.29 | 2,146 | 796 (22%) | 0.27 |
| Probe | 182 | 120 (3%) | 0.40 | 494 | 78 (2%) | 0.14 |
| Reproduce | 76 | 33 (1%) | 0.30 | 122 | 52 (1%) | 0.30 |
| Cleanup | 71 | 79 (2%) | 0.53 | 477 | 81 (2%) | 0.15 |
| Model | DeepSWE resolve | Tasks | Raw | Task-adjusted [95% CI] |
|---|---|---|---|---|
| Claude Opus 4.8 | 49.6 | 47 | 0.866 | +0.045 [+0.024, +0.067] |
| Claude Sonnet 5.5 | 56.6 | 55 | 0.821 | +0.042 [+0.018, +0.066] |
| Claude Haiku 5.5 | 48.7 | 47 | 0.834 | +0.037 [+0.006, +0.067] |
| Kimi K3 | 66.4 | 64 | 0.822 | +0.032 [+0.016, +0.047] |
| Claude Opus 5 | 64.6 | 65 | 0.808 | +0.027 [+0.013, +0.042] |
| GPT-5.6 Luna | 21.2 | 23 | 0.798 | +0.023 [ 0.020, +0.066] |
| Model | Tasks | Model | Developer | [95% CI] | , line-weighted | Units/task |
|---|---|---|---|---|---|---|
| GPT-5.6 Luna | 345 | 0.609 | 0.499 | +0.111 [+0.08, +0.14] | +0.098 [+0.07, +0.12] | 9.0 vs. 12.4 |
| GPT-5.3 Codex | 272 | 0.597 | 0.481 | +0.116 [+0.09, +0.15] | +0.114 [+0.08, +0.15] | 9.0 vs. 12.5 |
| Model | Resolve | Resolved tasks analyzed | Replay success |
|---|---|---|---|
| Claude Opus 5.5 | 89.4 | 424 | 99% (443/447) |
| Kimi K3 | 88.4 | 410 | 95% (422/442) |
| Claude Opus 5 | 87.2 | 420 | 99% (432/436) |
| Claude Opus 4.8 | 85.0 | 404 | 97% (413/425) |
| GPT-6 Astra | 84.4 | 400 | 98% (412/422) |
| GPT-5.6 Sol | 83.6 | 388 | 95% (398/418) |
| Metric | Needed ( ) | Unneeded ( ) | Full frame (271) |
|---|---|---|---|
| Evaluated code mutants | 1,725 | 237 | 1,962 |
| Killed by baseline tests in touched files ( ) | – | – | 45.6% |
| Killed by agent test units | 73.2% | 31.2% | 68.1% |
| Killed by held-out task tests ( ) | 83.4% | 31.2% | 77.1% |
| Killed by strengthened oracle ( ) | – | – | 84.7% |
| Net gain of agent tests over baseline file tests | – | – | 58.8% |
| mutmut operator class | 6,728 catalog | Share |
|---|---|---|
| Call argument ( CALL ) | 41,890 | 43.3% |
| String constant ( STR ) | 19,231 | 19.9% |
| Operator swap ( OPR / comp.) | 12,836 | 13.3% |
| Assignment / null ( ASN ) | 10,321 | 10.7% |
| Number constant ( NUM ) | 6,280 | 6.5% |
| Unary / keyword / other | 6,232 | 6.4% |
| Operator | Mutants | kill | kill |
|---|---|---|---|
| Constant (CON) | 569 | 66.3% | 77.2% |
| Statement deletion (SDL) | 507 | 78.9% | 86.4% |
| Relational operator (ROR) | 195 | 81.5% | 89.7% |
| Condition (COND) | 244 | 88.5% | 92.6% |
| Arithmetic operator (AOR) | 111 | 83.8% | 90.1% |
| Return value (RET) | 143 | 78.3% | 84.6% |
| Model | Patches | Units | test_* | Assert | Needed | Dev | Before Fix % | Post-fix | R G (Pre/Raw) | Sites (N/U) |
|---|---|---|---|---|---|---|---|---|---|---|
| Claude Opus 5.5 | 396 | 661 | 76.1% | 71.4% | 70.3% | 61.4% | 7.9% | 68.3% | 0.5% / 1.8% | 2,277 / 440 |
| Kimi K3 | 322 | 711 | 73.7% | 70.7% | 63.7% | 58.9% | 3.8% | 96.2% | 2.2% / 4.1% | 2,420 / 566 |
| Claude Opus 5 | 181 | 386 | 74.6% | 73.6% | 68.1% | 59.6% | 11.1% | 81.1% | 1.1% / 2.8% | 2,629 / 772 |
| Claude Opus 4.8 | 203 | 387 | 76.5% | 74.4% | 70.5% | 64.9% | 6.9% | 92.1% | 2.5% / 4.4% | 2,610 / 619 |
| GPT-6 Astra | 400 | 995 | 73.3% | 71.1% | 65.8% | 59.3% | 62.6% | 19.6% | 38.2% / 44.7% | 1,765 / 542 |
| GPT-5.6 Sol | 387 | 770 | 72.5% | 69.9% | 66.9% | 58.7% | 7.5% | 19.7% | 3.6% / 5.2% | 1,790 / 300 |
| Stage / Outcome | All patches | (no-op) | |
|---|---|---|---|
| All resolved patches analyzed | 6,724 | 3,781 | 2,943 |
| No standalone extracted test selector in trajectory | 3,777 | – | – |
| Container-verified patches tested with | 2,945 | – | – |
| Baseline fails ( ; left untouched) | 450 | – | – |
| Repeatably passing ( ; evaluated) | 2,495 | 1,468 | 1,027 |
| Method | Patches | Dropped | TP / FP | Prec. | Recall | Post | Passes |
|---|---|---|---|---|---|---|---|
| DRA + (all) | 6,724 | 4,047 | 1,507 / 2,540 | 37.2% | 55.5% | 0.953 | 80.7% |
| DRA + (2,495 cohort) | 2,495 | 1,220 | 269 / 951 | 22.0% | 45.3% | 0.960 | 80.0% |
| DRA + (sim.) | 6,724 | 3,449 | 1,775 / 1,674 | 51.5% | 65.3% | 0.962 | 85.4% |
| DRA + (sim.) | 6,724 | 3,305 | 1,899 / 1,406 | 57.5% | 69.9% | 0.969 | 87.4% |
| DRA + audit | 2,344 | 229 | 155 / 74 | 67.7% | 27.1% | – | 98.3% |
| DRA + (cumulative) | 6,724 | 2,703 | 2,703 / 0 | 100.0% | 99.5% | 0.998 | 100.0% |
AI Coding Agents
AI coding agents use language models and software tools to plan, edit, test, and maintain code with varying levels of autonomy.
See all 365 papers