AI Technical Debt Grows Because Agents Won't Delete Code
Ask a coding agent to remove something, and there is a measured chance the tests come back green while the code you asked to remove is still in the codebase. In a new benchmark of real deletion tasks, 29% of the patches that passed kept the doomed logic and routed execution around it.[1]
The tests went green. The code is still there.
Why won't AI coding agents delete code?
Because current models systematically hedge instead of committing to the cut, and now there is a number on it. A July study titled "To Add Is Machine, To Delete Is Human" built a benchmark called CanItDelete: 200 tasks mined from real code changes where the entire correct edit is deletion, run against five leading models.[1]

The headline asymmetry: even on tasks every model could solve, the models' patches matched at most 71.7% of what the developer actually deleted. The best models fail roughly one deletion in five. Smaller open models fall to 18%. And the failure is surgical, not navigational.
Models reach the right file for over 92% of required deletions but cut the exact line in under 52% of cases.
The agent knows where the problem lives. It will not commit to the cut. The paper names the hedge Guard-and-Go: instead of removing the code, the model wraps it in a conditional (a guard) and routes execution around it.
The behavior looks right, the diff looks busy, and a dead path ships. That is "looks done versus actually done" as a measured category.
Can passing tests hide the leftover code?
Measurably, yes. The researchers retrofitted tests that explicitly check code was removed onto 34 tasks from the most-cited agent coding benchmark, called SWE-bench Verified. On the same work, four leading models fell from 63.2% to 41.9%.[1] A third of what passed had been hiding code that was supposed to be gone.
Read that gap carefully. It is a small sample, and the claim is not that models are incompetent. The claim is that the green checkmark was never checking the thing you asked for. A test suite that only checks behavior will happily bless a patch that keeps every line you wanted gone.
How much AI-generated debt actually gets fixed?
Less than you would hope, at scale. A separate study analyzed 302,600 verified AI-authored code changes across 6,299 real repositories and tracked every issue those changes introduced: 484,366 in total, with maintainability problems (what engineers call code smells) making up 89.3%.[2]
More than 15% of changes from every assistant introduced at least one issue. And 22.7% of the tracked issues still survive at the latest version of their repository.
Accumulation was the observation. Deletion avoidance is the mechanism.
An AI-heavy codebase only grows because the machine adds readily and subtracts reluctantly, and the debt lands on people who never wrote the code.
It is the same shape as the finding that AI code security has been flat for two years while everything else improved: a specific competence staying still inside a rising capability.
The economics are already priced. Refactoring one 17,155-line file cut an agent's reading cost for the same change by 83%.[3] Structure is the dominant cost lever because agents do the reading, and deletion is how structure gets maintained. The measured news is that the agent will not pull that lever itself.
What should teams shipping with agents do?
Treat subtraction as human-owned work, and make removal verifiable. The study's own instrument is the practical playbook:
- State removals explicitly, and add tests that check the code is gone, not just that the behavior works.
- Review agent diffs for guard-wrapped leftovers before merging. A busy diff around code you asked to delete is the tell.
- Schedule human-owned pruning passes, with the refactoring token math above as the budget justification.
- Treat a passing suite as necessary, never sufficient, for a deletion. Design the human's role in rather than hoping vigilance catches it.
Will the next model generation fix this? Partially, maybe. Even when the researchers handed a model the exact lines to delete, success only reached 80.5%, because it then deleted beyond the target or added code instead.
A pilot that taught deletion during training reduced the avoidance, which the authors read as "undertrained rather than beyond reach."[1] Trainable, and unsolved: planning for it beats waiting for it to disappear.
The judgment underneath
There is a reason this looks familiar. Deleting code is a commitment about what the system should not do, and that takes knowing the domain, the callers, the history. Adding is cheap speculation; subtracting is judgment.
It is the same boundary the measurements keep finding from every direction: the bottleneck in agent work is skill, and skill does not arrive by scaffold.
In the AI era, the scarce engineering act is not adding code. It is subtracting it, and for now the delete key is a human instrument.
References
- ^1.Ebrahimi, Hasan, Bhatia, Rajbahadur, Hassan, arXiv, “To Add Is Machine, To Delete Is Human: Measuring and Mitigating Deletion Avoidance in LLM Code Editing” (July 30, 2026)
- ^
- ^3.Giles Edwards-Alexander, martinfowler.com, “The Economic Benefit of Refactoring (exploring-gen-ai)” (July 30, 2026)
Frequently asked
What is technical debt in AI-generated code?›The accumulated cost of code that ships working but gets harder to change over time.
Why do AI coding agents avoid deleting code?›Measured on a benchmark of 200 real deletion-only tasks, leading models found the right file over 92% of the time but cut the exact line in under 52% of cases.
Can passing tests hide technical debt?›Yes, and researchers measured exactly how much a green checkmark can hide.
How do you measure technical debt in AI-generated code?›Track it at the edit level, not just the test level: whether edits remove what they should, whether dead paths accumulate, and how much context an agent must read per change.
How do you get an AI agent to actually delete code?›Make removal explicit and verifiable: state what must be gone, add removal-checking tests, and review diffs for guard-wrapped leftovers.
Let’s build it together.
We turn clever prototypes into production systems people can rely on. If you’re building with agents and want a hand making it real, leave your email and we’ll be in touch.