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
Figure 1. Distribution of the number of unique blame commits per bug category on (a) Defects4J and (b) BugsInPy. Defects4J blame is almost entirely concentrated in a single commit, while BugsInPy is often multi-commit for complex bug categories (49.0% of SFMH and 71.4% of MFMH bugs).
Figure 2. HAFixAgent architecture and workflow.
Table 1. History versus non-history across the three base models under perfect FL, with the external baselines. Each cell is #Pass, i.e., the number of bugs plausibly repaired (the Plausible@1 rate is #Pass / Total). Hybrid = number of bugs fixed by at least one of the three history heuristics ( fn_all , fn_pair , fl_diff ). Baseline = RepairAgent on the full Defects4J set and BIRCH-feedback on the Defects4J multi-hunk subset (its own denominator). Both are Java-only, so it is empty for the BugsInPy rows. Superscripts count the bugs a history configuration repairs that non-history does not. Bold = highest #Pass per category among the four HAFixAgent configurations and the Baseline. Hybrid is an oracle upper bound and is not bolded. A ∗ marks a configuration, an individual history heuristic or their Hybrid (union), that significantly repairs bugs non-history cannot fix (McNemar’s exact test versus non-history , Bonferroni α=0.05/4=0.0125 across the three heuristics and their union). A dash (-) marks a cell that does not apply.
Figure 3. Venn diagrams comparing bug repair overlap across the four context configurations on DeepSeek-V3.2-Exp, on Defects4J (top) and BugsInPy (bottom). Each number shows the count of bugs uniquely fixed by that intersection of configurations.
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%)
Table 2. Accuracy for the realistic spectrum-based fault localization (SBFL) used in RQ2 (Ochiai formula, line granularity). #Bugs is the number of SBFL-runnable bugs. Top- N is the number (percentage) of those bugs for which at least one developer-patched line is ranked within the top N suspicious lines.
Table 3. Repair effectiveness under realistic spectrum-based fault localization (SBFL) across the three base models, paired on the FL-runnable bugs per dataset (827 Defects4J, 361 BugsInPy). Each cell is the Plausible@1 success rate (%) under SBFL. The subscript is the change in percentage points relative to perfect FL on the same bugs (Table 1 provides perfect-FL results on the full benchmarks). Bold marks the best Overall rate per dataset among the four configurations. Category sizes (SL/SH/SFMH/MFMH) are 160/131/413/123 for Defects4J and 51/90/150/70 for BugsInPy.
Table 4. History versus non-history under realistic spectrum-based fault localization (SBFL) across the three base models, paired on the FL-runnable bugs per dataset (827 Defects4J, 361 BugsInPy, the same bugs for every model). Each cell is #Pass, i.e., the number of bugs plausibly repaired (the Plausible@1 rate is #Pass / Total). Superscripts count the bugs a history configuration repairs that non-history does not. Hybrid = number of bugs fixed by at least one of the three history heuristics ( fn_all , fn_pair , fl_diff ). Bold = best individual configuration per category, including non-history but excluding the Hybrid. A ∗ marks a history heuristic or Hybrid that repairs significantly more bugs than non-history (McNemar’s exact test versus non-history , Bonferroni α=0.05/4=0.0125 across the three heuristics and their union). Category sizes (SL/SH/SFMH/MFMH) are 160/131/413/123 for Defects4J and 51/90/150/70 for BugsInPy.
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
Table 5. Median cost (USD) and the number of agent steps for successful repairs on DeepSeek-V3.2-Exp under perfect fault localization, with Friedman test p -values for cost on the matched set (N = bugs fixed by all 4 configs). Bold p -values indicate significance ( p<0.05 ), and ∗ marks configs with significantly higher cost than non-history (pairwise Wilcoxon post-hoc, Bonferroni α=0.0167 ).
Median Cost (USD)
Median Steps
Dataset
Config
N
Perf.
SBFL
p
Perf.
SBFL
p
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
Table 6. Effect of realistic fault localization on repair cost on DeepSeek-V3.2-Exp, measured per bug. For each configuration, on the cases it solves under both perfect and SBFL FL ( N ), we report median cost (USD) and the number of agent steps in each regime. The p columns show the results of Wilcoxon signed-rank tests pairing each bug’s perfect-FL value against its own SBFL value. SBFL significantly raises both cost and effort relative to perfect FL for every configuration on both benchmarks (all p<0.05 ).
FL
Dataset ( N )
Variant
Fixed
Runs
Cost ($)
Steps
Perfect
Defects4J N=854
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 N=501
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
Table 7. Cost of the hybrid approach (the union of fn_all , fn_pair , and fl_diff ) on DeepSeek-V3.2-Exp under perfect and realistic (SBFL) fault localization, with fl_diff alone as the reference. The brute-force variant runs all three heuristics and keeps any test-passing patch, while the cascade variant halts at the first pass in the fixed order fn_all , fn_pair , fl_diff . Fixed counts repaired bugs, Runs the mean heuristics executed per bug. Cost and steps are per-bug means over all N bugs (including failed attempts), unlike the success-only medians of Table 5 . Under SBFL, N covers the bugs whose four SBFL runs all recorded cost. In every setting, the hybrid costs significantly more than one non-history run (paired Wilcoxon on per-bug cost, all p<0.01 ).
Table 8. Representative bugs repaired by one of the three history heuristics but not by non-history , covering both benchmarks and all four bug categories. The last column describes the blame commit’s change and how it guided the fix, as recorded in the saved agent trajectory.