How Much Do Coding Agents Over-Edit, and Why? An Empirical Study of Unneeded Edits in Repository-Level Agent Patches
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.
Paper Prompts
Sign up for free to create and run prompts on this paper.
Explain it Like I'm 14
1. What is this paper about?
This paper studies how much coding agents—AI systems that edit software—change when fixing a programming problem.
A good fix should solve the problem without changing unrelated parts of the project. When an agent changes more than necessary, this is called over-editing.
For example, imagine a program has a three-line bug. An agent might fix it by changing those three lines, but it might also rewrite 50 other lines, add unnecessary code, or create many extra files. Even if all the tests pass, this larger change can be harder for programmers to understand and review.
The paper asks:
Do AI coding agents really add unnecessary code, and where does that extra code come from?
The researchers created a method called Delta Residue Attribution, or DRA, to investigate this question.
2. What questions did the researchers ask?
The study focused on five main questions:
- How much do AI agents over-edit compared with human developers?
- What kinds of extra edits do they make? For example, do they add code, tests, comments, or documentation?
- When do these unnecessary edits appear? Do they come from early debugging, the main fix, or later revisions?
- Do some AI models over-edit more than others?
- Can unnecessary code be removed automatically after the agent finishes?
The researchers also wanted to know whether a model that solves more tasks is automatically better at making small, focused changes.
3. How was the research carried out?
The data
The researchers examined:
- 7,660 successful AI coding sessions
- 18 different AI models
- Tasks from two programming benchmarks:
- SWE-bench Verified, containing Python software problems
- DeepSWE, containing longer tasks in languages such as Go, TypeScript, Python, Rust, and JavaScript
They also studied patches written by human developers so they could make a fair comparison.
The DRA method
The main method, DRA, works like checking a repaired bicycle by removing one part at a time.
First, the researchers divided each final code change into small pieces called units. A unit could be a group of nearby changed lines.
Then they:
- Replayed the AI agent’s actions to find out which step created each unit.
- Labeled each step as debugging, fixing, revising, or cleaning up.
- Removed one unit at a time.
- Ran the task’s tests again.
If removing a unit caused the tests to fail, that unit was considered needed. If the tests still passed, it was considered unneeded according to those tests.
The researchers measured this using necessity precision, or NP. In simple terms:
NP = 1.0means every unit appears to be needed.- A lower
NPmeans more changes could be removed while the tests still pass.
The researchers also used extra checks, called behavioral probes, to see whether supposedly unnecessary code changed what the program did on inputs that the normal tests did not cover.
Testing the added tests
The researchers also examined tests written by the AI agents. They inserted small artificial mistakes, called mutants, into the code and checked whether the new tests detected them.
This is similar to secretly putting small defects into a machine to see whether its safety checks notice them.
4. What did the researchers find?
AI patches were larger, but size was misleading
AI agents generally changed more lines than human developers.
On SWE-bench Verified, AI patches changed about 2.33 times as many lines as developer patches. However, much of the extra material was not ordinary program code:
- 61% of the extra edits were tests
- 13% were documentation
- 21% were code
- 5% were comments or formatting
This means a large patch is not automatically a bad patch. Some extra tests and explanations may be useful.
Most AI-written code was necessary
Although AI patches were larger, most of their code was needed for the task.
On SWE-bench Verified:
- AI code had an average necessity score of 0.887
- Developer code had a score of 0.864
This means that, according to the study’s tests, many AI models left less unnecessary code than human developer patches.
Out of the 18 models:
- 11 models left less unnecessary code than the developer baseline
- 4 models showed no clear difference
- 3 models, all Gemini Flash versions, left more unnecessary code
On DeepSWE, AI agents and developers were roughly similar.
Overall, about 11% of an AI patch’s code units were unnecessary. Importantly, extra behavioral checks suggested that 89% of these unnecessary code units changed how the program behaved. They were not merely harmless decorations.
For example, unnecessary code might make the program raise an error, ignore an error, or behave differently on an unusual input.
Extra code usually came from the main fix, not debugging
The researchers expected that unnecessary code might mostly be leftover debugging material, such as temporary print statements or experimental code.
That was not what they found.
Only about 4% of unnecessary code units came from debugging steps. Instead:
- Fixing steps created 83% of the unnecessary code
- Revision steps created about 11%
- Debugging steps created only 154 of 3,987 unnecessary code units
This suggests that agents usually introduce extra code while trying to construct the actual solution, not because they forget to remove temporary experiments.
Better at solving tasks did not always mean less over-editing
The study found no strong connection between:
- how often a model solved tasks, and
- how little unnecessary code it produced
On one benchmark, some models that solved many tasks still made relatively bloated changes. On DeepSWE, models with higher success rates sometimes left more unnecessary code.
So there are at least two different skills:
- Solving the problem
- Solving it with a focused, minimal change
A model can be good at one without being equally good at the other.
AI-written tests were sometimes useful
The tests added by agents caught about 68% of the artificial bugs created by the researchers.
This was better than ordinary regression tests in the same files, which caught about 46%. However, the task’s official tests performed better, catching about 77%.
The AI-created tests were still valuable because they found some bugs that the official tests missed. About 5% of all artificial bugs were caught only by the new or strengthened AI tests.
This means that extra tests should not automatically be considered wasteful.
Automatic cleanup helped, but was imperfect
The researchers tried two main ways to remove unnecessary code.
Asking the AI to check its own changes
The agent was asked to explain why every part of its patch was needed and remove anything it could not justify.
This method was fairly careful: about 66% of the removed pieces really were unnecessary. However, it found only about 36% of all unnecessary code.
In other words, it avoided many mistakes but missed a lot of extra code.
Removing code when tests still passed
The researchers removed pieces of code whenever the agent’s tests and existing tests still passed.
This found about 67% of unnecessary code, nearly twice as much as self-auditing. However, it was less accurate: only about 46% of the removed pieces were truly unnecessary.
About 89% of the cleaned-up patches still passed the task tests, but some needed code was removed by mistake.
This shows the central difficulty: tests cannot check every possible situation. Code may look unnecessary because the tests do not use the behavior it provides.
5. Why is this research important?
The paper suggests that we should not judge AI coding agents only by whether they pass tests or how many lines they change.
A better evaluation should report at least two things:
- Resolve rate: How often does the agent solve the task?
- Code necessity: How much of its code appears to be needed?
This is important because two agents might solve the same number of tasks, but one may create much cleaner and safer patches.
The research also suggests several possible improvements:
- Train AI models to make smaller, more focused changes.
- Keep useful tests and documentation separate from unnecessary program code.
- Use automatic cleanup tools after an agent finishes.
- Improve tests so they check more possible program behaviors.
- Give programmers better information about which parts of a patch may be unnecessary.
However, the study has limitations. The meaning of “needed” depends on the tests being used. If the tests miss an important behavior, the study might wrongly label some useful code as unnecessary. The researchers also studied only successful patches and mainly used one coding-agent system.
Simple conclusion
AI coding agents often make larger patches than human developers, but large patches are not always bad. Many extra changes are tests or documentation, and most of the code written by the agents is needed.
Still, around one in ten code changes was unnecessary on average, and much of that code changed the program’s behavior. These extra changes usually appeared while the agent was writing the fix, not during early debugging.
The main lesson is that an AI agent should be judged not only by whether it solves a programming problem, but also by whether it solves the problem cleanly and changes only what is necessary.
Practical Applications
Immediate Applications
- Post-generation patch pruning in software engineering — Software development / DevOps
- The repository must have executable, sufficiently reliable tests.
- Reverting units independently must not obscure interactions among jointly necessary edits.
- The reported 46.3% precision and 67.3% recall indicate that automatic deletion should initially be advisory or gated by human approval.
- The method is most directly applicable to tools that can replay file-editing actions and run isolated test commands.
- Review prioritization for AI-generated pull requests — Software maintenance / Code review
- Necessity is oracle-relative and should not be treated as proof that a change is incorrect.
- Developer baselines or historical repository norms improve interpretation.
- Human reviewers remain necessary because the paper found that many test-unneeded changes can still be semantically desirable.
- Benchmark reporting beyond pass/fail accuracy — AI evaluation / Academic benchmarking
- Benchmarks must expose reproducible trajectories or at least reproducible final patches.
- The benchmark oracle must be documented, since test-only necessity can overestimate excess code.
- Comparisons should separate code edits from tests, documentation, configuration, and formatting changes.
- Training-data filtering and trajectory debloating — AI model training
- The oracle must be strong enough to avoid deleting useful but poorly tested behavior.
- Training should not optimize blindly for small patches, since the study found that added tests and documentation can be valuable.
- Unit granularity and repository-specific coding conventions affect the labels.
- Automated test-suite improvement — Quality assurance / Software testing
- Tests must be reviewed for flaky behavior, excessive coupling, and weak assertions.
- Mutation-testing results are proxies for real defect detection.
- Tests added to unneeded code may have lower value; the study found substantially weaker mutation detection in such code.
- Model and harness selection for enterprise coding agents — Industry procurement / Engineering governance
- Scores may vary by language, repository, harness, and test quality.
- Results from Copilot CLI, SWE-bench Verified, and DeepSWE should not be generalized directly to all development environments.
- Evaluation should include unsuccessful trajectories and production-like repositories, not only resolved tasks.
- Developer education and review guidance — Academia / Professional training
- The organization needs repository-specific definitions of acceptable tests, documentation, refactoring, and configuration changes.
- Human labels are still needed to validate whether DRA flags correspond to changes reviewers would actually remove.
- Personal and daily-life use of coding assistants — Individual developers / Education
- The user must have runnable tests or manually inspect behavior on representative inputs.
- Self-audit alone is incomplete: in the study it found only about 35.5% of unneeded code, despite relatively high precision.
Long-Term Applications
- Production-grade necessity-aware coding-agent harnesses — Software infrastructure / DevOps
- Reliable replay across shell commands, generated files, binary artifacts, and complex build systems.
- Dependency-aware unitization rather than independent contiguous-line blocks.
- Cumulative delta debugging capable of handling jointly necessary edits.
- Confidence estimates and rollback mechanisms when pruning causes regressions.
- Key dependency: the paper’s current one-unit-at-a-time procedure can misclassify interacting edits.
- Specification- and property-based patch validation — Formal methods / Software quality
- Properties must accurately represent intended behavior.
- LLM-generated probes require validation and may introduce oracle bias.
- Fuzzing and symbolic execution may be computationally expensive for large repositories.
- Human-calibrated “should remove” evaluation standards — Research / Policy / AI assurance
- Human annotators need clear criteria distinguishing unnecessary, optional, refactoring, documentation, and safety-related changes.
- Inter-rater agreement may be limited because semantic minimality is context-dependent.
- Developer patches should not be treated as universally optimal; they are useful calibration references, not ground truth.
- Risk-based routing of AI-generated patches — Enterprise governance / Regulated sectors
- Risk models must incorporate domain impact, not just patch minimality.
- A small patch can still introduce a severe vulnerability, while a large documentation or test patch may be low risk.
- Regulatory acceptance would require auditability, reproducibility, and evidence that pruning does not remove safety behavior.
- Minimality-aware model training and inference-time optimization — Machine learning research
- The training oracle must avoid rewarding under-implementation.
- Models need examples where additional tests or documentation are beneficial, not penalized indiscriminately.
- Improvements must be validated across languages, repositories, harnesses, and unsuccessful tasks.
- Cross-harness and cross-language agent certification — AI evaluation / Standards
- Trajectory formats and tool APIs must expose enough information for replay and provenance.
- The current study had incomplete provenance for a substantial share of DeepSWE patches and used one primary harness.
- Certification must control for task mix, language, test quality, and model capability.
- Continuous repository maintenance and legacy-code cleanup — Software maintenance / Platform engineering
- Historical behavior may be intentionally relied upon even when current tests do not cover it.
- Removing code from mature systems requires production telemetry, compatibility testing, and staged rollout.
- The method should be combined with security, performance, and API-compatibility analysis rather than used as a standalone cleanup tool.
- Interactive assistants for non-expert users — Daily life / Education
- The system must infer intended behavior from incomplete specifications.
- Non-expert users may over-trust necessity scores; interfaces should expose uncertainty and offer before/after examples.
- Safety-critical or privacy-sensitive actions should require explicit confirmation and sandboxed execution.
Glossary
- 1-minimality: A patch property in which removing any single unit causes the oracle to reject it. “ exactly when is 1-minimal”
- AUROC: Area under the receiver operating characteristic curve, measuring a classifier’s ability to distinguish positive from negative cases. “The DRA unneeded flag predicts outside-patch units with an AUROC of 0.718”
- Behavioral probe: A targeted input-and-output test used to determine whether code changes program behavior. “we also check unneeded code units with behavioral probes”
- Bootstrap confidence interval: An uncertainty interval estimated by repeatedly resampling observed instances. “with a 95\% instance-bootstrap CI (”
- Counterfactual removal: Evaluating necessity by hypothetically reverting a change and observing the result. “DRA measures necessity by counterfactual removal”
- Delta debugging: A systematic technique for minimizing a failure-inducing change set by repeatedly removing components. “It decides whether a unit is needed by reverting it and rerunning the task tests, in the tradition of delta debugging”
- Differential testing: Testing multiple program variants with the same inputs and comparing their outputs. “property-based differential testing”
- Edit distance: A measure of the number of operations required to transform one text or patch into another. “against 0.21 for edit distance”
- False drop: An incorrectly removed patch unit that was actually necessary for the desired behavior. “Most false drops are code units that implement behavior that neither the existing tests nor the agent's tests exercise.”
- FAIL_TO_PASS test: A test that initially fails and is expected to pass after the patch is applied. “The task-test oracle $O_{\mathrm{test}$ runs the SWE-bench FAIL_TO_PASS and PASS_TO_PASS tests”
- Harness: The execution framework that controls an automated coding agent, its tools, and its evaluation process. “We evaluate 18 models from four providers on SWE-bench Verified”
- Instance-bootstrap CI: A confidence interval calculated by resampling task instances rather than individual observations. “with a 95\% instance-bootstrap CI (”
- Line-level blame: Version-control-style attribution assigning each line to the operation that most recently wrote or deleted it. “recording line-level blame after every step”
- LLM judge: A LLM used to classify or evaluate artifacts produced during an experiment. “an LLM judge (GPT-6.1 Sol) labels the rest”
- MaxSMT: An optimization form of satisfiability modulo theories that seeks a highest-weight set of satisfiable constraints. “e.g., via MaxSMT”
- Mutation testing: Testing a test suite by inserting artificial faults and checking which faults the tests detect. “We use mutation testing”
- Necessity precision (): The proportion of patch units judged necessary by a specified oracle. “The share of needed units is the necessity precision ”
- Oracle: A procedure that determines whether a program state satisfies the required correctness condition. “An oracle accepts a state () if it passes some check.”
- PASS_TO_PASS test: A regression test that passes before the patch and must continue passing afterward. “The task-test oracle $O_{\mathrm{test}$ runs the SWE-bench FAIL_TO_PASS and PASS_TO_PASS tests”
- Patch provenance: Information tracing a patch unit back to the action or step that produced it. “Tracing Edits to Trajectory Steps: DRA”
- Patch residue: The subset of patch units that remain after the task succeeds but are not required by the evaluation oracle. “The unneeded units form the residue”
- Precision: The proportion of items identified as positive that are actually positive. “self-audit is precise (65.7\%)”
- Property-based testing: Testing based on automatically generated inputs satisfying specified properties rather than only fixed examples. “Property-based testing and LLM-generated differential tests”
- Regression test: A test intended to ensure that previously working behavior remains intact after changes. “the repository's regression tests”
- Resolve rate: The proportion of attempted tasks whose final patches pass the task tests. “The resolve rate of a model is the share of its attempted tasks whose final patch passes the task tests.”
- Recall: The proportion of all relevant items that a method successfully identifies. “finds 67.3\% at lower precision (46.3\%)”
- Repository-level coding agent: An automated programming system capable of modifying and testing multiple files within an existing software repository. “We study over-editing in repository-level patches”
- Semantic minimum: The smallest change in program meaning that satisfies a specification. “Semantic minimum & Smallest semantic change satisfying a specification”
- Spearman correlation: A rank-based statistic measuring the monotonic relationship between two variables. “The Spearman correlation between resolve rate and $NP_{\mathrm{code}$ is ”
- Task fixed effects: Statistical controls that account for variation associated with individual tasks. “task fixed effects leave the same three Gemini Flash models below developers”
- Task-test oracle: An oracle whose decision is based on the benchmark’s designated task tests. “We report necessity under $O_{\mathrm{test}$”
- Trajectory: The ordered sequence of actions and observations produced during an agent’s attempt to solve a task. “An agent produces a trajectory of actions and observations”
- Unit provenance: The attribution of an individual patch unit to the step that introduced or last modified it. “DRA has four steps: replay, unit provenance, step-role labeling, and necessity grading.”
- Unit granularity: The size or level of decomposition used to divide a patch into independently evaluated components. “The model effect survives controls for unit granularity and task selection”
- Upper bound: A value that is guaranteed to be at least as large as the quantity being estimated. “We therefore treat the share of unneeded units as an upper bound on true excess”
- Validity check: A condition used to determine whether an experimental result or input is suitable for analysis. “Over the 271 SWE-bench Verified instances that pass our validity checks”
- Working-tree state: The current contents of files in a repository during an editing trajectory. “executing the first actions of a task yields the working-tree state ”

