一句话:提出 ReduceFix,用 LLM 生成自动归约器缩小失败测试输入,缓解长提示的 lost-in-the-middle 问题,显著提升修复成功率。
基于 LLM 的自动程序修复(APR)通常需要把测试输入放进提示中以帮助推断失败根因,但输入过长会让 LLM 难以保留关键信息,触发“lost-in-the-middle”问题并损害修复效果。本文提出 ReduceFix:它提示 LLM 自动生成一个输入归约器,在保持失败触发行为的前提下最小化失败输入,再把归约后的输入用于指导补丁生成,全程无需人工参与。为针对性评估,作者构建了首个长输入 APR 基准 LFTBench,包含 20 个编程任务中的 200 个真实缺陷,每个缺陷配有中位大小约 1MB 的失败输入。实验显示,ReduceFix 平均将输入缩小 89.1%,相比包含原始测试的提示最高提升 53.8% 的 pass@10,相比完全省略测试的提示提升 17.6%;把同样的归约步骤加入 ChatRepair 与 CREF 可分别提升 21.3% 与 2.6% 的修复率,且在仅用 ddmin 的归约模板基线和仓库级 OSS-Fuzz 案例上依然有效。消融实验进一步说明了输入长度与压缩后失败信息对修复成功的影响。
Large Language Models (LLMs) have shown great potential in Automated Program Repair (APR). Test inputs, being crucial for reasoning the root cause of failures, are always included in the prompt for LLM-based APR. Unfortunately, LLMs struggle to retain key information in long prompts. When the test inputs are extensive in the prompt, this may trigger the “lost-in-the-middle” issue, compromising repair performance. To address this, we propose ReduceFix, an LLM-based APR approach with a built-in component that automatically reduces test inputs while retaining their failure-inducing behavior. ReduceFix prompts an LLM to generate a reducer that minimizes failure-inducing test inputs without human effort, and then feeds the reduced failure-inducing inputs to guide patch generation. For targeted evaluation, we constructed LFTBench, the first long-input APR benchmark with 200 real bugs from 20 programming tasks, each paired with a failure-inducing input whose median size is 1 MB. On this benchmark, ReduceFix shrinks inputs by 89.1% on average and improves overall pass@10 by up to 53.8% relative to a prompt that includes the original test, and by 17.6% compared with omitting the test entirely. Adding the same reduction step to ChatRepair and CREF increases their fix rate by 21.3% and 2.6%, respectively, without other changes. Our gains hold against a ddmin-only reducing template baseline and transfer to repository-level OSS-Fuzz cases. Ablation studies further highlight the impact of input length and compressed failure information on repair success. These results underscore that automatically reducing failing inputs is a practical and powerful complement to LLM-based APR, significantly improving its scalability and effectiveness.