Paper: 2611.34875 — How Much Do Coding Agents Over-Edit, and Why? An Empirical Study of Unneeded Edits in Repository-Level Agent Patches
Authors: Aakash Goel, Benjamin Steenhoek, Yu Hu
Categories: cs.AI, cs.SE
Reading scope: Original arXiv v1 HTML, including sections 1–7 and Appendices A–I. The complete 107,202-character extraction was read in section files, beyond the helper’s excerpt limit. Original HTML cells for Tables 1–21 were checked; Figures 1 and 3 were visually inspected. Bibliographic entries, external cited papers and implementation were not independently audited. Experiments were not reproduced.
The Problem
A date parser reports an error on an empty string, although the issue asks it to return “no date,” represented by None in Python. The agent fixes that case, but also adds a non-string input guard, inserts a debug log and renames a local variable. The tests pass. Which changes belong in the patch?
This is the paper’s illustrative running example, not one of its measured repair cases. Counting changed lines cannot distinguish the required empty-string check from the other edits. Nor does a green test run explain what the non-string guard does on inputs the tests never try (Appendix B.1).
The authors build Delta Residue Attribution, or DRA, to investigate that question. It replays a coding agent’s work, links each surviving patch block to the step that wrote it, then removes blocks individually and reruns checks. Their study separates patch size, test-relative necessity, behavioral changes and the origin of edits (§§1 and 3).
The distinction matters because a change can be unnecessary for one test suite while still implementing behavior the issue requires. The checker becomes part of the answer.
The Explanation
Give every surviving edit its own counterfactual
Start with the complete, passing patch. DRA splits its changed lines into units: contiguous blocks in a file, merging blocks separated by at most one unchanged line. A newly created or deleted file is one unit (§3.2; Appendix B.3).
For each unit, restore its original lines while leaving the rest of the final patch in place. Then run the task tests. If they fail, that unit is needed by those tests. If they still pass, it receives a test-unneeded label.
In the date-parser illustration, removing the empty-string check makes the reported bug return. Removing the guard, log or variable rename leaves the stated test passing. One of the four units is therefore needed for that check. This does not establish that every other unit violates the intended behavior (Appendix B.1).
DRA also replays recorded edits and verifies that the reconstructed final files match the submitted patch. Each surviving unit is attributed to the latest step that wrote or deleted any of its lines. Rules and a model judge label the introducing step as exploration, reproduction, probing, fixing, refinement or cleanup (§§3.2–3.3).
An experiment that was deleted before submission contributes no final unit. An exploratory edit later rewritten as part of the solution is attributed to its later writer. The method traces surviving code, rather than infer the agent’s private reasons.

