[论文解读] AgentFL: Scaling LLM-based Fault Localization to Project-Level Context
AgentFL 是一个基于多智能体 LLM 的系统,通过将故障定位过程分解为三个阶段——故障理解、代码库导航和故障确认,实现了对项目级代码库的故障定位扩展。它通过使用具备测试行为追踪和文档引导搜索等工具的专用智能体,实现了最先进性能,在低代价下(平均每个错误 $0.074 和 97 秒)成功将 157 个错误定位在 Top-1 位置。
Fault Localization (FL) is an essential step during the debugging process. With the strong capabilities of code comprehension, the recent Large Language Models (LLMs) have demonstrated promising performance in diagnosing bugs in the code. Nevertheless, due to LLMs' limited performance in handling long contexts, existing LLM-based fault localization remains on localizing bugs within a small code scope (i.e., a method or a class), which struggles to diagnose bugs for a large code scope (i.e., an entire software system). To address the limitation, this paper presents AgentFL, a multi-agent system based on ChatGPT for automated fault localization. By simulating the behavior of a human developer, AgentFL models the FL task as a three-step process, which involves comprehension, navigation, and confirmation. Within each step, AgentFL hires agents with diversified expertise, each of which utilizes different tools to handle specific tasks. Particularly, we adopt a series of auxiliary strategies such as Test Behavior Tracking, Document-Guided Search, and Multi-Round Dialogue to overcome the challenges in each step. The evaluation on the widely used Defects4J-V1.2.0 benchmark shows that AgentFL can localize 157 out of 395 bugs within Top-1, which outperforms the other LLM-based approaches and exhibits complementarity to the state-of-the-art learning-based techniques. Additionally, we confirm the indispensability of the components in AgentFL with the ablation study and demonstrate the usability of AgentFL through a user study. Finally, the cost analysis shows that AgentFL spends an average of only 0.074 dollars and 97 seconds for a single bug.
研究动机与目标
- 解决现有基于 LLM 的故障定位方法的局限性,这些方法受限于上下文长度,仅能处理小范围代码(例如单个方法)。
- 通过模拟人类开发者调试行为(理解故障、导航代码库、确认错误位置),实现项目级故障定位。
- 通过将任务分解为受控的多步阶段并使用专用智能体,克服 LLM 在长上下文下的性能下降问题。
- 通过测试行为追踪和多轮对话等辅助策略,提升基于 LLM 的故障定位的准确性和可用性。
- 通过成本分析和用户研究,展示 AgentFL 在大规模部署中的成本效益和实际可用性。
提出的方法
- 将故障定位分解为三个阶段:故障理解(分析失败轨迹)、代码库导航(探索相关代码路径)和故障确认(验证可疑的错误位置)。
- 为每个阶段部署专用的 LLM 驱动智能体,每个智能体配备定制化工具(如测试执行、代码搜索、语义相似度匹配)。
- 集成测试行为追踪,以追踪失败测试的执行路径,并引导智能体向相关代码区域导航。
- 应用文档引导搜索,利用嵌入和类似 RAG 的检索机制,从项目中检索语义相关的代码片段。
- 使用多轮对话,通过迭代澄清和验证,优化智能体推理并提高预测准确性。
- 利用 GPT-3.5-turbo-16k-0613 配合提示工程和输入过滤,避免数据泄露,同时保持性能。
实验结果
研究问题
- RQ1多智能体 LLM 系统能否有效将故障定位从方法级扩展到项目级代码库?
- RQ2AgentFL 的三阶段架构(理解、导航、确认)相比基线 LLM 提示方法,在定位准确性上表现如何?
- RQ3辅助策略(测试行为追踪、文档引导搜索、多轮对话)对故障定位性能有何影响?
- RQ4AgentFL 在实际使用中是否具有可用性,其解释是否能有效帮助开发者识别错误?
- RQ5大规模部署 AgentFL 的计算和财务成本如何?
主要发现
- AgentFL 在 Defects4J-V1.2.0 中将 157 个错误成功定位在 Top-1 预测位置,优于现有基于 LLM 的方法。
- 该系统与最先进基于学习的故障定位技术表现出互补性,表明其在混合故障定位流水线中具有潜力。
- 在用户研究中,参与者认为 AgentFL 的解释具有帮助性,超过 80% 的错误在正确预测前仅有不到三个错误预测。
- AgentFL 实现了低成本和低时间消耗,平均每个错误为 $0.074 和 97 秒,95% 的情况低于 $0.20 和 200 秒。
- 消融研究证实,核心组件如测试行为追踪和多轮对话对最优性能不可或缺。
- 案例研究显示,即使 Top-1 预测错误,AgentFL 通常也能识别出正确的根本原因,并建议相关方法(如调用者),从而减少开发者的工作量。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。