Introduction
Large Language Models (LLMs) have significantly advanced Automated Program Repair (APR), enabling the resolution of complex, repository-level bugs. However, state-of-the-art agents often produce "Draft Patches"—solutions that are nearly correct but fail due to being incomplete or overfitted. Incomplete patches address core symptoms while missing necessary secondary changes, while overfitted patches fix specific examples in bug reports without addressing underlying logic. These failures often stem from a lack of deep context and an inability to foresee how small changes ripple through a large codebase.
The REFINE Framework
To address these limitations, we present REFINE, a novel framework designed as a context-aware post-processing layer for existing APR agents. REFINE transforms the repair process from a single-shot generation into a structured, multi-stage refinement pipeline.
The pipeline consists of three primary stages:
- Context Extraction and Regularization: Specialized agents extract structured "Issue Context" (defining logic, actions, and constraints) and "Code Context" (mapping data dependencies and call graphs). This regularizes messy natural language into a logical blueprint.
- Diverse Delta Patch Generation: Utilizing test-time scaling, REFINE generates multiple "delta patches"—small, targeted edits—by sampling the LLM with varying parameters to explore a wider solution space.
- Aggregated Patch Synthesis: A multi-agent committee, including Reviewer and Aggregation agents, filters irrelevant edits and merges non-conflicting changes, resolving potential conflicts before a final Validator checks the result against regression tests.
Evaluation and Benchmarks
REFINE was evaluated on two major benchmarks:
- SWE-Bench Lite: 300 real-world GitHub issues across 12 Python repositories.
- SWE-Bench Verified: 500 issues with manually verified, high-quality unit tests.
Key Results
REFINE demonstrates significant performance gains across various underlying APR systems. By treating repair as an iterative refinement process, it consistently bridges the gap between draft and correct patches.
Key findings include:
- State-of-the-Art Performance: Integrated with AutoCodeRover, REFINE achieved a 51.67% resolution rate on SWE-Bench Lite, a 14.67% absolute increase over the baseline.
- Broad Consistency: Across systems like CodeV, Agentless, and BlackBoxAI, REFINE provided an average improvement of 14%.
- Unique Fixes: Analysis revealed that REFINE resolved 16 unique issues that no baseline model could fix, proving its efficacy on particularly difficult bugs.
Insights and Discussion
The success of REFINE highlights several critical aspects of modern APR:
- Structured Semantics: LLMs perform better when forced to regularize a problem—explicitly stating constraints and generalization—before writing code.
- The Power of Diversity: Aggregating multiple "near-correct" ideas often yields a comprehensive solution that no single generation could produce.
- Tool-Agnosticism: As a "plugin" layer, REFINE addresses a universal "refinement gap" present in all current state-of-the-art APR systems.
Limitations and Future Work
While effective, REFINE introduces higher computational costs due to multiple LLM calls and test-time scaling, averaging ~$6.59 per issue. Future work will focus on optimizing the cost-to-performance ratio and exploring more sophisticated reviewer models. Additionally, ensuring safety against "hallucinated" fixes that pass tests but introduce security flaws remains a priority, suggesting that human-in-the-loop review continues to be essential for industrial applications.
Summary updated