From Historical Patches to Repair Plans: Outcome-Conditioned Reasoning for Repository-Level Program Repair
Abstract
Repository-level automated program repair (APR) requires long-horizon reasoning over interdependent decisions. However, most LLM-based approaches reconstruct repair reasoning independently for each issue, failing to reuse successful patterns from prior repairs, even though real-world repositories contain many related issues with shared structure or constraints. Existing methods typically rely on forward exploration, which operates under outcome uncertainty, incurs substantial inference-time overhead, and can drift from the final correct patch. We propose Conditional Reasoning Distillation (ConRAD), which leverages in-repository resolved issues by reconstructing repair reasoning backward from verified patches and distilling outcome-consistent, stage-wise repair reasoning plans. Injected at inference time, these plans guide fault localization and patch generation, replacing open-ended exploration with constrained inference without fine-tuning or search. On SWE-Bench Lite, ConRAD improves Pass@1 by 10.4\% (GPT-4o), 8.6\% (DeepSeek-V3), and 10.3\% (GPT-5), demonstrating a scalable inference-time alternative to forward exploration for long-horizon APR.
Lay Summary
Repository-level automated program repair (APR) requires long-horizon reasoning over many interdependent steps — interpreting an issue, locating the faulty files and functions, understanding project-specific constraints, and finally synthesizing a patch. These stages are tightly coupled, so an early mistake (such as incorrect fault localization) often cascades downstream into a failed fix. Most LLM-based APR methods make this harder by treating each issue as an independent problem, reconstructing reasoning from scratch and ignoring that real repositories usually contain many related, already-resolved issues with shared structure or constraints. To cope with limited supervision, many methods rely on forward exploration (e.g., iterative refinement or Monte Carlo Tree Search), which reasons under outcome uncertainty, incurs heavy inference-time cost, and can drift away from the correct patch. We propose ConRAD (Conditional Reasoning Distillation). The key idea is that a resolved issue's verified ground-truth patch defines a known-correct outcome to condition on. Instead of exploring forward, ConRAD reconstructs repair reasoning backward from that patch, distilling outcome-consistent, stage-wise repair plans for file localization, function localization, and patch generation. A conservative filter, the Exemplar Guardian, discards historical exemplars likely to induce negative transfer. The distilled plans are injected as in-context guidance at inference time — requiring no fine-tuning or search. On SWE-Bench Lite, ConRAD improves Pass@1 by 10.4% (GPT-4o), 8.6% (DeepSeek-V3), and 10.3% (GPT-5), and beats an MCTS baseline by 13.0% while using 9.71× fewer LLM calls and 2.47× fewer tokens — a scalable, compute-efficient alternative to forward exploration.