HAFixAgent: History-Aware Agentic Program Repair
Organizations: Queen’s University, Kingston, Canada
Abstract
Automated program repair (APR) has recently shifted toward large language models and agent-based systems, while prior work shows that repository history can help repair single-line bugs. We conduct a large-scale empirical study of whether, how much, and under what conditions repository history improves agentic APR beyond this setting. We present HAFixAgent, a history-aware program repair agent that injects blame-derived repository context into its repair loop. Across 854 Defects4J (Java) and 501 BugsInPy (Python) bugs, we first show that bug-relevant history is widely available. We then evaluate HAFixAgent across three base models under perfect fault localization. The best history heuristic improves over non-history from +4.4% on Defects4J and +1.1% on BugsInPy with the strongest model to as much as +64.3% with weaker models. HAFixAgent also outperforms RepairAgent by +56.6% and BIRCH-feedback by +47.1% on the strongest model, showing that it is a strong repair agent independent of history. The three history heuristics are complementary: each repairs a different subset of bugs, so their hybrid significantly repairs more bugs than non-history (McNemar's test, p < 0.001), and this advantage persists under realistic spectrum-based fault localization. Individual history heuristics are generally no more expensive than non-history in agent steps or tokens under either localization setting, while the hybrid costs roughly twice a single run in a cascade setting.
Figures & tables
| Benchmark | FL tool | #Bugs | Top-1 | Top-3 | Top-5 | Top-10 |
|---|---|---|---|---|---|---|
| Defects4J | GZoltar 1.7.3 | 827 | 40 (5%) | 137 (17%) | 183 (22%) | 245 (30%) |
| BugsInPy | FauxPy 0.7.0 | 361 | 13 (4%) | 54 (15%) | 71 (20%) | 107 (30%) |
| Median Cost (USD) | Median Steps | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Dataset | Cat. | N | non-history | fn_all | fn_pair | fl_diff | non-history | fn_all | fn_pair | fl_diff | Fried. p |
| Defects4J | SL | 118 | 0.005 | 0.008 ∗ | 0.005 | 0.008 ∗ | 12 | 14 | 13 | 16 | 0.001 |
| SH | 72 | 0.016 | 0.019 | 0.015 | 0.014 | 23 | 25 | 24 | 22 | 0.184 | |
| SFMH | 140 | 0.016 | 0.020 | 0.016 | 0.021 | 26 | 28 | 26 | 30 | 0.122 | |
| MFMH | 22 | 0.029 | 0.026 | 0.023 | 0.023 | 34 | 29 | 32 | 30 | 0.142 | |
| BugsInPy | SL | 59 | 0.027 | 0.029 | 0.020 | 0.033 | 19 | 19 | 18 | 18 | 0.214 |
| Median Cost (USD) | Median Steps | |||||||
|---|---|---|---|---|---|---|---|---|
| Dataset | Config | N | Perf. | SBFL | Perf. | SBFL | ||
| Defects4J | non-history | 352 | 0.010 | 0.038 | 0.001 | 20 | 30 | 0.001 |
| fn_all | 362 | 0.013 | 0.043 | 0.001 | 20 | 28 | 0.001 | |
| fn_pair | 369 | 0.011 | 0.039 | 0.001 | 20 | 29 | 0.001 | |
| fl_diff | 362 | 0.013 | 0.037 | 0.001 | 21 | 29 | 0.001 | |
| BugsInPy | non-history | 168 | 0.036 | 0.045 | 0.016 | 22 | 28 | 0.001 |
| FL | Dataset ( ) | Variant | Fixed | Runs | Cost ($) | Steps |
|---|---|---|---|---|---|---|
| Perfect | Defects4J | fl_diff only | 545 | 1.00 | 0.034 | 34.2 |
| Hybrid, cascade | 684 | 1.64 | 0.067 | 64.0 | ||
| Hybrid, brute-force | 684 | 3.00 | 0.104 | 103.0 | ||
| BugsInPy | fl_diff only | 374 | 1.00 | 0.086 | 29.0 | |
| Hybrid, cascade | 463 | 1.36 | 0.118 | 42.2 | ||
| Hybrid, brute-force | 463 | 3.00 | 0.240 | 87.3 |
Automated Program Repair
Automated program repair develops methods that locate software faults and produce validated fixes with limited human effort.
See all 158 papersProject Prometheus: Bridging the Intent Gap in Agentic Program Repair via Reverse-Engineered Executable Specifications
Intent Gap'' -- the misalignment between the generated patch and the developer's original intent. Current solutions relying on natural language summaries or adversarial sampling often fail to provide the deterministic constraints required for surgical repairs. In this paper, we introduce Prometheus, a novel framework that bridges this gap by prioritizing *Specification Inference* over code generation. We employ Behavior-Driven Development (BDD) as an executable contract, utilizing a multi-agent architecture to reverse-engineer Gherkin specifications from runtime failure reports. To resolve the Hallucination of Intent,'' we propose a Requirement Quality Assurance (RQA) Loop, a mechanism that leverages ground-truth code as a proxy oracle to validate inferred specifications. We evaluated Prometheus on 680 defects from the Defects4J benchmark. The results are transformative: our framework achieved a total correct patch rate of 93.97% (639/680). More significantly, it demonstrated a Rescue Rate of 74.4%, successfully repairing 119 complex bugs that a strong blind agent failed to resolve. Qualitative analysis reveals that explicit intent guides agents away from structurally invasive over-engineering toward precise, minimal corrections. Our findings suggest that the future of APR lies not in larger models, but in the capability to align code with verified, Executable Specifications -- whether pre-existing or reverse-engineered.