REFINE: Enhancing Program Repair Agents through Context-Aware Patch Refinement

Anvith Pabba, Simin Chen, Alex Mathai, Anindya Chakraborty, Baishakhi RayarXiv 2025 · DOI

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 REFINE multi-agent pipeline architecture, illustrating the flow from context extraction to final patch validation.

The pipeline consists of three primary stages:

  1. 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.
  2. 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.
  3. 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.

Performance comparison showing the improvement in resolution rates across different APR agents after applying REFINE.

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

BibTeX
@misc{pabba2025refine,
  author = {Anvith Pabba and Simin Chen and Alex Mathai and Anindya Chakraborty and Baishakhi Ray},
  title = {{REFINE: Enhancing Program Repair Agents through Context-Aware Patch Refinement}},
  year = {2025},
  eprint = {2510.03588},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.03588},
}
Figure