HAFixAgent: History-Aware Automated Program Repair Agent
Yu Shi, Hao Li, Bram Adams, Ahmed E. Hassan
2025-11-10
Summary
This paper explores how to make automated program repair, which tries to automatically fix bugs in code, even better by using the history of changes made to the code over time. Recent approaches use powerful AI models, but often only look at the current state of the code, ignoring valuable information from past versions.
What's the problem?
Current automated program repair systems, even those using advanced AI, often struggle with fixing complex bugs that require changes to multiple parts of the code. They tend to focus on the immediate problem area and don't take advantage of the fact that the history of how the code was written can often point directly to where the bug was introduced. Specifically, the last person to change a piece of code is often the one who accidentally created the bug.
What's the solution?
The researchers created a system called HAFixAgent, which is an AI agent designed to fix bugs. What makes it different is that it actively looks at the code's history – specifically, who last modified the buggy code and what changes they made. It uses this 'blame' information to guide its repair process, helping it to understand the context of the bug and suggest more accurate fixes. They tested it on a large set of real-world bugs and compared it to other state-of-the-art repair systems.
Why it matters?
This work is important because it shows that incorporating code history significantly improves the effectiveness of automated bug repair, especially for complicated bugs. It's also efficient, meaning it doesn't take much longer or cost much more to run, and it provides a practical way to build better bug-fixing AI. Ultimately, this could lead to tools that help developers fix bugs faster and more reliably, saving time and effort.
Abstract
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.