ChatPaper.aiChatPaper

HAFixAgent:具歷史感知的自動化程式修復代理

HAFixAgent: History-Aware Automated Program Repair Agent

November 2, 2025
作者: Yu Shi, Hao Li, Bram Adams, Ahmed E. Hassan
cs.AI

摘要

近年來,自動化程式修復(APR)領域逐漸轉向大型語言模型與基於代理的系統,然而多數系統僅依賴本地快照上下文,忽略了儲存庫歷史。既有研究顯示,儲存庫歷史有助於修復單行程式碼錯誤,因為最後一次觸及錯誤程式行的提交往往就是引入錯誤的提交。本文探討儲存庫歷史是否能大規模提升代理式APR系統效能,特別針對複雜的多區塊錯誤。我們提出HAFixAgent——具歷史感知的錯誤修復代理,其修復循環中注入了源自追溯標記的儲存庫啟發式策略。針對Defects4J中854個真實錯誤的初步研究啟發了我們的設計,顯示錯誤相關歷史不僅廣泛存在且高度集中。HAFixAgent與兩種頂尖基線方法的實證比較表明:(1)有效性:相較於代理式基線(提升212.3%)與多區塊修復基線(提升29.9%),HAFixAgent實現顯著進步;(2)效率:歷史資訊未顯著增加代理步驟數,且令牌成本保持相當水準,對於複雜的多檔案多區塊錯誤更呈現明顯較低的中位數成本;(3)實用性:結合不同歷史啟發式策略可修復更多錯誤,提供清晰的成本效益權衡。HAFixAgent為具歷史感知的代理式APR提供實用方案:將代理扎根於版本控制歷史,優先採用基於差異比對的歷史上下文,並在需要時整合互補的啟發式策略。
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 of all 854 real-world bugs from Defects4J motivates our design, showing that bug-relevant history is both widely available and highly concentrated. Empirical comparison of HAFixAgent with two state-of-the-art baselines shows: (1) Effectiveness: HAFixAgent significantly improves over the agent-based baseline (by 212.3%) and the multi-hunk baseline (by 29.9%). (2) Efficiency: history does not significantly increase agent steps and keeps token costs comparable, with notably lower median costs for complex multi-file-multi-hunk bugs. (3) Practicality: combining different historical heuristics repairs more bugs, offering a clear cost-benefit trade-off. HAFixAgent offers a practical recipe for history-aware agentic APR: ground the agent in version control history, prioritize diff-based historical context, and integrate complementary heuristics when needed.
PDF32December 2, 2025