AI
New Framework Tackles Over-Editing Problem in AI-Assisted Code Repair
Researchers introduce PRepair, which trains language models to fix bugs precisely by modifying only problematic code while preserving correct sections.
Large language models have become powerful tools for fixing code automatically, yet they frequently struggle with a critical flaw: they tinker with sections of code that are already working correctly, inadvertently breaking functionality and obscuring the actual location of bugs. Researchers have now formalized this challenge as a "precise repair" problem and developed a framework to address it.
The Over-Editing Problem#
When LLMs attempt to repair buggy programs, they don't always show restraint. Rather than making surgical changes to fix broken logic, they often rewrite substantial portions of code—including parts that function as intended. This excessive editing undermines two key goals: it reduces the likelihood that the repair actually works, and it complicates the process of isolating which sections of code were truly responsible for the original failure.
Introducing PRepair#
The proposed solution, called PRepair, works in two interconnected stages. The first, Self-Breaking, generates a diverse set of intentionally flawed programs by injecting controlled bugs and using min-max sampling techniques. This provides rich training material that exposes models to varied failure modes.
The second stage, Self-Repairing, trains models using a novel optimization method called Edit-Aware Group Relative Policy Optimization (EA-GRPO). The key innovation is an edit-aware reward mechanism that encourages the model to make corrections while changing as little code as possible—rewarding precision over wholesale rewrites.
Performance and Practical Impact#
Empirical results demonstrate meaningful improvements. The framework boosts repair precision by as much as 31.4% when measured on fix₁@1, a metric that jointly evaluates both whether repairs work and how much of the original code they preserve. Additionally, when combined with speculative editing techniques, PRepair significantly accelerates decoding throughput, suggesting practical viability for real-world deployment.

