Why Do AI Coding Agents Fail at Large Multi-File Refactors?
A change in one file has to reach every file that depends on it. Giving each of those files its own agent, instead of sending one editor through all of them, recovers much of what gets lost.
By Haibo Jin, Haohan Wang, and others · · About our arXiv preprint
Key findings
- In a controlled test in the HERMES paper (Haibo Jin, Xinjie Li, Peng Kuang and Haohan Wang, arXiv 2026), a single GPT-5.6 Sol editor scored 16.8% on the whole-repository migrations of SWE Refactor Bench, while one agent per file, working on the same selected files, scored 31.0%.
- The gap grows with the amount of cross-file coordination: in the same HERMES comparison it was 3.6 points on SWE-bench Verified, 11.2 on DevOps-Gym, 13.0 on Terminal-Bench 4.0 and 14.2 on SWE Refactor Bench.
- More compute explains only part of it: on Terminal-Bench 4.0, a single editor given about the same tokens and cost as HERMES rose from 38.8% to 45.5%, still 6.3 points below the 51.8% of HERMES (arXiv 2610.07832).
- Against the standard harness for the same model, HERMES raised GPT-5.6 Sol at medium effort from 6.5% under Codex to 31.0% on SWE Refactor Bench, at a higher cost of $24.8 against $6.0 per task (arXiv 2610.07832).
Why do AI coding agents fail at large refactors?
AI coding agents fail at large refactors less because they cannot write the code than because they lose track of what one change requires everywhere else. Rename a parameter, swap a framework or move a build system, and the edit has to reach callers, configuration, tests and documentation. An agent that fixes a single GitHub issue well can make the core edit correctly and still leave the repository broken.
The numbers show how far apart the two jobs are. With GPT-5.6 Sol, the mini-SWE-agent harness resolves 96.2% of SWE-bench Verified, a benchmark of individual GitHub issues. On SWE Refactor Bench, built by another group from 20 whole-repository migrations, only 28 of 520 agent runs (5.4%) pass all three evaluation stages.
Our paper, Harness Engineering for Software Engineering via Modular Executable Dev-Primitives, by Haibo Jin, Peng Kuang and Haohan Wang at the University of Illinois Urbana-Champaign and Xinjie Li at The Pennsylvania State University, points at where the program state lives. It is spread over source files, configurations and tests that depend on each other, and every edit changes it. One agent with one growing history has to keep rebuilding that picture. Compressing the history does not remove the need to look again. So the paper asks a different question: what if each file could answer for itself, and tell the others what it needs?
Key terms
- Multi-file refactor
- A change to the structure of a codebase that must be applied consistently across several files while keeping its behavior the same; a whole-repository migration is the largest form.
- Incomplete propagation
- The failure in which an agent edits some affected files correctly but does not update the call sites, configuration or tests that depend on them.
- Agent harness
- The program around a model that gives it tools, context, an execution loop and checks; Codex, Claude Code and mini-SWE-agent are harnesses.
- Dev-Primitive
- A repository file paired with a resident LLM that reads that file, edits only that file, and sends natural-language requirements to the files it affects.
- HERMES
- The harness that activates the Dev-Primitives a task needs, runs the result, and traces each failure back to the files responsible for it.
What if every file had its own agent?
A Dev-Primitive attaches a resident LLM to one file. It gets a local goal, reads its own code, edits it if needed, and returns messages, for example a request that another file keep its JSON encoding consistent. Messages are addressed, not broadcast: they go to the callers, callees, configurations and tests that the file's own reasoning implicates, and no central agent rewrites them on the way. A file can also take part without changing. It may only report a constraint.
A repository can hold thousands of files, so HERMES adds two mechanisms. Activation picks the files likely to matter, follows their dependencies, and wakes only those. With GPT-5.6 Sol that came to 4.7 files per task on SWE-bench Verified and 12.6 on SWE Refactor Bench, with 95.4% and 83.3% of the files in the reference set included. Diagnosis runs after the repository is executed: it traces a failure back to particular files and reactivates only those, for up to three revision rounds. Failing tests or a failed build cannot be overruled by a model's opinion, and the benchmarks' held-out tests are never shown during solving.
The paper's worked example is a Django issue from SWE-bench Verified (django-13512), solved with the small open model Qwen3-8B. Six files were activated, they exchanged 15 directed messages (in this case mostly confirming what the recipients already planned), and four were edited. The patch took a different route from the human developers' fix, and it passed all 35 held-out tests.
Does one agent per file beat a single agent editing everything?
This is the test that isolates the idea. The authors kept the activation step, the selected files, the execution environment, the diagnosis step, the three revision rounds and the GPT-5.6 Sol model, and changed one thing: a single editor now received all the selected files and the whole plan at once.
| Benchmark | Single editor | HERMES (one Dev-Primitive per file) | Difference (points) |
|---|---|---|---|
| SWE-bench Verified (GitHub issues) | 93.4% | 97.0% | +3.6 |
| DevOps-Gym (build, monitoring, issues, tests) | 44.21% | 55.41% | +11.20 |
| Terminal-Bench 4.0 (terminal tasks) | 38.8% | 51.8% | +13.0 |
| SWE Refactor Bench (whole-repository migration) | 16.8% | 31.0% | +14.2 |
Because both versions see the same files, the gap is not about finding the right code. The single editor is cheaper, using 10–14% fewer tokens, so the authors also ran a compute-matched version on Terminal-Bench 4.0 that generates several candidate revisions per round. It reached 45.5%. Extra inference therefore explains about half of that 13.0-point gap, and the division of labor is the likely source of the rest.
Removing one part at a time shows which parts a migration depends on.
Messages between files cost 7.5 points to remove on SWE Refactor Bench and 2.8 on SWE-bench Verified, which is what one would expect if their job is to carry a change across files. Waking every identified file and keeping it awake does not help either: scores fall by 1.2 to 3.0 points and cost rises by 1.61 to 1.88 times.
How much does the harness change the score of the same model?
Against published or matched baselines at the same model and reasoning effort, HERMES with GPT-5.6 Sol at medium effort gained 12.4 points on average over the four benchmarks. The gain is uneven: 0.8 points on SWE-bench Verified over mini-SWE-agent, and 24.5 points on SWE Refactor Bench over Codex.
| Model and effort, on SWE Refactor Bench | Baseline harness | Baseline score (cost per task) | HERMES score (cost per task) |
|---|---|---|---|
| GPT-5.6 Sol, medium | Codex | 6.5% ($6.0) | 31.0% ($24.8) |
| GPT-5.6 Sol, high | Codex | 19.0% ($7.7) | 36.5% ($39.6) |
| GPT-5.6 Luna, medium | Codex | 0.0% ($1.7) | 16.0% ($4.9) |
| Claude Sonnet 5, high | Claude Code | 6.0% ($24.6) | 25.5% ($34.8) |
| Claude Opus 5, medium | Claude Code | 28.5% ($38.4) | 36.5% ($58.6) |
| Claude Opus 5, high | Claude Code | 34.5% ($55.7) | 41.5% ($82.4) |
Every row costs more under HERMES. One way to bring the cost down is to use a strong model only where it counts. With GPT-5.6 Sol for activation and diagnosis and Qwen3-8B for all the edits, HERMES stayed within 4.5 points of the all-Sol version on each benchmark and cost 26.2% less on Terminal-Bench 4.0 (50.6% against 51.8% resolved). Strengthening diagnosis alone helped more than strengthening activation alone. Working out why the code failed needed the bigger model more than writing the code did.
What else is known about why multi-file refactors fail?
Several groups have studied this problem. Some of their results support ours, and some pull the other way.
- SWE Refactor Bench: Can Coding Agents Complete a Long-Horizon, Whole-Repository Stack Migration? (Deyao Hong, Yizhe Chi and colleagues, arXiv 2026) is the benchmark behind our main result. It audits whether the migration really happened, which catches agents that copy the old implementation to make tests pass. Its picture is of near misses: among the 340 runs that pass the audit, 58% reach 99% of the fixed checks but only 26% reach 100%.
- SWE-Bench ProMax (Yuling Shi and colleagues, COLM 2026) covers 170 refactoring tasks in seven languages, averaging 11.5 modified files. The best model resolves 41.2%. The authors name incomplete refactoring as the dominant failure: agents often find the core files but stop short of the peripheral call sites, configuration files and test fixtures. This is the failure our messages between files are meant to address.
- RefactorPlatform (Aziz Ben Amor, Drish Mali, Mann Acharya, Vijayasri Iyer and Sébastien Bratières, EMNLP 2026 System Demonstrations) audits failed runs and attributes 50.9% of failures on RefactorBench to correct local edits whose dependent call sites were never updated. It also cautions against simply adding agents: a retrieval-augmented single agent passed 86% of matched tasks, against 66% for the sub-agent configuration they tested. There, the agent itself decides when to delegate; in HERMES, the division is fixed by file ownership. The two have not been compared directly.
- Exploration Structure in LLM Agents for Multi-File Change Localization (Akeela Darryl Fattha, Kia Ying Chua, Lingxiao Jiang and Laura Wynter, arXiv 2026) finds that, for a small model locating the files to change, a plain multi-turn loop matters more than added domain agents. Their task is finding files. Our controlled test starts after the files are found, so the two results can both hold.
- RefactorBench (Dhruv Gautam, Spandan Garg, Jinu Jang, Neel Sundaresan and Roshanak Zilouchian Moghaddam, ICLR 2025) showed early that agents solved only 22% of handcrafted multi-file tasks with base instructions, and that giving an agent an explicit representation of state improved this by 43.9%. Dev-Primitives keep that state in a different place, with the files.
- MAGIS (Wei Tao and colleagues, NeurIPS 2024) and CodeTeam (Yifei Wang and colleagues, arXiv 2026) also split repository work among agents, by designed roles such as manager and developer in MAGIS, and by architect, CTO, developer and QA roles with file ownership set in a contract in CodeTeam. In HERMES the agents come from the repository's own files.
What this does not show
This is an arXiv preprint and has not been peer reviewed. It does not show that one agent per file is always better: the controlled single-editor test was run with one model, GPT-5.6 Sol, and the compute-matched version on one benchmark.
SWE Refactor Bench has only 20 tasks, so scores move. Three HERMES runs with the default setting gave 29.5%, 32.0% and 31.5%; the other HERMES rows are single runs, and the baselines are largely taken from the public leaderboard. That leaderboard is noisy too: GPT-5.6 Sol under Codex scores 19.0 at high effort, 9.5 at xhigh, and 28.5 at max, the last at $143.5 per task. The leaderboard's best entry, Claude Opus 5 with Claude Code at xhigh, scores 47.0, above every HERMES result in the paper; HERMES was not run at that setting.
Where models are already strong, there is little left to gain: Claude Opus 5 ties its baseline on SWE-bench Verified at 97.0% and gains 1.5 points or less on Terminal-Bench 4.0. High SWE-bench Verified numbers also deserve care in general. The SWE-Bench ProMax authors cite an audit finding flawed tests in nearly 60% of the benchmark's unsolved instances, and models that can reproduce reference patches from training data.
HERMES usually costs more and can fail when activation misses a dependency or the tests say little. Files are the only granularity tested.
Frequently asked questions
Why do AI coding agents fail at large refactors?
Mostly because a change made in one file is not carried through to the other files that depend on it. Two independent benchmark studies, SWE-Bench ProMax (COLM 2026) and RefactorPlatform (EMNLP 2026), report this incomplete propagation as the main failure. The HERMES paper (arXiv 2610.07832) adds a controlled test: with the model and the selected files held fixed, replacing one editor with one agent per file raised the SWE Refactor Bench score from 16.8% to 31.0%.
Can AI coding agents migrate a whole codebase on their own?
Rarely, as of 2026. On SWE Refactor Bench, which has 20 whole-repository migrations, only 28 of 520 agent runs (5.4%) passed all three evaluation stages. The highest HERMES score on it, 41.5% with Claude Opus 5 at high effort, still leaves most of the benchmark unsolved.
Are multi-agent coding systems better than a single agent?
It depends on how the work is divided. In the HERMES paper, one agent per activated file beat a single editor on all four benchmarks with GPT-5.6 Sol, by 3.6 to 14.2 points. In RefactorPlatform, a single agent with retrieval passed 86% of matched tasks against 66% for the sub-agent setup its authors tested, so adding agents does not help by itself.
Can a small model do the code edits if a larger model plans?
Largely, yes, in this paper. With GPT-5.6 Sol choosing the files and diagnosing failures, and Qwen3-8B making the edits, HERMES stayed within 4.5 points of using GPT-5.6 Sol everywhere on all four benchmarks. On Terminal-Bench 4.0 it reached 50.6% against 51.8%, at 26.2% lower inference cost.
Citation
@article{jin2026hermes,
title = { Harness Engineering for Software Engineering via Modular Executable Dev-Primitives },
author = { Jin, Haibo and Li, Xinjie and Kuang, Peng and Wang, Haohan },
journal = { arXiv preprint arXiv:2610.07832 },
year = { 2026 }
}
Related from our lab
- Why AI agents fail at real-world tasks: the wider framework that Dev-Primitives belong to
- Agent Primitives: reusable building blocks for multi-agent systems
- What self-evolving agents forget as they adapt
- How a team of AI agents writes and revises gene expression analysis code
- All DREAM Lab preprints