RefactorAssist: Agentic Refinement for Reliable Code Refactoring
On the map: LLM agents and tool use → Software engineering coding agents
Abstract (arXiv)
Code refactoring aims to enhance the internal structure of source code without affecting its functional behavior. The recent advancements of Large Language Models (LLMs) have demonstrated potential for automating software engineering tasks, such as code refactoring. However, the refactorings produced by LLMs often introduce subtle errors, leading to functional behavior changes and failed unit tests, which limit their practical adoption. To address the limitations of LLM-generated refactorings, we analyze the root causes of their failures and develop the RefactorAssist agent to improve the functional correctness of LLM-generated refactorings. To this end, we use 10 open-source Java projects with their native test suites and manually evaluate why LLM-generated refactorings fail unit tests. We then design an agentic approach that leverages unit-test logs, error explanations, project context retrieval, and code diffs to guide the iterative refactoring. Our findings show that the main reasons for failure are context misunderstanding/hallucination (24.3%), incorrect or inconsistent renaming (15.3%), adding new functionality or variables (13.7%), code incompleteness (11.3%), syntax and structural errors (9.7%), edge cases not handled (9%), improper type handling (8.7%), and variables outside scope (8%). To make our approach cost-effective, RefactorAssist first applies a static repair step for missing imports, unbalanced brackets, and compilation errors without LLMs. For remaining failures, RefactorAssist incorporates error logs and code diffs, achieving up to a 70.8% repair rate on the remaining failures and a 94.2% cumulative pass rate under the best-performing configuration. These results indicate that static checks and test-guided, context-aware agentic repair can increase the reliability of LLM-generated refactorings, bringing them closer to practical integration within developer workflows.
Key facts. Cited by 1 paper in the map (data through 14 Oct 2026). Placed in Software engineering coding agents, one of 16 directions in LLM agents and tool use. Builds on 16 of its 54 references that are in the map. First posted on arXiv 2 Aug 2026.
Builds on
16 of 54 references.
References · 16
- 2024The Llama 3 Herd of Modelscited by 14,715
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2024Qwen2.5-Coder Technical Reportcited by 1,203
- 2024StarCoder 2 and The Stack v2: The Next Generationcited by 502
- 2020IntelliCode Compose: Code Generation Using Transformercited by 227
- 2023Large Language Models for Software Engineering: Survey and Open Problemscited by 181
- 2023Keep the Conversation Going: Fixing 162 out of 337 bugs for 0.42 each using ChatGPTcited by 125
- 2020Learning to Update Natural Language Comments Based on Code Changescited by 31
- 2023Refactoring Programs Using Large Language Models with Few-Shot Examplescited by 28
- 2024Balanced Data Sampling for Language Model Training with Clusteringcited by 23
- 2021On the Evaluation of Commit Message Generation Models: An Experimental Studycited by 20
- 2024Data Efficient Evaluation of Large Language Models and Text-to-Image Models via Adaptive Samplingcited by 12
4 more
- 2022Methods2Test: A dataset of focal methods mapped to test casescited by 10
- 2021A Critical Comparison on Six Static Analysis Tools: Detection, Agreement, and Precisioncited by 9
- 2024EM-Assist: Safe Automated ExtractMethod Refactoring with LLMscited by 8
- 2026An Empirical Analysis of Community and Coding Patterns in OSS4SG vs. Conventional OSScited by 3
Built on by
Citing papers per year: 2026: 1.
1 paper.
Similar, not cited
Close in wording, no citation either way
- 2025RefAgent: A Multi-agent LLM-based Framework for Automatic Software Refactoring
- 2026REFINE: A Multi-Agent LLM Approach for Evidence-Guided Code Refactoring
- 2025MANTRA: Enhancing Automated Method-Level Refactoring with Contextual RAG and Multi-Agent LLM Collaboration
- 2026"Refactoring Runaway": Understanding and Mitigating Tangled Refactorings in Coding Agents for Issue Resolution
- 2026CodeTaste: Can LLMs Generate Human-Level Code Refactorings?
- 2026SmellBench: Towards Fine-Grained Evaluation of Code Agents on Refactoring Tasks
- 2025Agentic Refactoring: An Empirical Study of AI Coding Agents
- 2025REFINE: Enhancing Program Repair Agents through Context-Aware Patch Refinement