arXiv:2511.01047cs.SEcs.AI2025-11被引 2

让程序修复智能体学会看代码历史,显著提升复杂错误修复成功率。

HAFixAgent: History-Aware Program Repair Agent

  • 引入代码仓库历史信息作为修复线索,指导智能体决策。
  • 在多行改动的复杂错误上,修复成功率提升38.6%以上。
  • 对错误定位噪声有强鲁棒性,适合实际开发场景使用。

自动化程序修复(APR)正转向大语言模型与基于智能体的系统,但多数系统仅依赖局部快照上下文,忽略代码仓库历史。已有研究表明,修复单行错误时,最近修改该行的提交通常就是引入错误的提交。本文研究代码历史是否能在大规模下提升智能体式修复系统的性能,尤其针对复杂的多片段错误。我们提出HAFixAgent,一种具备历史感知能力的修复智能体,将基于责任追溯的仓库启发式信息注入修复循环。对854个Defects4J(Java)和501个BugsInPy(Python)错误的初步研究验证了这一设计:错误相关的历史信息在两个基准中广泛存在。所有实验均使用同一LLM(DeepSeek-V3.2-Exp),结果表明:(1)有效性:在Defects4J上,HAFixAgent优于RepairAgent(+56.6%)和BIRCH-feedback(+47.1%);历史上下文进一步提升修复率,分别在Defects4J上+4.4%、BugsInPy上+38.6%,尤其在单文件多片段(SFMH)错误上表现突出。(2)鲁棒性:在错误定位存在+1/+3/+5行偏移的噪声条件下,历史信息带来持续提升,使SFMH错误的成功率维持在40%~56%,而无历史基线则降至0%。(3)效率:历史信息未显著增加智能体步数或令牌消耗。

原文摘要 · Abstract (English)

Automated program repair (APR) has recently shifted toward large language models and agent-based systems, yet most systems rely on local snapshot context, overlooking repository history. Prior work shows that repository history helps repair single-line bugs, since the last commit touching the buggy line is often the bug-introducing one. In this paper, we investigate whether repository history can also improve agentic APR systems at scale, especially for complex multi-hunk bugs. We present HAFixAgent, a History-Aware Bug-Fixing Agent that injects blame-derived repository heuristics into its repair loop. A preliminary study on 854 Defects4J (Java) and 501 BugsInPy (Python) bugs motivates our design, showing that bug-relevant history is widely available across both benchmarks. Using the same LLM (DeepSeek-V3.2-Exp) for all experiments, including replicated baselines, we show: (1) Effectiveness: HAFixAgent outperforms RepairAgent (+56.6\%) and BIRCH-feedback (+47.1\%) on Defects4J. Historical context further improves repair by +4.4\% on Defects4J and +38.6\% on BugsInPy, especially on single-file multi-hunk (SFMH) bugs. (2) Robustness: under noisy fault localization (+1/+3/+5 line shifts), history provides increasing resilience, maintaining 40 to 56\% success on SFMH bugs where the non-history baseline collapses to 0\%. (3) Efficiency: history does not significantly increase agent steps or token costs on either benchmark.

程序修复智能体代码历史LLM

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。