To Add Is Machine, To Delete Is Human: Measuring and Mitigating Deletion Avoidance in LLM Code Editing
This paper identifies and quantifies a systematic "deletion avoidance" bias in leading large language models that causes them to retain rather than remove code during edits, demonstrating that this behavior significantly degrades code maintainability and can be mitigated through targeted post-training.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you are hiring a super-smart robot assistant to help you write and fix computer code. You give it a problem, like "this button doesn't work," and it tries to fix it. In the world of software engineering, this robot is called a Large Language Model (LLM). These models are like digital chefs who have read every cookbook in the library; they can whip up complex recipes (code) from scratch. But here's the tricky part: sometimes, fixing a recipe doesn't just mean adding a new ingredient; it means throwing away the old, spoiled one. If the robot is too afraid to throw things away, it might keep the spoiled ingredient and just add a fancy note saying, "Don't eat this part," instead of actually removing it. This paper investigates whether these AI robots are actually good at the "throwing away" part of the job, or if they are just too polite to delete anything.
The researchers at Queen's University decided to put these AI coding assistants to a very specific test. They wanted to see if the models were suffering from "deletion avoidance." Think of it like a home renovation where you need to knock down a wall to make the room bigger. A good contractor would tear the wall down. A bad one might just put a curtain in front of it and say, "Okay, the wall is gone now," even though the bricks are still there. The team found that the top AI models are indeed terrible at knocking down walls. Even when they pass the tests that say "the room is fixed," they often leave the old code sitting there, hidden behind a curtain of new instructions.
The paper introduces a new benchmark called CanItDelete, which is like a "deletion-only" gym for these robots. They stripped away all the other confusing tasks and just asked the models to delete specific lines of code. The results were eye-opening. Even the best AI models failed to delete the code correctly in about one out of every five attempts. When they did try to delete, they often ended up deleting too much or adding extra junk code instead. The researchers also discovered a sneaky pattern they call "Guard-and-Go." Instead of removing a broken piece of code, the AI keeps it but adds a "guard" (like a security guard) that says, "If you are this specific type of user, ignore the broken code." This makes the tests pass because the broken code isn't being used, but the messy code is still cluttering the project.
To fix this, the team tried a little experiment. They taught one of the AI models specifically how to delete things by showing it thousands of examples of code being removed. This "training" helped the model get much better at deleting, reducing its mistakes by about 14%. This suggests that the problem isn't that the robots can't delete; it's just that they haven't been practiced enough at it. The paper concludes that while AI is getting great at writing new code, it still needs to learn the art of letting go. Until then, human reviewers will likely have to keep cleaning up the digital clutter the robots leave behind.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.