BLAgent: Agentic RAG for File-Level Bug Localization
作者: Md Afif Al Mamun, Gias Uddin
分类: cs.SE, cs.AI
发布日期: 2026-07-05
💡 一句话要点
提出BLAgent以解决文件级别的Bug定位问题
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: Bug定位 自动程序修复 大语言模型 检索增强生成 代码分析
📋 核心要点
- 现有的RAG方法在Bug定位中依赖静态检索,缺乏必要的推理能力,导致故障代码识别不准确。
- BLAgent通过代码结构感知的编码、双视角查询转换和两阶段重排序,提供了一种新的文件级Bug定位解决方案。
- 在SWE-bench-Lite上,BLAgent的Top-1准确率超过78%,并且在APR框架中修复成功率提高了25%。
📝 摘要(中文)
Bug定位在基于大语言模型(LLM)的软件维护中仍然是一个关键瓶颈,准确识别故障代码对于调试、根本原因分析、分流和自动程序修复(APR)至关重要。文件级别的Bug定位在层次化定位和修复管道中尤为关键,错误的文件选择可能会影响后续阶段,如函数级定位和补丁生成。尽管检索增强生成(RAG)为将LLM与代码库上下文结合提供了有希望的方法,但现有的RAG管道往往依赖静态检索,缺乏准确识别故障代码所需的推理能力。本文提出了BLAgent,一个新颖的代理RAG框架,集成了三大核心思想:代码结构感知的代码库编码、双视角查询转换和两阶段的代理重排序。BLAgent在SWE-bench-Lite上实现了超过78%的Top-1准确率,并在APR框架中提高了高达25%的修复成功率。
🔬 方法详解
问题定义:本论文旨在解决文件级别的Bug定位问题,现有方法在准确性和推理能力上存在不足,导致故障代码识别不准确。
核心思路:BLAgent的核心思路是通过集成代码结构感知的编码、双视角查询转换和两阶段的代理重排序,来提高Bug定位的准确性和效率。这样的设计能够更好地利用代码库的上下文信息。
技术框架:BLAgent的整体架构包括三个主要模块:代码结构感知的编码模块、双视角查询转换模块和两阶段的代理重排序模块。该框架通过这些模块的协同工作,实现高效的Bug定位。
关键创新:BLAgent的主要创新在于采用了有界推理策略,限制LLM的检查和重排序仅在经过检索过滤的候选文件集内进行,从而避免了开放式的代码库遍历。这一设计在提高定位准确性的同时,降低了计算成本。
关键设计:在关键设计方面,BLAgent使用了路径增强的AST(抽象语法树)分块技术,并通过双视角查询转换捕捉结构和行为信号。此外,重排序阶段结合了符号检查与基于证据的推理,确保了结果的准确性。
📊 实验亮点
在实验中,BLAgent在SWE-bench-Lite上实现了超过78%的Top-1准确率,并在使用闭源模型时达到了86%。此外,BLAgent的计算成本比最强基线低18倍,且在APR框架中提高了高达25%的修复成功率,显示出其显著的性能优势。
🎯 应用场景
BLAgent的研究成果具有广泛的应用潜力,尤其在软件维护、调试和自动程序修复等领域。通过提高Bug定位的准确性和效率,BLAgent能够显著降低开发和维护成本,提升软件质量。未来,该框架还可以扩展到其他类型的代码分析和修复任务中。
📄 摘要(原文)
Bug localization remains a key bottleneck for large language model (LLM)-based software maintenance, where accurately identifying faulty code is essential for debugging, root cause analysis, triage, and automated program repair (APR). File-level bug localization is especially critical in hierarchical localization and repair pipelines, where incorrect file selection can propagate to downstream stages such as function-level localization and patch generation. While Retrieval-Augmented Generation (RAG) offers a promising way to ground LLMs in repository context, existing RAG pipelines often rely on static retrieval and lack the reasoning needed to accurately identify faulty code. In this work, we present BLAgent, a novel agentic RAG framework for file-level bug localization that integrates three key ideas: (i) code structure-aware repository encoding with path-augmented AST-based chunking, (ii) dual-perspective query transformation that captures both structural and behavioral signals from bug reports, and (iii) two-phase agentic reranking that combines symbolic inspection with evidence-grounded reasoning. Unlike prior graph-based or multi-hop agentic approaches, BLAgent adopts a bounded reasoning strategy that limits LLM-based inspection and reranking to a compact, retrieval-filtered set of candidate files, avoiding open-ended repository traversal. This design balances localization accuracy with computational cost. On SWE-bench-Lite, BLAgent attains over 78% Top-1 accuracy with open-source models and over 86% with a closed-source model, while being over 18x cheaper than the strongest baseline using the same model. When integrated into an APR framework, BLAgent improves end-to-end repair success by up to 25%.