2026

Large Language Models have shown remarkable potential in automated code generation, yet the programs they produce frequently fail due to logical flaws or unhandled edge cases. To address this, we propose RA-CRF, a Retrieval-Augmented Code Repair Framework that explicitly integrates a structured Error-Repair Knowledge Graph (ERKG). Unlike existing methods that rely on unstructured self-reflection or raw execution feedback, our framework constructs a hierarchical taxonomy connecting error types to specific repair strategies. By leveraging execution feedback, the framework retrieves relevant knowledge to generate structured repair documents, effectively decoupling error diagnosis from targeted code editing. Furthermore, we introduce an adaptive self-evolution mechanism that continuously refines the ERKG by persisting verified repair results. Experimental results on single-function benchmarks including BigCodeBench demonstrate that RA-CRF achieves significant performance gains across various open-source and closed-source models. Notably, RA-CRF lifts DeepSeek-V3 to 65.52% Pass@1, a new best on the official BigCodeBench leaderboard. Our findings indicate that integrating explicit and evolvable error-correction knowledge is a robust path to enhancing the reliability and interpretability of code generated by large language models.