RepairAgent: An Autonomous, LLM-Based Agent for Program Repair
作者: Islem Bouzenia, Premkumar Devanbu, Michael Pradel
分类: cs.SE, cs.AI
发布日期: 2024-03-25 (更新: 2024-10-28)
💡 一句话要点
提出RepairAgent以解决自动化程序修复问题
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 程序修复 自主代理 大型语言模型 软件工程 自动化技术 深度学习 工具调用
📋 核心要点
- 现有的程序修复方法通常依赖固定的提示或反馈循环,缺乏自主性和灵活性,难以有效应对复杂的缺陷修复任务。
- RepairAgent将大型语言模型视为自主代理,能够动态规划和执行修复操作,灵活调用多种工具以实现程序修复。
- 在Defects4J数据集上的实验表明,RepairAgent成功修复了164个缺陷,其中39个缺陷是先前技术未能修复的,显示出显著的提升。
📝 摘要(中文)
自动化程序修复已成为缓解软件缺陷对系统可靠性和用户体验影响的重要技术。本文介绍了RepairAgent,这是首个基于大型语言模型(LLM)的自主代理,旨在解决程序修复挑战。与现有的深度学习方法不同,RepairAgent将LLM视为能够自主规划和执行修复操作的代理,通过调用合适的工具来修复缺陷。RepairAgent在收集缺陷信息、获取修复材料和验证修复结果时,能够自由交错,并根据收集的信息和之前修复尝试的反馈决定调用哪些工具。我们的评估基于流行的Defects4J数据集,展示了RepairAgent在自主修复164个缺陷方面的有效性,其中包括39个未被先前技术修复的缺陷。与LLM的交互平均成本为每个缺陷270,000个标记,按OpenAI的GPT-3.5模型当前定价计算,每个缺陷约为14美分。
🔬 方法详解
问题定义:本文旨在解决程序修复中的自主性不足问题。现有方法往往依赖于固定的提示和反馈循环,缺乏灵活性,难以适应复杂的修复场景。
核心思路:RepairAgent将大型语言模型视为一个自主代理,能够根据收集的信息和反馈动态规划修复步骤,灵活调用合适的工具进行修复。这样的设计使得修复过程更加高效和智能。
技术框架:RepairAgent的整体架构包括信息收集、修复材料获取和修复验证三个主要模块。代理在这些模块之间自由交错,并根据当前状态和历史反馈决定下一步操作。
关键创新:RepairAgent的最大创新在于其将LLM视为自主代理,能够动态调整修复策略,而不是依赖于固定的提示。这一设计使得修复过程更加灵活和高效。
关键设计:RepairAgent使用了一套动态更新的提示格式,以便LLM能够与各种修复工具进行交互。此外,有限状态机的设计帮助代理在调用工具时做出更为合理的决策。
🖼️ 关键图片
📊 实验亮点
在Defects4J数据集上的实验结果显示,RepairAgent成功修复了164个缺陷,其中39个缺陷是先前技术未能修复的,显示出显著的性能提升。与LLM的交互平均成本为每个缺陷270,000个标记,约合14美分,具有较高的性价比。
🎯 应用场景
RepairAgent的研究成果在软件工程领域具有广泛的应用潜力,尤其是在自动化程序修复和软件维护方面。其自主修复能力可以显著提高软件开发的效率,降低维护成本,未来可能推动更智能的开发工具和平台的出现。
📄 摘要(原文)
Automated program repair has emerged as a powerful technique to mitigate the impact of software bugs on system reliability and user experience. This paper introduces RepairAgent, the first work to address the program repair challenge through an autonomous agent based on a large language model (LLM). Unlike existing deep learning-based approaches, which prompt a model with a fixed prompt or in a fixed feedback loop, our work treats the LLM as an agent capable of autonomously planning and executing actions to fix bugs by invoking suitable tools. RepairAgent freely interleaves gathering information about the bug, gathering repair ingredients, and validating fixes, while deciding which tools to invoke based on the gathered information and feedback from previous fix attempts. Key contributions that enable RepairAgent include a set of tools that are useful for program repair, a dynamically updated prompt format that allows the LLM to interact with these tools, and a finite state machine that guides the agent in invoking the tools. Our evaluation on the popular Defects4J dataset demonstrates RepairAgent's effectiveness in autonomously repairing 164 bugs, including 39 bugs not fixed by prior techniques. Interacting with the LLM imposes an average cost of 270,000 tokens per bug, which, under the current pricing of OpenAI's GPT-3.5 model, translates to 14 cents of USD per bug. To the best of our knowledge, this work is the first to present an autonomous, LLM-based agent for program repair, paving the way for future agent-based techniques in software engineering.