arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2511.03153cs.SEcs.AI
收藏

RefAgent:一种基于大型语言模型的多智能体框架,用于自动软件重构

RefAgent: A Multi-agent LLM-based Framework for Automatic Software Refactoring

Polytechnique Montreal(蒙特利尔大学)

Khouloud Oueslati, Maxime Lamothe, Foutse Khomh

AI总结:

RefAgent是一种基于多智能体的LLM框架,用于自动化软件重构,通过自我反思和工具调用能力提升重构效率和代码质量。

摘要:

大型语言模型(LLMs)已经显著影响了各种软件工程任务。事实上,在软件重构的情况下,传统LLMs已经展示了减少开发时间和提高代码质量的能力。然而,这些LLMs往往依赖于静态的、详细的指令来完成特定任务。相比之下,基于LLM的智能体可以动态适应不断变化的环境,并通过与软件工具交互和执行工作流来自主做出决策。在本文中,我们探索了基于LLM的智能体在支持重构活动方面的潜力。具体来说,我们介绍了RefAgent,一种用于端到端软件重构的多智能体LLM框架。RefAgent由专门的智能体组成,负责规划、执行、测试以及通过自我反思和工具调用能力迭代优化重构。我们对八个开源Java项目进行了评估,将RefAgent与单一智能体方法、基于搜索的重构工具以及历史开发者重构进行比较。我们的评估重点在于:(1)生成的重构对软件质量的影响,(2)识别重构机会的能力,以及(3)每个LLM智能体的贡献,通过消融研究。我们的结果表明,RefAgent实现了90%的中位单元测试通过率,将代码异味减少了中位数52.5%,并将关键质量属性(如可重用性)提高了中位数8.6%。此外,它在识别重构机会方面与开发者重构和基于搜索的工具非常接近,分别达到了79.15%和72.7%的中位数F1分数。与单一智能体方法相比,RefAgent将中位数单元测试通过率提高了64.7%,将中位数编译成功率提高了40.1%。这些发现突显了多智能体架构在推进自动化软件重构方面的潜力。

英文摘要:

Large Language Models (LLMs) have substantially influenced various software engineering tasks. Indeed, in the case of software refactoring, traditional LLMs have shown the ability to reduce development time and enhance code quality. However, these LLMs often rely on static, detailed instructions for specific tasks. In contrast, LLM-based agents can dynamically adapt to evolving contexts and autonomously make decisions by interacting with software tools and executing workflows. In this paper, we explore the potential of LLM-based agents in supporting refactoring activities. Specifically, we introduce RefAgent, a multi-agent LLM-based framework for end-to-end software refactoring. RefAgent consists of specialized agents responsible for planning, executing, testing, and iteratively refining refactorings using self-reflection and tool-calling capabilities. We evaluate RefAgent on eight open-source Java projects, comparing its effectiveness against a single-agent approach, a search-based refactoring tool, and historical developer refactorings. Our assessment focuses on: (1) the impact of generated refactorings on software quality, (2) the ability to identify refactoring opportunities, and (3) the contribution of each LLM agent through an ablation study. Our results show that RefAgent achieves a median unit test pass rate of 90%, reduces code smells by a median of 52.5%, and improves key quality attributes (e.g., reusability) by a median of 8.6%. Additionally, it closely aligns with developer refactorings and the search-based tool in identifying refactoring opportunities, attaining a median F1-score of 79.15% and 72.7%, respectively. Compared to single-agent approaches, RefAgent improves the median unit test pass rate by 64.7% and the median compilation success rate by 40.1%. These findings highlight the promise of multi-agent architectures in advancing automated software refactoring.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