Better Understanding, Better Fixes? A Study of Hallucination in LLM-based Automated Program Repair

Xuemeng Cai and colleagues at Singapore Management University and Harbin Institute of Technology measure hallucination not only in the final patch of an LLM program repair run but in the intermediate artifacts that lead to it, over 832 Defects4J bugs and three models.
Ask this paper
Definition used: A hallucination is a patch or intermediate artifact not faithfully grounded in the available repair evidence, which lets the study score reasoning steps rather than only outcomes.
Three intermediate tasks probed: Triggering testcase identification, line coverage prediction, and additional testcase generation.
Repair rates: Only 21.0% to 55.9% of generated patches pass the developer-written test suite across models and settings.
The finding that matters for evaluation: Manual analysis of 812 sampled repairs found repair hallucinations in 72.7% of cases, including patches that pass all available tests. Incorrect causal localization accounts for 45.9% of these and incorrect repair strategy for 18.5%. More accurate intermediate artifacts are generally associated with successful repairs, but the relationship does not always hold.
Abstract
Large language models (LLMs) have significantly advanced automated program repair (APR), yet existing evaluations remain largely result-centric and provide limited insight into hallucination during repair. In APR, hallucination may arise not only in final patches but also in the intermediate artifacts that guide patch generation. To address this gap, we perform a multi-layered analysis of hallucination throughout the APR process. Specifically, we characterize hallucination as the production of patches or intermediate artifacts that are not faithfully grounded in the available repair evidence. We examine repair hallucination in final patches and understanding hallucination in intermediate artifacts through three tasks, namely triggering testcase identification, line coverage prediction, and additional testcase generation.We then evaluate three representative LLMs on 832 Defects4J bugs through automatic evaluation and manual analysis. Our results show that both repair and understanding hallucinations remain prevalent. Across models and settings, only 21.0%-55.9% of generated patches pass the developer-written test suite. Moreover, although more accurate intermediate artifacts are generally associated with successful repairs, this relationship does not always hold. Manual analysis of 812 sampled repairs identifies repair hallucinations in 72.7% of cases, including patches that pass all available tests; incorrect causal localization and incorrect repair strategies account for 45.9% and 18.5% of these hallucinations, respectively. Meanwhile, models frequently misidentify triggering testcases, mispredict line coverage involving branching control flow, and generate additional testcases with missing bug-triggering conditions or incorrect expected behavior.