Original Figure 1, rendered from its SVG. It uses the paper’s illustrative date-parser example; the measured distribution of edit origins is discussed below.
A larger patch can contain several kinds of work
The main study uses GitHub Copilot CLI with 18 models. It analyzes 6,728 resolved SWE-bench Verified patches and 932 resolved DeepSWE patches. The total of 7,660 counts trajectories across models, not distinct bugs. The first benchmark contains Python tasks; the second covers longer tasks in several languages (§4.1).
On SWE-bench Verified, the median model changes 2.33 times the developer patch’s lines. Excluding test files, the ratio is 1.09. Among the paper’s extra-edit units, 61% are test-file edits, 13% documentation and 21% code (§§5.1–5.2; Figure 3).
That bucket deliberately combines ungraded test edits with units the task tests call unneeded. SWE-bench grading resets test files, so an agent’s new tests cannot establish their own value through the same necessity check. Calling all of those test edits useless would misread the measurement.
DRA’s primary code score is the needed fraction of code units in a patch, averaged across patches. Under task tests, it is 0.887 for agents versus 0.864 for developer patches on SWE-bench Verified. These are unit fractions, not shares of changed lines. Eleven of the 18 models have a significantly higher fraction than their matched developer baseline; four show no detected difference, which does not establish equivalence (§5.1; Appendix C.1).
The pattern changes on DeepSWE. Code accounts for 58% of extra edits, and the reported mean necessity fractions are 0.797 for agents and 0.785 for developers. No model is significantly above its developer baseline. The benchmark and the matched comparisons matter; the SWE-bench result is not a general verdict on agent patches (§§5.1–5.2).
Added tests need a different measure of usefulness
To evaluate tests, the authors inject small artificial bugs into the agent-patched code and ask which test suites detect them. Across 1,962 evaluated mutants in 271 valid instances, the agent’s added or edited test units detect 68.1%, compared with 45.6% for the original tests in the touched files and 77.1% for the held-out task tests (§5.2; Appendix F.1; Table 16).
The reported 95% interval for the agent-test detection rate is 63.7–72.5%, from resampling instances. The result applies to this eligible mutation cohort and these injected changes. It measures fault detection, while the earlier removal test measures whether an edit is required to pass a particular suite.
A test can therefore add value even when benchmark grading does not count its presence toward resolving the original issue. The code guard raises the next question: what happens when the task tests miss a behavior change?
A stronger check reverses the developer comparison
The authors generate differential probes for code that the task tests call unneeded. Each probe runs on the full agent patch, the patch with one unit removed and the developer-patched repository. Comparing their outputs helps separate an untested fix from an extra behavioral change (§3.4; Appendix C.1).
Of 3,559 probed test-unneeded agent code units, 3,151 change behavior when reverted: 88.5%, with a 95% Wilson interval of 87–90%. A behavioral difference alone does not establish whether the original edit was wanted.
For 1,263 units, the developer version matches the full agent patch rather than the reverted version. Those units provide evidence of an untested, developer-aligned fix. For 1,586, the developer version matches the reverted patch, giving evidence of an extra behavioral change. Another 408 show no difference on the probes; the remaining cases are mixed or match neither version (Appendix C.1; Table 7).
Return to the date parser. An empty-string test can stay green after removing a guard, while nearby inputs behave differently. Comparing the full and reverted behavior with the developer fix supplies evidence the original test lacked. It still uses the developer patch as a reference, rather than a complete statement of user intent.
The strengthened check keeps task-required units and also counts untested, developer-aligned fixes as needed. The reported means change as follows (Appendix C.1):
| Necessity check | Agent mean code fraction | Developer mean code fraction | Agent minus developer |
|---|---|---|---|
| Task tests | 0.887 | 0.864 | +2.3 percentage points |
| Tests plus developer-aligned behavioral probes | 0.925 | 0.970 | −4.5 percentage points |
Both means rise, but the developer’s rises more. The comparison reverses. A claim that agents write a more necessary patch must say which behavior its checker can recognize.
The residue usually arrives with the fix
The illustrative parser leaves a guard and a log from probing. In the measured SWE-bench code residue, however, only 154 of 3,987 units, about 3.9%, are attributed to debug steps. Steps labeled Fix contribute 83%, and Refine 11% (§5.3; Appendix E.3).
This narrows the target for cleanup. Removing scratch scripts and debug logs would address little of the surviving code residue in these resolved trajectories. It does not prove that an in-loop cleanup policy would be ineffective: the paper did not run the proposed in-loop interventions, and attribution follows the last writer (§6; Appendices A and H).
Resolve rate also leaves this dimension partly hidden. Claude Sonnet 5 resolves 80.6% of attempted SWE-bench tasks, with a mean code necessity fraction of 0.922 on analyzed successful patches. Gemini 3.7 Flash resolves 81.4%, with a fraction of 0.789. Similar task completion can accompany different patch composition (§5.4; Appendix E.2).
Across the 18 models, the correlation between resolve rate and code necessity on SWE-bench Verified is −0.10, with no detected association. On DeepSWE’s 17-model analysis it is −0.59, with reported p = 0.01. These are associations between model-level measurements, not evidence that solving more tasks causes unnecessary edits (§5.4).
Visible-test pruning trades coverage for mistaken removals
The task’s held-out tests are not available to a deployed agent. The authors therefore evaluate cleanup using information it can have. A self-audit asks a model, or an available sibling, to justify each final diff block and drop what it cannot justify. A cumulative DRA variant instead removes a unit when the agent’s own test command and the existing regression tests still pass (§5.5; Appendix D.5).
Pruning first requires a standalone test command that passes twice with the same nonzero test count. It also keeps at least one code unit. Only 2,495 of 6,724 patches meet the repeatable-command condition; 1,468 of those have one code unit and are no-ops for this procedure (Appendix G.1; Table 20).
Against the strengthened necessity labels, the results are (§5.5; Table 1):
| Cleanup analysis | Patches analyzed | Precision of removed code | Recall of unnecessary code |
|---|---|---|---|
| Model self-audit | 6,345 | 65.7% | 35.5% |
| Cumulative pruning with agent and regression tests | 2,495 | 46.3% | 67.3% |
Precision asks how many removed units were judged unnecessary. Recall asks how many of the judged-unnecessary units were removed. The analyses use different eligible cohorts, so this is not a fully paired comparison.
Visible-test pruning finds more of the labeled excess, while more of its removals are mistakes. 89.1% of its patches still pass the task tests afterward. All were resolved before pruning, so green visible tests did not preserve every completed repair (§5.5; Appendix D.5).
Stopping at the first green agent-test run has limited effect on necessity. On 3,031 graded patches that kept editing after that run, the early version still passes task tests in 97.3%, but its code necessity fraction changes only from 0.700 to 0.710. Much of the residue was already present (§5.5).
The useful output is now an audit with a stated checker and a remaining uncertainty, rather than a bare count of added lines.
Core Concepts
Test-unneeded describes a counterfactual under a checker. It says that removing the date-parser guard left the selected tests passing. To decide whether the guard belongs, inspect its behavior and the intended input contract. The strengthened probe experiment shows why that extra step can change the answer.
The unit sets the resolution of the judgment. A block can contain both the empty-string fix and unrelated changes. If removing the block breaks tests, the score cannot separate its individual lines. New files count as one unit, and a lone code unit is treated as needed by the grading protocol.
Provenance identifies a surviving edit’s last writer. A probing change later rewritten during a fix moves into the fix attribution. The role statistics help locate where surviving edits enter final patches; they do not expose the agent’s thoughts or establish the effect of a cleanup policy.
These distinctions keep the metric useful without asking it to answer a broader question than its evidence permits.
The Insight
A test-unneeded label gives a reviewer a concrete question: what changes when this block is removed, and which version matches the required behavior? Its value lies in directing that investigation. It does not by itself settle what to delete.
Patch size, task completion and necessity answer different parts of the review. The checker and its coverage determine how far a necessity comparison can travel.
A Critical Reading
The study grades developer patches with the same procedure, supplements task tests with executed probes and reports changes to its preregistered plan. Those choices expose an important limit rather than hide it: changing the behavioral criterion reverses the headline developer comparison (Appendices A and C).
The probes and role labels rely on models. A second model agreed on 84.4% of 10,000 sampled role labels, but there was no human role audit. The proposed human study of whether reviewers would remove a unit remains unfinished; agreement between model judges cannot establish that judgment (§4.1; Appendix B.4–B.5).
The population also matters. These are successful trajectories under the main Copilot CLI harness. Exact replay excludes some SWE-bench trajectories, and 12.7% of DeepSWE code units lack provenance. Supplementary harness comparisons use final patches and do not generalize the role attribution to those harnesses (§6; Appendix D.4).
Single-block removal gives a tractable measure, with limits from merged edits and dependencies between blocks. Even a patch where every individual block is required need not be the smallest accepted patch overall. The paper checks alternative unit weightings and multi-unit cohorts, but neither those controls nor a stronger finite probe set supplies a complete specification (§6; Appendix B.2 and D.4).
DRA is useful as a way to ask and test more precise review questions. Human acceptance, complete behavior preservation and results on unsuccessful trajectories remain outside what this study establishes.
What You Can Use
For the date-parser repair, review code, tests and documentation separately. Give each code block a reason tied to the issue or the intended input behavior. When a removal keeps tests green, compare full and reverted behavior on relevant cases before deciding which version to keep.
A model diff audit can supply candidates for that inspection. If you prune, retest the cumulative result against both the issue and regressions, then check behavior the visible suite may miss. Record the checker and the unresolved intent questions alongside the result. The paper’s pruning experiment shows why a shorter passing patch still needs that review.
论文: 2611.34875 — 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
分类: cs.AI, cs.SE
阅读范围: 阅读原始 arXiv v1 HTML,包括正文第1–7节及附录A–I。
完整提取共107,202字符,分节阅读,未采用助手函数限额后的首尾节选。
核对表1–21的原始HTML单元格,目视检查图1、3。
未独立核查参考文献、外部论文和实现代码,未复现实验。
问题
一个日期解析函数碰到空字符串就报错,需求却是返回“没有日期”,在Python里写作None。
智能体修好了这一处,还加了输入类型检查、调试日志,顺手改了局部变量名。
测试全过了,哪些改动该留在补丁里?
这是论文用来解释方法的示例,并非某个实测修复案例。 只数改了多少行,分不清空字符串检查与其余改动。 测试亮绿灯,也说不清新增的类型检查会怎样处理测试没碰过的输入(附录B.1)。
作者做了DRA,改动残留归因。 它重放智能体的编辑过程,找出最终补丁里每块改动由哪一步写下,再逐块撤回、重跑检查。 研究因此能把补丁大小、测试意义上的必要性、行为变化,以及改动来源分开看(第1、3节)。
一块改动对某套测试并非必要,仍可能实现需求要求的行为。 用什么来检查,就成了答案的一部分。
翻译
给每块留下的改动做一次“撤掉会怎样”
先拿到完整、已经通过测试的补丁。 DRA把每个文件里连续改动的行分成单元,两块之间只隔一行未改代码时会合并;新建或删除整个文件,算一个单元(第3.2节;附录B.3)。
每次只把一个单元恢复到原样,保留其余最终改动,再跑任务测试。 撤掉后测试失败,这个单元就是这套测试需要的;仍然通过,则标为“测试不需要”。
在日期解析示例里,撤掉空字符串检查,原来的错误就回来了。 撤掉类型检查、日志或变量改名,给定测试仍然通过。 因此四块改动里只有一块对这项检查必要,但这还没证明其余三块都违背需求(附录B.1)。
DRA同时重放记录下来的编辑,确认最终文件与提交的补丁完全一致。 每个留下的单元,归到最后写入或删除其中任意一行的那一步。 规则和模型判别器再把这一步分为探索、复现、试探、修复、修订或清理(第3.2–3.3节)。
提交前已删除的实验脚本,不会留下最终单元。 试探时写下、修复时又改过的代码,归给后一次写入。 这套方法追的是最终代码的来路,没有直接读出智能体为什么这么想。

