Amir M. Ebrahimi, Mohammed Mehedi Hasan, Aaditya Bhatia, Gopi Krishnan Rajbahadur, Ahmed E. Hassan
6 min
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.
Alex: And the models still struggled, even with all that complexity stripped away?
Sam: They did. The models often failed in two ways. Some deleted too much, removing code that was still needed. But more commonly, they added new code instead of just finishing the removal—as if they couldn't resist the urge to write something. That points to what the researchers call an "additive skew." These models are trained on enormous amounts of text and code where the goal is almost always to produce something. Writing, generating, completing. Deletion is the opposite of that, and it seems to run against the grain of how they've learned to operate.
Alex: So it's not just a technical glitch—it's more like a deeply ingrained habit?
Sam: That's a fair way to put it. The researchers tested this further using what they call a "diagnostic ladder." They gave the models progressively more help—first pointing to the general region of code to remove, then the specific lines. Even with that level of guidance, some models still failed by over-editing or adding unnecessary logic. The problem isn't that they can't find the right code. It's that the act of deleting feels unnatural to them.
Alex: That's a meaningful concern if we want AI to help maintain large, complex software systems. Is there any evidence this can actually be fixed?
Sam: There is, and it's encouraging. In a pilot study, the researchers added a small amount of deletion-focused training to one of the models—essentially teaching it that removing code is a valid and valuable action, not just a last resort. The model became noticeably better at clean removal, and that improvement carried over to tasks it hadn't specifically practiced. So deletion isn't beyond these models. It's just a skill that hasn't been prioritized in how they're built and trained.
Alex: You mentioned earlier that some models "over-delete" when they try to fix this. Are we just trading one error for another?
Sam: That's a significant observation from the pilot study. While incomplete deletion dropped, the models started removing too much code in some cases. It suggests that knowing when to delete and knowing exactly where to stop are actually two distinct skills. The model is learning to act, but it hasn't yet mastered the precision of knowing what to leave alone. It's a bit like learning to use a scalpel—first you have to overcome the hesitation to cut at all, and then you have to learn the boundaries.
Alex: So it's not just about getting them to remove code. It's about teaching them the nuance of what to leave alone.
Sam: Precisely. And that nuance matters enormously in real software. A codebase that's been "fixed" by an AI that deletes too aggressively can be just as broken as one that's been left cluttered. The researchers' broader point is that subtraction needs to be treated as a first-class skill—something worth training for explicitly—if we want these models to genuinely maintain and refactor software, rather than just patch it and move on.
Alex: It's a useful reminder that the way we measure success shapes the behavior we get. If we only reward AI for making programs run, we shouldn't be surprised when it ignores everything else. Thanks for listening to ResearchPod.