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.
Figures & tables
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.
Benchmark
Task
Scope
Deletion-only
Instances
Task construction
Evaluation
FeatureBench ( Zhou et al., 2026 )
Feature development
Feature
×
200
Test-guided code extraction
Tests
Commit0 ( Zhao et al., 2025 )
Library implementation
Repository
×
54
Implementation removal
Tests
SWE-EVO ( Le et al., 2026 )
Release upgrades
Repository
×
48
Release transition mining
Tests
SWE-Milestone ( Deng et al., 2026a )
Continuous evolution
Repository
×
98
Commit grouping
Tests
RefactorBench ( Gautam et al., 2025 )
Refactoring
Repository
×
100
Handcrafted refactorings
AST checks
CodeTaste ( Thillen et al., 2026 )
Refactoring
Repository
×
100
Refactoring commit mining
Tests + static checks
Table 1: Comparison of RepoClean with representative coding benchmarks. RepoClean evaluates autonomous repository-level cleanup of obsolete historical code. Its automated pipeline reintroduces previously deleted code from real repository histories into newer versions, creating tasks with deletion-only gold patches. Evaluation combines functional tests with deletion coverage.
Figure 2: Overview of the RepoClean construction pipeline. The pipeline extracts obsolete code from repository histories and uses coding agents to construct executable environments. Reinserting the extracted code into current repository versions creates candidate cleanup tasks. Candidates are retained when the inserted code causes previously passing tests to fail, with its removal providing a verifiable cleanup solution.
Figure 3: Distribution of tasks across six software domains in RepoClean.
Category
Statistic
Mean
Max
Gold patch
# Deleted lines
256.85
573
# Modified files
15.62
37
Test files
# Failed tests
39.15
219
# Passed tests
30.70
250
# Total
69.85
267
Table 2: Per-task gold patch sizes and pre-cleanup test file counts in RepoClean.
Full
Lite
Model
% Res.
% Rec.
% Cov.
Token I/O
# Steps
% Res.
% Rec.
% Cov.
Token I/O
# Steps
GPT-6 Astra
23.0
73.2
76.2
2.3M / 16.9K
33.9
15.0
72.2
75.5
1.8M / 16.2K
31.0
DeepSeek-V4.1-Flash
21.5
67.6
71.0
77.9M / 168.9K
293.0
20.0
64.0
69.7
74.5M / 163.4K
289.4
GLM-5.3
17.5
72.5
70.7
28.6M / 82.6K
201.4
17.5
75.1
67.8
28.3M / 83.6K
202.2
GPT-6.1 Sol
13.5
67.4
70.2
1.9M / 13.9K
33.7
15.0
66.5
69.5
1.8M / 14.1K
32.8
Kimi K3
13.5
68.7
65.5
19.2M / 83.3K
157.9
15.0
63.1
62.7
19.3M / 83.8K
160.0
Table 3: Main results on RepoClean Full and Lite, sorted by Full Resolved in descending order. Res., Rec., and Cov. denote Resolved, Recovery, and Coverage (%). Token I/O and Steps are averaged over tasks.
Figure 4: Cleanup scope and resolution rates for GPT-6 Astra on RepoClean. Tasks are grouped by (a) lines deleted and (b) files modified by the gold patch, using bins of 50 lines and three files, respectively. Bars show Resolved (%) per bin; ticks mark bin centers.
Figure 5: Examples of cleanup errors and misleading self-tests. (a) DeepSeek retains an old method that the gold patch removes and adds a supporting method instead. (b) Kimi deletes a method still required by the current version. Its self-test passes by checking only that the method is absent, while a previously passing validation test fails when calling it. Code and logs are shown as excerpts.
With file paths
Model
% Res.
% Rec.
% Cov.
GPT-6.1 Sol
27.5 (+12.5)
70.2 (+3.7)
84.6 (+15.2)
DS-V4.1-Flash
17.5 (-2.5)
67.7 (+3.8)
77.1 (+7.3)
Qwen3.8-27B
12.5 (+2.5)
44.9 (-13.5)
47.1 (-2.9)
Table 4: Effect of file-location hints on RepoClean Lite, with changes relative to the no-hint baseline in Table 3 .
General repair instruction
Model
% Res.
% Rec.
% Cov.
GPT-6.1 Sol
15.0 (0.0)
60.2 (-6.3)
37.2 (-32.2)
DS-V4.1-Flash
10.0 (-10.0)
68.9 (+4.9)
32.7 (-37.1)
Qwen3.8-27B
5.0 (-5.0)
56.5 (-1.9)
21.8 (-28.2)
Table 5: Effect of replacing cleanup instructions with a general repair request on RepoClean Lite, with changes relative to the cleanup baseline in Table 3 .
Figure 6: Functional regressions during code cleanup. Results cover tasks in RepoClean with initially passing validation test files. A regression occurs when an initially passing test file fails after editing; a fix occurs when an initially failing file passes. Numbers within bars indicate task counts; percentages at bar ends indicate the overall regression rate.
Figure 7: Termination modes of unresolved runs. Each row reports category percentages among a model’s unresolved runs on RepoClean; n denotes the number of such runs. Colors use a nonlinear scale; hatched cells indicate zero occurrences.
Appendix figures & tables13 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 8: Excerpt of the pure-deletion diff in davidhalter/jedi ( jedi/_compatibility.py , 0c618a4456c4 → ef5d36112106 ). Lines prefixed with - denote historical code deleted from Ck and extracted by the pipeline, including the entire function _python2_dct_keys_to_unicode and a two-line internal fragment inside the retained function pickle_dump .
Extracted content
Counting rule
Entire function or method
Counts as 1 each.
Internal fragments
Enclosing function or method counts once, regardless of fragment count.
Entire class
Each member function or method counts as 1; the class itself is not counted.
Appendix
Table 6: Function and method counting rules for extracted historical code.
Return status
Subsequent action
retry
The agent revises the Dockerfile or test script using the error feedback and calls validate again.
smoke_passed
The agent stops editing, and the system proceeds to full validation (Section B.3 ).
failed
Validation stops without further retries, and the repository is excluded.
Appendix
Table 7: Actions triggered by each return status of the validate tool.
Figure 9: Example commands and JSON outputs of the unified run_script.sh interface on aws/chalice .
Configuration item
Setting
Planning and construction model
GPT-5.6 Luna
Iteration limit per agent
150
Time limit per agent
120 minutes
Max validation attempts
10
Initial-check sample size
Up to 10 files
Docker image build timeout
40 minutes
Appendix
Table 8: Environment construction settings.
Figure 10: Excerpt of the prompt used by the environment planning agent.
Figure 11: Excerpt of the prompt used by the environment construction agent.
Software domain
Repository
Full
Lite
Web & apps
aws/chalice
5
1
beeware/toga
2
1
django-extensions/django-extensions
8
2
encode/django-rest-framework
7
1
falconry/falcon
5
1
pallets/flask
1
0
Appendix
Table 9: Task counts per repository in RepoClean Full and Lite.
Model
Reasoning effort
GPT-6 Astra
xhigh
GPT-6.1 Sol
high
DeepSeek-V4.1-Flash
max
GLM-5.3
max
Kimi K3
max
Qwen3.8-27B
default
Appendix
Table 10: Reasoning effort settings for the evaluated models.
Setting
Value
Agent framework
mini-swe-agent 2.4.6
Environment preparation limit
60 minutes
Agent execution limit
60 minutes
Agent interaction step limit
Unlimited
Terminal command timeout
30 seconds
Final validation limit
30 minutes
Appendix
Table 11: Runtime settings for agents and evaluation containers.
Figure 12: Cleanup task instruction used in the main experiment.
Figure 13: Example file-location hints appended to the cleanup instruction in the file-location hint ablation.
Figure 14: General repair instruction used in the cleanup instruction ablation.