PatchPilot: A Cost-Efficient Software Engineering Agent with Early Attempts on Formal Verification

📄 arXiv: 2502.02747v2 📥 PDF

作者: Hongwei Li, Yuheng Tang, Shiqi Wang, Wenbo Guo

分类: cs.RO, cs.AI, cs.CR

发布日期: 2025-02-04 (更新: 2025-06-10)

🔗 代码/项目: GITHUB


💡 一句话要点

PatchPilot:一种兼顾成本、效率和稳定性的软件工程智能补丁代理

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 软件补丁 智能代理 代码修复 大语言模型 规则规划 自动化软件工程 SWE-bench

📋 核心要点

  1. 现有基于代理的补丁方法成本高、稳定性差,而基于规则的方法性能受限。
  2. PatchPilot提出一种新的规则规划流程,包含复现、定位、生成、验证和改进五个组件。
  3. 实验表明,PatchPilot在SWE-bench上优于现有开源方法,同时保持低成本和高稳定性。

📝 摘要(中文)

本文提出PatchPilot,一种兼顾补丁有效性、稳定性和成本效益的智能补丁代理。现有补丁代理可分为基于代理规划的方法(依赖LLM进行规划)和基于规则规划的方法(遵循预定义的工作流程)。前者性能高但成本高且稳定性有限,后者更稳定高效但工作流程的局限性影响了性能。PatchPilot提出了一种新颖的基于规则的规划工作流程,包含五个组件:复现、定位、生成、验证和改进(改进是PatchPilot独有的)。针对每个组件,我们引入了新颖且定制化的设计,以优化其有效性和效率。在SWE-bench基准上的大量实验表明,PatchPilot在保持低成本(每个实例低于1美元)并确保更高稳定性的同时,表现优于现有的开源方法。我们还进行了详细的消融研究,以验证每个组件中的关键设计。

🔬 方法详解

问题定义:现有软件补丁代理在效率、成本和稳定性之间难以平衡。基于代理规划的方法依赖大语言模型,计算成本高昂且结果不稳定。基于规则的方法虽然更稳定高效,但预定义的流程限制了其性能上限。因此,需要一种既能保证补丁效果,又能兼顾成本和稳定性的方法。

核心思路:PatchPilot的核心思路是设计一种改进的、基于规则的规划流程,该流程在保证稳定性和效率的同时,通过引入新的组件和定制化设计来提升补丁性能。通过精心设计的规则和模块,避免完全依赖大语言模型进行规划,从而降低成本并提高稳定性。

技术框架:PatchPilot包含五个主要组件: 1. 复现(Reproduction):重现错误,确认问题。 2. 定位(Localization):确定需要修改的代码位置。 3. 生成(Generation):生成候选补丁。 4. 验证(Validation):验证补丁是否修复了错误,且没有引入新的问题。 5. 改进(Refinement):这是PatchPilot独有的组件,用于迭代改进补丁,进一步提升性能。

关键创新:PatchPilot的关键创新在于其整体的规则规划流程以及改进(Refinement)组件的引入。改进组件允许代理迭代地优化补丁,从而提高补丁的质量和成功率。此外,每个组件都进行了定制化设计,以优化其效率和效果。

关键设计:每个组件都有定制化的设计。例如,定位组件可能使用静态分析和动态分析相结合的方法来精确定位错误位置。生成组件可能使用基于模板的代码生成方法,并结合大语言模型进行微调。验证组件使用测试用例来评估补丁的正确性。改进组件则根据验证结果,迭代地调整补丁代码。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

PatchPilot在SWE-bench基准测试中表现出色,优于现有的开源方法,同时保持了较低的成本(每个实例低于1美元)和较高的稳定性。消融研究验证了每个组件的关键设计的有效性,表明PatchPilot的性能提升并非偶然,而是得益于其精心设计的架构和组件。

🎯 应用场景

PatchPilot可应用于软件开发和维护的各个阶段,例如自动化缺陷修复、代码审查和持续集成。它可以帮助开发者快速修复软件中的错误,提高软件质量,并降低开发和维护成本。该研究对于提升软件工程自动化水平具有重要意义,并可能促进更可靠、更高效的软件开发流程。

📄 摘要(原文)

Recent research builds various patching agents that combine large language models (LLMs) with non-ML tools and achieve promising results on the state-of-the-art (SOTA) software patching benchmark, SWE-bench. Based on how to determine the patching workflows, existing patching agents can be categorized as agent-based planning methods, which rely on LLMs for planning, and rule-based planning methods, which follow a pre-defined workflow. At a high level, agent-based planning methods achieve high patching performance but with a high cost and limited stability. Rule-based planning methods, on the other hand, are more stable and efficient but have key workflow limitations that compromise their patching performance. In this paper, we propose PatchPilot, an agentic patcher that strikes a balance between patching efficacy, stability, and cost-efficiency. PatchPilot proposes a novel rule-based planning workflow with five components: reproduction, localization, generation, validation, and refinement (where refinement is unique to PatchPilot). We introduce novel and customized designs to each component to optimize their effectiveness and efficiency. Through extensive experiments on the SWE-bench benchmarks, PatchPilot shows a superior performance than existing open-source methods while maintaining low cost (less than 1$ per instance) and ensuring higher stability. We also conduct a detailed ablation study to validate the key designs in each component. Our code is available at https://github.com/ucsb-mlsec/PatchPilot.