TL;DR
We’ve spent years teaching AI agents how to write code, but it turns out they’re much worse at the digital equivalent of spring cleaning. This paper introduces RepoClean, a benchmark designed to see if LLM agents can identify and remove "obsolete" code—historical baggage that clutters a repository and causes modern tests to fail. The verdict? Even the most advanced models, like GPT-6 Astra, only manage to "spark joy" (resolve the task) about 23% of the time.
What Problem Does This Paper Address?
In the world of software, evolution is messy. As developers add new features, old logic often becomes redundant or, worse, starts conflicting with the new stuff. This is "technical debt" in its physical form: obsolete functions, old imports, and "zombie" logic that lingers in the codebase.
While we have plenty of benchmarks to test if an AI can add a feature or fix a bug, we haven't really tested if they can safely delete. Deleting code is terrifying for a developer because of hidden dependencies—if you pull one loose thread in file_A.py, you might unravel the logic in file_B.py. The authors argue that a truly autonomous maintenance agent needs to be able to prune a repository-level codebase without accidentally breaking the parts that still work.
Methods
The researchers created an automated "time-travel" pipeline to generate realistic cleanup tasks.
- Historical Extraction: They looked at the git history of popular Python projects and identified code that human developers had previously deleted.
- Re-injection: They took that "obsolete" code and shoved it back into a newer, working version of the repository.
- Validation: If re-inserting that old code caused a previously passing test to fail, they had a perfect task: "Here is a broken repo; find the historical junk and remove it to restore functionality."
To solve these tasks, agents must navigate the entire repository, understand cross-file dependencies, and distinguish between "important logic" and "obsolete interference."
Datasets
The authors introduced RepoClean, which consists of 200 cleanup tasks sourced from 34 popular open-source Python repositories (like Flask, Pandas, and Chalice).
They also provided RepoClean Lite, a 40-task subset designed for faster, lower-cost evaluation. Unlike previous benchmarks that might focus on a single file, RepoClean requires agents to look at an average of 15.6 files per task to find the "gold patch"—the specific lines that need to vanish.
Key Insights and Ideas
- The "Repair vs. Remove" Trap: When faced with a bug caused by obsolete code, AI agents often try to "fix" it by writing more code to work around the old logic, rather than just deleting the old logic. It’s like trying to fix a wobbly table by shoving more napkins under the leg instead of just tightening the screw.
- Cleanup is an "Opt-in" Skill: In an "instruction ablation" study, the researchers found that if you don't explicitly tell the AI to "clean up," it deletes significantly less code. Without the nudge, agents ignore the "obsolete" parts and focus only on making the tests pass by any means necessary.
- Misleading Self-Tests: Agents are surprisingly good at lying to themselves. They often write their own "unit tests" to verify their work. However, these tests sometimes pass because they only check if the code exists (or doesn't), failing to catch the fact that the agent accidentally broke a core repository function in the process.
Key Results
The performance gap is wide. The researchers tested seven major models, and the results show that repository-level maintenance is a major frontier for LLMs:
- GPT-6 Astra led the pack but still only resolved 23% of the tasks.
- DeepSeek-V4.1-Flash followed closely at 21.5%.
- Qwen3.6-35B-A3B struggled significantly, resolving only 1% of the tasks.
- Deletion Coverage: Even when models "fixed" the tests, they often left behind a lot of the junk. GPT-6 Astra had a mean deletion coverage of 76.2%, meaning it still missed about a quarter of the obsolete code that human developers had originally removed.
Limitations and Future Work
The current benchmark is Python-only. Because the pipeline relies on Abstract Syntax Tree (AST) analysis to identify functions and classes, it would need to be adapted for other languages like Java or C++.
Additionally, the benchmark relies on existing test suites. If a repository has poor test coverage, the "obsolete" code might not trigger a failure, meaning some types of "dead code" (that doesn't break things but just sits there) aren't captured by this specific method. Future work could involve using static analysis to identify "silent" dead code that doesn't necessarily cause a test to crash but still contributes to technical debt.
Summary updated