RepoClean: Evaluating Coding Agents on Repository-Level Obsolete Code Cleanup

Hongyixuan Yuan, Qixing Zhou, Pengcheng Huang, Qingshuo Ni, Runsong Zhao, Shaokai He, Xiangpeng Li, Deqiang OuyangarXiv 2026

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.

  1. Historical Extraction: They looked at the git history of popular Python projects and identified code that human developers had previously deleted.
  2. Re-injection: They took that "obsolete" code and shoved it back into a newer, working version of the repository.
  3. 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."

The RepoClean construction pipeline: from extracting old diffs to building a verifiable Docker environment.

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.
Examples of agents failing: (a) adding code instead of removing it, and (b) deleting a required method but writing a self-test that "passes" anyway.

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.
Figure 1: Cleanup task and evaluation in RepoClean. (a) An example of obsolete-code removal while preserving the current implementation, with schematic illustrations of test recovery and deletion coverage. (b) Model comparison by task resolution rate and mean deletion coverage on RepoClean.

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

Abstract

Large language model (LLM) agents have demonstrated strong repository-level programming capabilities. However, as software evolves, repository code may become redundant or obsolete, increasing maintenance costs and potentially introducing functional issues. Agents must therefore identify and remove unnecessary code safely, yet autonomous repository-level code cleanup remains insufficiently evaluated in isolation. To evaluate this capability, we introduce RepoClean, a benchmark of 200 cleanup tasks from 34 popular open-source Python repositories. RepoClean is constructed by automatically reintroducing deleted code from real repository histories into newer versions, preserving current implementations and retaining instances where previously passing tests consequently fail. To restore existing functionality without new feature development, agents must use repository interfaces and cross-file dependencies to determine which historical code to remove and which implementations to preserve. Evaluation of seven models shows that even the best-performing model, GPT-6 Astra, resolves only 23% of tasks. Further analysis reveals that agents remove substantially less obsolete code when cleanup is not explicitly requested. RepoClean provides a foundation for systematically studying these cleanup challenges and advancing coding agents toward autonomous software maintenance.
BibTeX
@misc{yuan2026repoclean,
  author = {Hongyixuan Yuan and Qixing Zhou and Pengcheng Huang and Qingshuo Ni and Runsong Zhao and Shaokai He and Xiangpeng Li and Deqiang Ouyang},
  title = {{RepoClean: Evaluating Coding Agents on Repository-Level Obsolete Code Cleanup}},
  year = {2026},
  eprint = {2611.30350},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.30350},
}
Figure