HAFixAgent: History-Aware Automated Program Repair Agent DOI: XXXXXXX.XXXXXXX ISBN: 978-1-4503-XXXX-X/2018/06 CCS: Software and its engineering Software testing and debugging CCS: Computing methodologies Artificial intelligence

Yu Shi, Hao Li, Bram Adams, Ahmed E. Hassan · 2025

Read HAFixAgent: History-Aware Automated Program Repair Agent DOI: XXXXXXX.XXXXXXX ISBN: 978-1-4503-XXXX-X/2018/06 CCS: Software and its engineering Software testing and debugging CCS: Computing methodologies Artificial intelligence by Yu Shi, Hao Li, Bram Adams, Ahmed E. Hassan (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2511-01047.txt.

Introduction

Yu Shi, Hao Li, Bram Adams, and Ahmed Hassan study whether a code repository's history can help an automated agent fix bugs. Earlier work showed history helps with single line bugs. Their system, HAFixAgent, feeds context drawn from blame information, which records who last changed each line, into an agent's repair loop.

The study covers hundreds of Java bugs from Defects4J and Python bugs from BugsInPy, across three base language models. History proved widely available and useful: the best heuristic added a few percent for the strongest model and far more for weaker ones. Three different history heuristics fixed different subsets of bugs, so combining them repaired greatly more than no history, at no extra cost in steps or tokens.

Catalog record

CREATORYu Shi, Hao Li, Bram Adams, Ahmed E. Hassan
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE77 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2511-01047

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

HAFixAgent: History-Aware Automated Program Repair Agent DOI: XXXXXXX.XXXXXXX ISBN: 978-1-4503-XXXX-X/2018/06 CCS: Software and its engineering Software testing and debugging CCS: Computing methodologies Artificial intelligence Yu Shi, Hao Li, Bram Adams, Ahmed E. Hassan 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 H istory- A ware Bug- Fix ing 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. 1. Introduction Software bugs are an inevitable and costly aspect of software development, leading to system failures, security vulnerabilities, and degraded user experience ( 4 ; 79 ; 66 ) . Since manually identifying and fixing these bugs consumes significant developer time and resources, automated program repair (APR) has been an active and promising research direction for over a decade, aiming to mitigate this burden by automatically generating patches for detected bugs ( 33 ) . APR has evolved from heuristic-based ( 32 ; 35 ; 67 ) , constraint-based ( 34 ; 48 ; 44 ) , and template-based techniques ( 43 ; 47 ; 42 ) to learning-based methods ( 9 ; 27 ; 40 ; 45 ; 82 ; 83 ; 77 ) and, most recently, large language model-based approaches ( 80 ; 26 ; 24 ; 70 ; 72 ; 69 ; 16 ; 78 ; 25 ; 38 ; 60 ) and agent-based approaches ( 75 ; 5 ; 50 ; 49 ; 36 ; 81 ; 7 ; 65 ) . However, despite substantial progress, reliably repairing complex bugs remains a persistent challenge. Particularly difficult are bugs that span multiple lines and locations (e.g., multi-hunks), which require coordinated, potentially non-local edits across different parts of the codebase. Recent characterizations, such as the work by 51 , highlight that these bugs are not only common but also significantly harder for current LLM-based approaches compared to simpler single-hunk fixes. Overcoming this complexity barrier is crucial for APR approaches to be broadly applicable in real-world software development. To address such complex bugs, recent advances in APR have pursued two promising yet separate directions. First, agent-based approaches have emerged as the state-of-the-art ( 5 ; 75 ; 65 ) . Agent-based approaches like RepairAgent ( 5 ) leverage LLMs to plan, execute actions via software tools (e.g., code search, editing, testing), and react to iterative feedback, enabling them to tackle more complex reasoning compared to simple prompting. However, these agents typically operate only on the current code snapshot and immediate test results, lacking deeper historical context. Second, drawing from decades of mining software repositories research ( 63 ; 23 ; 1 ) , recent APR techniques started to recognize the value of historical code context. Our prior work ( 60 ) showed that injecting historical context derived from git blame 1 1 1 https://git-scm.com/docs/git-blame commits (the last change touching a buggy line) can improve LLM repair performance for single-line bugs using simple prompting. However, this approach lacked the sophisticated reasoning and tool interaction capabilities of agents, limiting its potential for complex, multi-location repairs. We hypothesize that combining the iterative, tool-using capabilities of agentic workflows with the rich, contextual clues found in repository history can significantly enhance APR, particularly for complex multi-hunk bugs. History provides information on relevant past changes, developer rationale, and co-evolution patterns, while the agent leverages tools to explore, validate, and integrate this historical context dynamically during the repair process. Yet, it is unclear whether this approach scales. Complex multi-hunk bugs could have many different blame commits, potentially overwhelming the agent with noisy and irrelevant signals rather than providing a focused context. We design HAFixAgent , a history-aware agent for APR that integrates history heuristics (inspired by our prior HAFix work ( 60 ) ) to enable the agent to leverage historical context alongside bash command tools during its autonomous execution. To evaluate the effectiveness of HAFixAgent, we apply it to all 854 bugs in the Defects4J ( 29 ) dataset, a widely used benchmark for evaluating APR techniques. In this study, we address the following research questions (RQs): • RQ0. To What Extent Is Historical Information Available in Real-World Bugs? Before integrating repository history, we have to first establish if relevant historical information is broadly available and scalable for use in APR. Specifically, we analyze the Defects4J dataset to measure the availability and concentration of historical information for bugs. Our findings confirm that 71.1% of bugs have available historical information and most map to a single unique blame commit. This result directly supports the feasibility of using a simple, single-commit heuristic for HAFixAgent, even for complex bugs. • RQ1. How Effective Is HAFixAgent at Fixing Real-World Bugs? We empirically compare HAFixAgent to recent APR systems and also quantify the extent to which any improvements are attributable to the introduction of historical context as opposed to the adoption of an agent architecture. For this, we evaluate HAFixAgent’s effectiveness against two state-of-the-art baselines on the Defects4J dataset: one for common bugs ( 5 ) and another specializing in multi-hunk repairs ( 51 ) . The results show that HAFixAgent repairs 212.3% more bugs than the baseline for common bugs and outperforms the multi-hunk baseline by 29.9%. • RQ2. What Are the Cost and Efficiency of HAFixAgent? Historical grounding should not inflate agent loops or token usage. We track token costs of HAFixAgent under different configurations and compare the costs. We found that integrating history into the agent repair loop is cost-efficient overall, without notable overhead. The main contributions of our paper are as follows: • The design and implementation of HAFixAgent, a novel history-aware agentic approach for APR that enriches its decision-making loop with deep repository context. • A practical and automated method for constructing historical context, featuring three distinct blame-derived historical heuristics and a robust fallback strategy designed for any agentic APR system. • A large-scale empirical evaluation on all 854 Defects4J bugs, providing strong evidence that history is (1) broadly available (71.1% blameable) and highly concentrated (with 70.7% of bugs mapping to a single commit), and (2) significantly improves agent effectiveness and efficiency. We will release the complete replication package of code and the evaluation script after the revision is completed. In the interim, please contact

Read the complete text