Papers
arxiv:2607.28887

To Add Is Machine, To Delete Is Human: Measuring and Mitigating Deletion Avoidance in LLM Code Editing

Published on Jul 30
ยท Submitted by
Gopi Krishnan Rajbahadur
on Aug 4
Authors:
,
,
,
,

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

Paper submitter

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

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

Sign up or log in to comment

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

Cite arxiv.org/abs/2607.28887 in a model README.md to link it from this page.

Datasets citing this paper 0

No dataset linking this paper

Cite arxiv.org/abs/2607.28887 in a dataset README.md to link it from this page.

Spaces citing this paper 0

No Space linking this paper

Cite arxiv.org/abs/2607.28887 in a Space README.md to link it from this page.

Collections including this paper 0

No Collection including this paper

Add this paper to a collection to link it from this page.