Refine After Generation: Toward Correct and Concise Patches in LLM-based Program Repair

📅 2026-08-13
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This study addresses the pervasive redundancy in program repair patches generated by large language models (LLMs), which are significantly larger and more complex than developer-written patches, thereby undermining their reviewability and practicality. The work presents the first systematic characterization of this redundancy and introduces a novel post-processing paradigm that decouples minimization from patch generation, overcoming limitations of prior approaches reliant on prompting or format constraints. To this end, the authors construct a multi-source patch-pair dataset and train RECAP—a plug-and-play refiner—using supervised fine-tuning, direct preference optimization, and reasoning trace distillation. Experiments demonstrate that RECAP reduces total code changes from +242.14% to +4.24% and net changes from +348.24% to −39.75% relative to developer patches, while preserving correctness and yielding up to 42 additional successfully repaired instances.
📝 Abstract
Large language models (LLMs) have advanced automatic program repair (APR) to the point where agentic systems routinely resolve real-world, repository-level issues. Yet the generated patch has received little scrutiny beyond whether it passes tests. In this paper, we identify patch verbosity as a major yet overlooked concern in LLM-based APR. Characterizing 28 state-of-the-art approaches on SWE-bench Verified, we find that even successful patches are consistently larger and more complex than developer patches, with the median approach producing 121.78% more total changes, 80.91% more net changes, and 43.99% higher cyclomatic complexity. We further show that this verbosity is rooted in capability-oriented design choices such as iterative refinement and broad context, and can hardly be reduced by surface-level controls such as output format or minimality prompts. Motivated by these findings, we formulate post-generation patch refinement and propose RECAP, a lightweight, plug-and-play adapter that attaches to existing repair frameworks after generation. RECAP's refiner is trained via supervised fine-tuning and direct preference optimization with distilled reasoning traces, on a dataset of patch pairs we construct from multiple sources. Across four host systems, prompting, commit-untangling, and minimality-aware baselines reduce patch size only by sacrificing 49 to 217 resolved instances. In contrast, RECAP achieves a substantially better size-correctness tradeoff, cutting average total changes from +242.14% to +4.24% and net changes from +348.24% to -39.75% relative to developer patches while preserving or improving resolution by up to 42 instances. Our results indicate that minimality cannot be simply reduced to syntactic compression, and that decoupling minimization from generation offers a practical path to more reviewable repairs.
Problem

Research questions and friction points this paper is trying to address.

patch verbosity
automatic program repair
large language models
code minimality
cyclomatic complexity
Innovation

Methods, ideas, or system contributions that make the work stand out.

patch verbosity
post-generation refinement
program repair
large language models
minimality
🔎 Similar Papers
W
Wenqiang Luo
Department of Computer Science, City University of Hong Kong, Hong Kong, China
J
Jacky Keung
Department of Computer Science, City University of Hong Kong, Hong Kong, China
X
Xiaoyu Shi
Department of Computer Science, Aalto University, Espoo, Finland
Y
Yicheng Sun
Department of Computer Science, City University of Hong Kong, Hong Kong, China
Boyang Yang
Boyang Yang
Jisuan Institute of Technology, Beijing JudaoYouda Network Technology Co. Ltd.
AI4SECS EducationLLM4SEProgram RepairSoftware Engineering
Zhou Yang
Zhou Yang
University of Alberta, Amii
Software EngineeringAI4SESE4AI
Haoye Tian
Haoye Tian
Assistant Professor, Aalto University
Software EngineeringMachine LearningProgram RepairAI4SELLM4SE