Everything K-culture — comebacks to K-beauty, straight to your inboxGet it in your inbox›
To Add Is Machine, To Delete Is Human: Measuring and Mitigating Deletion Avoidance in LLM Code Editing
arXiv:2607.288872026-07-29
AI coding models keep quietly leaving old code in place even when asked to delete it
Analyzing five top models on the SWE-bench Verified leaderboard, this study finds that test-passing patches still leave much of the developer's intended deletions in place. A new deletion-only benchmark, CanItDelete, shows even the best model fails one in five tasks. Adding a small amount of deletion-focused training data reduced this behavior and also improved other code-editing scores.
METAL MEDIA explanatory visual
Three-stage investigation of deletion avoidance
Evidence statusMeasured results reported
1. Real-repo patch comparisonCompared passing patches from five SWE-bench Verified models against developer patches, finding only 65-72% deletion recall and 29% of passing patches using Guard-and-Go
2. Testing the test suite's blind spotAdding deletion-sensitive checks to 34 tasks dropped pass rate from 63.2% to 41.9%, showing original tests rarely catch missing deletions
3. Deletion-only benchmarkCanItDelete's 200 tasks remove localization and addition confounds; best model reaches only 79.0%, and still fails 19.5% even given exact lines to delete
4. Diagnostic ladderCumulative hints (explicit instruction, region pointer, exact spans) show failures stem from missing boundary knowledge, not missing intent
5. Deletion-focused post-trainingAdding deletion examples equal to 0.7% of a 7B model's training tokens improved CanItDelete, SWE-bench Verified, and CanItEdit scores together
An explanatory diagram made by METAL MEDIA, not a figure supplied by the paper's authors.
What they did
The authors compared patches from five leaderboard models (GLM-4.6, GPT-5, Kimi-K2, Opus-4.5, Salesforce SAGE) on official SWE-bench Verified submissions against the human developer patch, finding mean deletion recall (the share of developer deletions the model also performs) of only 65.2% to 71.7% on 197 tasks all five models solved.
Models locate the correct file for over 92% of required deletions but remove the exact line in only 44.6% to 51.6% of cases, showing the failure is not localization but a reluctance to actually delete found code.
An LLM classifier found that 29.0% of passing patches follow a 'Guard-and-Go' pattern: the model keeps the developer-removed logic and wraps it in a new conditional or fallback path instead of deleting it.
Retrofitting 34 tasks with tests that specifically check whether the target code was deleted caused four frontier models' pass rate to drop from 63.2% to 41.9%, showing standard tests rarely catch missing deletions.
On CanItDelete, a new 200-task benchmark where the entire required edit is deletion, even the best model (Claude Opus 4.8) succeeded on only 79.0% of tasks, and even when given the exact lines to delete, GPT-5.6 Sol still failed 19.5% of tasks by deleting too much or adding code instead. Adding 12.8k deletion examples (0.7% of training tokens) to a 7B model's post-training mixture improved CanItDelete success by 13.9 points, and also raised SWE-bench Verified by 5.3 points and CanItEdit by 1.4.
Figure 1: An example of deletion avoidance in a solved SWE-bench Verified task. The developer patch removes a statement, while the model retains it under an ‘else’ guard.
Table 1: Mean deletion recall on 197 tasks all five models solve and 57 all five fail. δ denotes effect size.
Model
Failed (n=57)
Solved (n=197)
δ
GLM-4.6
24.0%
67.5%
0.532
GPT-5
29.9%
68.5%
0.485
Kimi-K2
19.8%
65.2%
0.543
Opus-4.5
30.4%
71.7%
0.504
Salesforce SAGE
27.5%
68.0%
0.501
Figure 2: Overview of CanItDelete benchmark construction, cumulative diagnostic modes, and the structural outcome taxonomy.
Table 2: Patch strategies among 2,358 classifier-labeled pairs. Share is overall frequency; pass rate is SWE-bench Verified resolution within each strategy. Table 12 (Appendix B) lists the ten Guard-and-Go forms.
Strategy
n
Share
Pass rate
Delete-and-Replace
1,197
50.8%
85.2%
Guard-and-Go
684
29.0%
72.2%
Non-reference alternative
477
20.2%
39.6%
Figure 3: Vanilla-mode success and failure composition across 12 models. Success is measured over 200 tasks; failure mechanisms are measured over each model’s failed tasks.
Table 3: Attempts passing the original suite and, among them, the deletion-sensitive check on 34 tasks per model. Drop is in percentage points (pp); each task is about 2.9 pp.
Passing attempts
Model
Tasks
Original suite
Original
suite
With deletion check
With deletion
check
Drop (pp)
Drop
(pp)
Original
suite
With deletion
check
Drop
(pp)
GPT-5.6 Sol
34
21 (61.8%)
15 (44.1%)
17.6
Opus 4.8
34
21 (61.8%)
14 (41.2%)
20.6
GLM-5.2
34
26 (76.5%)
18 (52.9%)
23.5
DeepSeek-V4-Pro
34
18 (52.9%)
10 (29.4%)
23.5
Overall
136
86 (63.2%)
57 (41.9%)
21.3
Figure 4: Diagnostic-ladder outcomes under increasingly precise deletion guidance. Four models use 200 tasks; Claude Opus 4.8 uses 173.
Table 4: 7B-model performance before and after deletion-augmented post-training. Values are three-run means (%); Δ is absolute percentage-point change. Over-deletion is a subset of complete-but-invalid edits.
CanItDelete outcome
Benchmark success
Succ.
Incomp.
Complete invalid
Over- deletion
SWE-b. Verified
EditBench
CanItEdit
Base
6.5
80.4
13.1
10.6
25.40
39.26
44.30
+Deletion
13.7
66.5
19.8
16.8
30.70
39.07
45.70
Δ
+7.2
−13.9
+6.7
+6.2
+5.30
-0.19
+1.40
Figure 5: File-, scope-, and exact-line overlap across all required deletions in the 197 tasks solved by all five models
Table 5: Model submissions selected from the official SWE-bench Verified repository. For each model family, we retained the latest submission using the OpenHands scaffold. The submission date is extracted from the leading YYYYMMDD component of the repository directory name.
Family
Selected model
Submission directory
Submission date
GLM
GLM-4.6
20250930_zai_ glm-4.6
September 30, 2025
GPT
GPT-5
20250807_ openhands_gpt5
August 7, 2025
Kimi
Kimi K2
20250716_ openhands_kimi_k2
July 16, 2025
Claude
Claude Opus 4.5
20251127_ openhands_ claude-opus-4-5
November 27, 2025
SAGE
Salesforce SAGE
20251103_ SalesforceAIResearch_ SAGE_OpenHands
November 3, 2025
Figure 6: Structural distributions across the 200 CanItDelete tasks.
Table 6: Mean per-task deletion precision and recall. A match requires the model-generated patch to delete the same base-commit source location as the official human patch.
Failed by all five (n=57)
Failed by all five
(n=57)
Solved by all five (n=197)
Solved by all five
(n=197)
Failed by all five
(n=57)
Solved by all five
(n=197)
Model
Precision
Recall
Precision
Recall
GLM-4.6
34.6%
24.0%
70.7%
67.5%
GPT-5
35.6%
29.9%
69.3%
68.5%
Kimi-K2
35.0%
19.8%
70.6%
65.2%
Opus-4.5
47.0%
30.4%
74.3%
71.7%
Salesforce SAGE
36.7%
27.5%
66.2%
68.0%
Table 7: Comparison of deletion recall between all-passed (n=197) and all-failed (n=57) eligible tasks for each evaluated model. Panel A reports the median and interquartile range (IQR). Panel B reports the Mann–Whitney U test with Holm-adjusted p-values and Cliff’s δ effect size.
All-passed
All-failed
Model
Median
IQR
Median
IQR
Salesforce SAGE
1.00
0.75
0.07
0.50
GLM-4.6
1.00
0.75
0.00
0.33
GPT-5
1.00
0.71
0.00
0.50
Kimi-K2
1.00
0.80
0.00
0.25
Opus-4.5
1.00
0.61
0.17
0.50
Table 8: Comparison of deletion precision between all-passed (n=197) and all-failed (n=57) eligible tasks for each evaluated model. Panel A reports the median and interquartile range (IQR). Panel B reports the Mann–Whitney U test with Holm-adjusted p-values and Cliff’s δ effect size.
All-passed
All-failed
Model
Median
IQR
Median
IQR
Salesforce SAGE
1.000
0.684
0.038
0.929
GLM-4.6
1.000
0.667
0.000
1.000
GPT-5
1.000
0.684
0.000
1.000
Kimi-K2
1.000
0.667
0.000
1.000
Opus-4.5
1.000
0.500
0.400
1.000
Table 9: Model-generated patch size relative to the corresponding developer patch for passing Guard-and-Go pairs. LOC is measured as the sum of added and deleted lines.
Model
Pairs
Model larger
Model
larger
Equal LOC
Equal
LOC
Model smaller
Model
smaller
Model
larger
Equal
LOC
Model
smaller
GLM-4.6
91
89 (97.80%)
0 (0.00%)
2 (2.20%)
GPT-5
120
58 (48.33%)
10 (8.33%)
52 (43.33%)
Kimi-K2
92
75 (81.52%)
3 (3.26%)
14 (15.22%)
Opus-4.5
91
30 (32.97%)
20 (21.98%)
41 (45.05%)
Salesforce SAGE
100
50 (50.00%)
14 (14.00%)
36 (36.00%)
Overall
494
302 (61.13%)
47 (9.51%)
145 (29.35%)
Table 10: Categories in the running taxonomy after each axial round. Each round covers five new pairs.
Round
Pairs coded
Added
Revised
Total
1
5
12
0
12
2
10
4
0
16
3
15
4
0
20
4
20
3
0
23
5
25
0
0
23
6
30
0
0
23
Table 11: Guard-and-Go structural subtypes identified in model-generated patches.
Subtype
Definition
Retained Path as Live Fallback
Guards the reported case but leaves logic deleted by the official patch as the default path, allowing non-matching inputs to continue executing the retained logic.
Special-Case Carve-Out Bypass
Adds a branch or relaxes a precondition for one input category while leaving the general resolution mechanism unchanged.
Missing-Element Existence Bypass
Checks for a required runtime element and returns a default value when it is absent instead of evaluating the retained logic.
Failure-Site Symptom Patch
Suppresses or compensates for the symptom at the failure site while leaving the producing control flow unchanged.
Exception Capture Bypass
Catches exceptions raised by retained logic and returns a default value instead of removing the underlying cause.
Post-Hoc Output Correction
Corrects an incorrect result after the buggy computation has already completed.
Missing-Functionality Injection
Introduces new logic or parameters to handle the reported case instead of adopting the restructuring performed by the official patch.
Upstream Reroute Around Retained Branch
Redirects problematic inputs away from a retained branch, leaving the obsolete branch as unreachable legacy logic.
Parallel Duplicate-Path Retention
Retains logic that the official patch consolidates while introducing an additional execution path that can also satisfy the behavior.
Value-Compatibility Shim
Conditionally restores a legacy constant or decoding behavior for a specific input.
Table 12: Distribution of the ten Guard-and-Go structural forms. Of the 684 Guard-and-Go pairs, the closed-source classifier assigned a subtype to 550 and abstained on the remaining 134. Share is computed over the 550 typed pairs, and pass rate is the proportion of pairs that SWE-bench Verified records as resolved.
Structural form
n
Share
Pass rate
Retained Path as Live Fallback
221
40.2%
68.3%
Special-Case Carve-Out Bypass
95
17.3%
52.6%
Missing-Element Existence Bypass
60
10.9%
81.7%
Failure-Site Symptom Patch
51
9.3%
66.7%
Exception Capture Bypass
43
7.8%
53.5%
Missing-Functionality Injection
35
6.4%
74.3%
Post-Hoc Output Correction
20
3.6%
80.0%
Upstream Reroute Around Retained Branch
10
1.8%
90.0%
Parallel Duplicate-Path Retention
8
1.5%
87.5%
Value-Compatibility Shim
7
1.3%
71.4%
All typed pairs
550
100.0%
67.3%
Table 13: Heuristic used to prioritize behaviorally important deletion units.
Signal
Score
Deleted lines are not reintroduced elsewhere
+3.0
Complete control block is removed
+3.0
Condition guarding existing code is changed or removed
+3.0
Control-flow statement is removed
+3.0
Complete function or class is removed
+2.5
Decorator is removed
+2.0
Comparison or Boolean logic is removed
+1.5
Function or class signature is changed
+1.5
Assignment is removed
+1.0
Function or method call is removed
+1.0
Deleted code contains problem-statement terms
+2.0
Larger multi-line deletion unit
+1.5
Import and its dependent code are removed
+0.5
Standalone import is removed
−4.0
Table 14: Task counts across the deletion-focused F2P construction process.
Selection stage
Count
Tasks with at least 25% deletion
69
Tasks included in deletion-unit analysis
65
Tasks with a meaningful code deletion
63
Tasks without a meaningful code deletion
2
Deletion units identified
166
Targets covered by a listed visible test
24
Targets not covered by a listed visible test
39
Host-validated deletion-focused F2P tasks
34
Table 15: The four cumulative CanItDelete diagnostic modes.
Mode
Cumulative signal
Diagnostic question
Vanilla
No signal beyond the developer-style request
Can the model infer and execute the complete deletion end to end?
Explicit deletion
Requires complete removal and forbids guards, comments, disabled branches, fallbacks, replacement code, and other workarounds
Is failure caused by not choosing a genuinely subtractive edit?
Region pointer
Identifies relevant functions, methods, or regions without revealing deletion boundaries
Is finding every required region the principal obstacle?
Exact lines
Supplies occurrence-specific spans and requires all unmarked text to be preserved
Can the model execute a precise deletion once intent, location, and boundaries are known?
Table 16: Complete five-model diagnostic-ladder results. Four models use 200 tasks per mode; Claude Opus 4.8 uses 173. Cells report count (percentage).
Mode
Success
Incomplete deletion
Complete deletion, invalid edit
GLM-5.2
Vanilla
133 (66.5)
30 (15.0)
37 (18.5)
Explicit deletion
128 (64.0)
36 (18.0)
36 (18.0)
Region pointer
147 (73.5)
29 (14.5)
24 (12.0)
Exact lines
175 (87.5)
6 (3.0)
19 (9.5)
GPT-5.6 Sol
Vanilla
148 (74.0)
20 (10.0)
32 (16.0)
Explicit deletion
144 (72.0)
21 (10.5)
35 (17.5)
Region pointer
148 (74.0)
19 (9.5)
33 (16.5)
Exact lines
161 (80.5)
6 (3.0)
33 (16.5)
MiniMax-M3
Vanilla
134 (67.0)
36 (18.0)
30 (15.0)
Explicit deletion
134 (67.0)
32 (16.0)
34 (17.0)
Region pointer
137 (68.5)
33 (16.5)
30 (15.0)
Exact lines
170 (85.0)
6 (3.0)
24 (12.0)
Claude Opus 4.8
Vanilla
136 (78.6)
25 (14.5)
12 (6.9)
Explicit deletion
138 (79.8)
27 (15.6)
8 (4.6)
Region pointer
143 (82.7)
19 (11.0)
11 (6.4)
Exact lines
169 (97.7)
1 (0.6)
3 (1.7)
Qwen3-235B-A22B
Vanilla
50 (25.0)
109 (54.5)
41 (20.5)
Explicit deletion
55 (27.5)
105 (52.5)
40 (20.0)
Region pointer
54 (27.0)
99 (49.5)
47 (23.5)
Exact lines
113 (56.5)
35 (17.5)
52 (26.0)
Findings
Across 197 tasks solved by all five leading models, mean deletion recall ranged from 65.2% (Kimi-K2) to 71.7% (Opus-4.5), and it fell further to 19.8-30.4% on the 57 tasks all five models failed.
29.0% of passing patches (494 of 1,703) followed the Guard-and-Go strategy, which passed SWE-bench Verified 72.2% of the time — lower than Delete-and-Replace (85.2%) but higher than non-reference alternatives (39.6%).
Adding deletion-sensitive checks to 34 tasks dropped the pass rate of four frontier models from 63.2% to 41.9% (a 21.3 percentage-point decline), and 29 of 86 originally passing attempts retained the target code that should have been removed.
On the 200-task CanItDelete benchmark, success across 12 models ranged from 79.0% (Claude Opus 4.8, best) down to 18.0% (weaker open models); even when given exact deletion spans, Claude Opus 4.8 reached 97.7% but Qwen3-235B still left target code in 17.5% of tasks.
Adding 12,821 deletion examples (0.7% of training tokens) to a 7B model's post-training mixture raised CanItDelete success from 6.5% to 13.7%, improved SWE-bench Verified by 5.3 points and CanItEdit by 1.4 points, with EditBench essentially unchanged.
Where it can be used
Adding a review checklist item that checks whether code the developer patch was meant to remove has actually been deleted, separate from whether tests pass, before merging AI-generated pull requests
Adding deletion-sensitive tests (checks that fail if a target still remains, used as FAIL_TO_PASS criteria) into automated patch evaluation pipelines to catch Guard-and-Go style patches
Designing post-training data mixtures for code-editing models that include a small share of deletion-specific examples to reduce deletion avoidance
Using deletion-focused checks before deploying LLMs for legacy code cleanup, refactoring, or dead-code removal tasks
Limits and open work
The analysis covers five specific models' latest 2025-era SWE-bench Verified submissions under a fixed OpenHands scaffold, so findings may not generalize to other scaffolds or later model generations
The deletion-sensitive check treats the developer's removed code as the required target, but an alternative repair that preserves that code could still satisfy the original behavioral specification, so deletion is not proven to be the only valid fix
The 34 deletion-sensitive-check tasks and the 200 CanItDelete tasks were both deliberately selected for heavy or exclusive deletion content, so they do not represent SWE-bench Verified or general repository work as a whole
The deletion-focused post-training experiment is a proof of concept run on a single 7B in-house model with one training recipe, and whether the effect holds at larger scale is left to future work
Adding deletion training reduced incomplete deletion but increased over-deletion (removing beyond the intended boundary), showing that completing a deletion and controlling its boundary are separate objectives that still need to be addressed
Why it matters
This provides concrete evidence that AI-generated code patches can pass all tests while still leaving obsolete code behind, making codebases harder to maintain over time. Anyone reviewing or deploying AI coding agents should not treat 'tests pass' as proof of a clean edit, and may need to add deletion-specific checks.
Terms in this paper
Deletion Avoidance · A systematic tendency for a model to retain code that an intended edit actually requires removing
Guard-and-Go · A patch pattern where the model keeps the code that should be deleted and wraps it in a new condition or bypass instead
Deletion Recall · The share of the developer's actual deletions that the model's patch also performs
CanItDelete · A new benchmark of 200 tasks mined from real commits where the entire required edit is deletion
Deletion-Sensitive Check · A test added specifically to fail if the code that should have been deleted still remains
Original abstract (English)
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 fil