原论文图1,由原始SVG渲染。图中采用日期解析的说明示例,实测改动来源的分布见后文。
补丁变大,里面可能装了几种工作
主实验使用GitHub Copilot CLI和18个模型,分析6,728个已解决的SWE-bench Verified补丁,以及932个已解决的DeepSWE补丁。 合计7,660条是跨模型的轨迹数,并非不同错误的数量。 前者是Python任务,后者包含多种语言、更长的开发任务(第4.1节)。
在SWE-bench Verified上,中位模型改动的行数是开发者的2.33倍;去掉测试文件后,比值为1.09。 论文所归入“额外改动”的单元中,61%来自测试文件,13%是文档,21%是代码(第5.1–5.2节;图3)。
这里的“额外改动”,特意把未评定必要性的测试改动,与任务测试判为不需要的单元放到一起。 SWE-bench评测会重置测试文件,所以智能体新写的测试,无法靠同一种撤回检查体现价值。 把这些测试都叫作没用,就读错了指标。
DRA主要看的代码分数,是一个补丁里必要代码单元所占的比例,再对补丁取平均。 只用任务测试时,SWE-bench Verified上的智能体平均为0.887,开发者为0.864。 这是改动块的比例,不是修改行数的比例。 18个模型里,11个显著高于各自匹配的开发者基线;4个未检测出显著差异,这不等于已经证明两者相同(第5.1节;附录C.1)。
换到DeepSWE,代码占额外改动的58%。 论文报告的必要性均值是智能体0.797、开发者0.785,但没有模型显著高于自己的开发者基线。 任务集和匹配比较不能省掉,SWE-bench上的结果还不是对所有智能体补丁的判决(第5.1–5.2节)。
新测试值不值,要另换一种检查
作者往智能体修改后的代码里注入小型人工错误,检查各套测试能抓住多少。 在271个有效实例、1,962个受测变异体上,智能体新增或修改的测试单元抓住68.1%,原来被修改测试文件中的测试抓住45.6%,保留的任务测试抓住77.1%(第5.2节;附录F.1;表16)。
智能体测试检出率的95%区间为63.7–72.5%,由按实例重复抽样得到。 结论针对这批符合条件的实例和注入错误。 它测的是发现错误的价值,之前逐块撤回测的则是某项改动对通过指定测试是否必要。
所以,新测试即使不影响原任务的评分,也可能有用。 接下来轮到类型检查:任务测试漏掉行为变化时,又该怎样判断?
检查加深,开发者比较就翻了过来
对任务测试判为不需要的代码,作者生成差异行为探针。 同一段探针分别在完整智能体补丁、撤掉一个单元后的补丁,以及开发者修改后的版本上运行。 比较输出,能给“未被测试覆盖的修复”与“额外行为变化”提供不同证据(第3.4节;附录C.1)。
在3,559个受探查的测试不需要单元里,3,151个撤回后会改变行为,约88.5%,95%威尔逊区间为87–90%。 发生行为差异,本身还没有说明原改动该不该留。
其中1,263个,开发者版本与完整智能体补丁表现相同,而与撤回版本不同,支持它们是未被任务测试覆盖、却与开发者一致的修复。 另有1,586个,开发者版本与撤回后的补丁相同,支持原单元带来了额外行为。 408个在探针上未见差异,其余证据混合,或开发者版本与两边都不同(附录C.1;表7)。
回到日期解析,删掉类型检查,空字符串测试照样通过,附近输入的行为却可能变化。 把完整版本和撤回版本的行为与开发者修复比较,就多了一层原测试没有提供的证据。 但开发者补丁仍是参照,不能代替对用户意图的完整说明。
增强检查保留任务测试要求的单元,也把未受测试覆盖、行为与开发者一致的修复算作必要。 均值随之变化(附录C.1):
| 必要性检查 | 智能体代码必要比例均值 | 开发者均值 | 智能体减开发者 |
|---|---|---|---|
| 任务测试 | 0.887 | 0.864 | +2.3个百分点 |
| 测试加开发者行为对齐探针 | 0.925 | 0.970 | −4.5个百分点 |
两边的分数都升了,开发者升得更多,比较方向因此翻转。 说智能体写的补丁更“必要”,还得说明检查者能认出哪些行为。
多余代码,通常跟着修复一起留下
说明示例里,试探阶段留下了类型检查和日志。 可实测SWE-bench代码残留中,只有3,987个单元里的154个,约3.9%,归到调试步骤。 标为修复的步骤贡献83%,标为修订的贡献11%(第5.3节;附录E.3)。
这让清理的目标变得具体。 在这些已解决任务的最终补丁里,只清掉临时脚本和调试日志,能碰到的代码残留很少。 但这没有证明边执行边清理一定无效:论文没有运行拟议的循环内干预,而且归因用的是最后写入者(第6节;附录A、H)。
任务解决率也会遮住这个维度。 Claude Sonnet 5解决80.6%的SWE-bench尝试任务,受分析的成功补丁中,代码必要比例为0.922。 Gemini 3.7 Flash解决81.4%,必要比例却是0.789。 接近的完成率,可以伴随不同的补丁构成(第5.4节;附录E.2)。
18个模型在SWE-bench Verified上的解决率与代码必要性的相关系数为**−0.10**,未检测出关联。 DeepSWE的17模型分析中为**−0.59**,报告p = 0.01。 这是模型层面指标之间的相关,还不能推出“解决更多任务导致更多不必要改动”(第5.4节)。
用可见测试裁剪,删得更多也会删错更多
部署时,智能体拿不到任务保留的测试。 作者因此用它能拿到的信息试清理:自查让原模型或可用的同系列模型逐块说明最终改动的理由,删掉无法说明的部分;累积裁剪则在撤回一个单元后,确认智能体自己的测试与既有回归测试仍然通过(第5.5节;附录D.5)。
裁剪先要求能提取出独立测试命令,并连续两次通过,得到相同、非零的通过测试数;也不会删空所有代码单元。 6,724个补丁中,2,495个满足命令可重复通过的条件。 其中1,468个只有一个代码单元,这项程序对它们不做删除(附录G.1;表20)。
以增强检查的必要性标签作参照,结果如下(第5.5节;表1):
| 清理分析 | 分析补丁数 | 删除代码的精确率 | 不必要代码的召回率 |
|---|---|---|---|
| 模型自查 | 6,345 | 65.7% | 35.5% |
| 用智能体测试与回归测试累积裁剪 | 2,495 | 46.3% | 67.3% |
精确率问“删掉的单元里,有多少被参照检查判为不必要”;召回率问“参照检查判为不必要的单元里,删掉了多少”。 两项分析使用不同的合格子集,并非完全逐例配对的比较。
可见测试裁剪找出了更多被标记的多余代码,但删除里也有更多误判。 裁剪后,89.1%的补丁仍能通过任务测试。 它们在裁剪前都已经解决任务,所以可见测试继续亮绿灯,并没有保住每一次完成的修复(第5.5节;附录D.5)。
第一次自有测试全过就停,也没有明显提高必要性。 对3,031个首次全绿后仍继续编辑、并完成评分的补丁,提前停止版本仍有97.3%通过任务测试,但代码必要比例只从0.700变为0.710。 不少残留在第一次亮绿灯时就已经存在(第5.5节)。
现在,值得带走的是一份注明检查方法、保留未知问题的审查记录,而不仅是多加了多少行。
核心概念
“测试不需要”,说的是一种受检查条件约束的反事实。 它只说明撤掉日期解析的类型检查后,选定测试仍然通过。 要决定这块检查该不该留,还得看行为与预期输入约定。 增强探针实验说明,补上这一层证据,答案可能会变。
单元决定判断能看多细。 一块里可能同时装着空字符串修复和无关改动。 整块撤回导致测试失败,指标也分不开其中每一行。 新文件只算一块;只剩一个代码单元时,评分协议会把它视为必要。
来路追到的是留下代码的最后写入者。 试探代码若在修复时又被改过,就移到修复归因里。 角色统计能帮助定位最终改动从哪一步进入,却没有揭开智能体的想法,也没有直接证明一种清理策略的效果。
守住这几项区分,指标就能有用,同时不越过证据能回答的问题。
洞见
“测试不需要”给审查者一个具体问题:删掉这块会改变什么行为,哪个版本符合需求? 标签的价值,是把检查引到这里,并没有独自决定该删什么。
补丁大小、任务完成和改动必要性,各回答审查的一部分。 检查方法及其覆盖范围,决定必要性比较能推到哪里。
博导审稿
研究用同一种程序评定开发者补丁,用实际运行的探针补充任务测试,也交代了相对预注册计划的变化。 这些选择让一个重要边界露出来:换了行为判断标准,最醒目的开发者比较就翻转了(附录A、C)。
探针和角色标注依赖模型。 第二个模型对一万个抽样步骤的角色标签有84.4%一致率,但没有人工角色审计。 “审查者会不会删掉这个单元”的人工研究仍未完成,模型判别器彼此同意,还不能证明人的判断(第4.1节;附录B.4–B.5)。
样本范围也很重要。 主实验看Copilot CLI下已成功的轨迹,精确重放要求排除了一部分SWE-bench轨迹,DeepSWE有12.7%的代码单元缺少来路归因。 其他执行框架的补充比较使用最终补丁,不能把角色来源的结论一起推广过去(第6节;附录D.4)。
逐块撤回提供了可执行的检查,也受合并改动和块间依赖限制。 即使每块单独撤掉都不行,也未必已经得到整体最小的合格补丁。 论文检查了别的单元权重和多块补丁子集,可这些控制与有限的增强探针,都不能补成完整需求规格(第6节;附录B.2、D.4)。
DRA适合把审查问题问得更准,并用实验检查。 人会不会接受补丁、行为是否完整保留、失败轨迹会怎样,仍超出这项研究已经建立的结论。
启发
日期解析修复里,可以把代码、测试、文档分别审查。 每一块代码,都说明它与问题或预期输入行为的关系。 撤回后测试仍过,就在相关输入上比较完整版本与撤回版本的行为,再决定留哪一边。
模型自查可以提供值得继续检查的候选改动。 若做裁剪,要重测累积删除后的整体结果,同时检查原问题、回归行为,以及可见测试可能漏掉的部分。 把检查方法和仍不明确的意图问题一起记下来。 论文的裁剪实验说明,补丁变短、测试通过之后,这项审查仍然有用。