To Add Is Machine, To Delete Is Human: Measuring and Mitigating Deletion Avoidance in LLM Code Editing
Abstract
Large language models increasingly write and repair production code, yet evidence is mounting that their test-passing patches leave codebases harder to maintain. We identify one concrete source: deletion avoidance, the systematic tendency to retain code that an intended edit requires removing. Across the five leading models on the official SWE-bench Verified leaderboard, deletion recall against the developer patch reaches at most 71.7% even on tasks all five solve, and models reach the right file for over 92% of required deletions but cut the exact line in under 52% of cases. Instead, 29.0% of passing patches wrap the targeted code in a guard or fallback, a pattern we call Guard-and-Go. Such patches pass because the original tests rarely check removal: when we retrofit 34 Verified tasks with tests that fail if the targeted code remains, four frontier models spanning closed and open weights fall from 63.2% to 41.9%. Because real repairs mix removal with addition, we curate CanItDelete, a benchmark of 200 tasks mined from real commits whose entire required edit is deletion. Even with the addition work gone, the best model still fails one task in five, and smaller open models fall to 18.0%. We then ablate GPT-5.6 Sol under four cumulative prompts; success moves little until we supply the exact lines, which nearly eliminate incomplete deletion yet raise success only to 80.5% because the model then deletes beyond the spans or adds code instead. Finally, through a pilot study we show one potential fix: teaching deletion during post-training reduces deletion avoidance and improves broader code-editing performance, suggesting the behavior is undertrained rather than beyond reach.
Community
A lot of AI-generated patches feel like slop because frontier models still struggle with something we barely consider a task at all for a software engineer: ๐ฑ๐ฒ๐น๐ฒ๐๐ถ๐ป๐ด ๐๐ต๐ฒ ๐ฟ๐ถ๐ด๐ต๐ ๐ฐ๐ผ๐ฑ๐ฒ ๐ฎ๐ป๐ฑ ๐๐๐ผ๐ฝ๐ฝ๐ถ๐ป๐ด.
We built CanItDelete, 200 tasks from real commits where deletion is the entire edit. No rewiring. No replacement logic. It diagnoses retention, partial deletion, over-deletion, and boundary errors.
Claude Opus 4.8 still failed 21% of tasks, GPT-5.6 Sol 26%, and GLM-5.2, Kimi K2 Thinking, MiniMax-M3, and DeepSeek-V4-Pro roughly one in three. Most failures left required code behind.
Giving models the exact lines helped, but exposed another problem. Claude reached 97.7%, while GLM-5.2 still failed 12%, GPT-5.6 Sol 18%, and Qwen3-235B 42%. For some models, better localization traded incomplete deletion for over-editing.
In real repository work, this becomes ๐๐ช๐๐ง๐-๐๐ฃ๐-๐๐ค. Instead of removing obsolete logic, models keep it live behind a guard or fallback, often as the default path for inputs the guard does not catch. Across five leading SWE-bench Verified submissions, 29% of passing patches did this.
That can pass tests. It is not merge-ready.
When we required the code to actually be gone on deletion-heavy tasks, resolution fell 21.3 points, and a third of accepted patches failed.
The hopeful result is that deletion can be taught. Adding just 0.7% deletion-focused data cut incomplete deletion by 13.9 points and improved SWE-bench Verified by 5.3 points. Over-deletion also rose, showing that completing a removal and stopping at its boundary are distinct skills.
๐๐ณ ๐ฐ๐ผ๐ฑ๐ถ๐ป๐ด ๐ฎ๐ด๐ฒ๐ป๐๐ ๐ฎ๐ฟ๐ฒ ๐๐ผ ๐ฝ๐ฟ๐ผ๐ฑ๐๐ฐ๐ฒ ๐บ๐ฒ๐ฟ๐ด๐ฒ-๐ฟ๐ฒ๐ฎ๐ฑ๐ ๐ฐ๐ผ๐ฑ๐ฒ, ๐๐ฒ ๐ป๐ฒ๐ฒ๐ฑ ๐๐ผ ๐๐ฟ๐ฎ๐ถ๐ป ๐๐ต๐ฒ๐บ ๐น๐ถ๐ธ๐ฒ ๐๐ผ๐ณ๐๐๐ฎ๐ฟ๐ฒ ๐ฒ๐ป๐ด๐ถ๐ป๐ฒ๐ฒ๐ฟ๐. ๐ก๐ผ๐ ๐ผ๐ป๐น๐ ๐๐ต๐ฎ๐ ๐๐ผ ๐๐ฟ๐ถ๐๐ฒ, ๐ฏ๐๐ ๐๐ต๐ฎ๐ ๐บ๐๐๐ ๐ป๐ผ ๐น๐ผ๐ป๐ด๐ฒ๐ฟ ๐ฒ๐ ๐ถ๐๐.
This is an automated message from the Librarian Bot. I found the following papers similar to this paper.
The following papers were recommended by the Semantic Scholar API
- SWE-Touch: Benchmarking Coding Agents When Users Touch the Code (2026)
- A Preliminary Study on Explaining Risk of Code Changes using LLM-Based Prediction Models (2026)
- DepRepair: LLM-Based Source-Code Repair for Dependency Breaking Changes (2026)
- IssueExec: A Test-Driven Approach for Localizing Software Engineering Issues (2026)
- DebugTracker: Lightweight Process Evidence for Classroom Debugging (2026)
- TestEvo-Bench: An Executable and Live Benchmark for Test and Code Co-Evolution (2026)
- Auditing Reward Hackability in Code RL Training Environments (2026)
Please give a thumbs up to this comment if you found it helpful!
If you want recommendations for any Paper on Hugging Face checkout this Space
You can directly ask Librarian Bot for paper recommendations by tagging it in a comment: @librarian-bot recommend
Get this paper in your agent:
hf papers read 2607.28887 Don't have the latest CLI?
curl -LsSf https://hf.co/cli/install.sh | bash Models citing this paper 0
No model linking this paper
Datasets citing this paper 0
No dataset linking this paper
Spaces citing this paper 0
No Space linking this paper
Collections including this paper 0
No Collection including this paper