[Paper Review] Automated Repair of Programs from Large Language Models
This paper investigates whether automated program repair (APR) techniques can improve the reliability of code generated by large language models like Codex, particularly in competitive programming contexts. It finds that APR tools—especially Codex's edit mode—can effectively fix many bugs in auto-generated code when guided by fault localization, suggesting that combining language models with APR could significantly enhance code quality and robustness.
Large language models such as Codex, have shown the capability to produce code for many programming tasks. However, the success rate of existing models is low, especially for complex programming tasks. One of the reasons is that language models lack awareness of program semantics, resulting in incorrect programs, or even programs which do not compile. In this paper, we systematically study whether automated program repair (APR) techniques can fix the incorrect solutions produced by language models in LeetCode contests. The goal is to study whether APR techniques can enhance reliability in the code produced by large language models. Our study revealed that: (1) automatically generated code shares common programming mistakes with human-crafted solutions, indicating APR techniques may have potential to fix auto-generated code; (2) given bug location information provided by a statistical fault localization approach, the newly released Codex edit mode, which supports editing code, is similar to or better than existing Java repair tools TBar and Recoder in fixing incorrect solutions. By analyzing the experimental results generated by these tools, we provide several suggestions: (1) enhancing APR tools to surpass limitations in patch space (e.g., introducing more flexible fault localization) is desirable; (2) as large language models can derive more fix patterns by training on more data, future APR tools could shift focus from adding more fix patterns to synthesis/semantics based approaches, (3) combination of language models with APR to curate patch ingredients, is worth studying.
Motivation & Objective
- To analyze the types of bugs present in code automatically generated by large language models such as Codex.
- To evaluate the effectiveness of existing automated program repair (APR) tools—TBar and Recoder—in fixing bugs in LLM-generated code.
- To assess the performance of Codex's edit mode (Codex-e) as a novel APR technique for repairing auto-generated programs.
- To explore the potential of integrating language models with APR to improve code quality through better patch generation and fault localization.
- To identify key limitations in current APR approaches and suggest future research directions for enhancing repairability of LLM-generated code.
Proposed method
- Collected 113 programming tasks from LeetCode and used Codex to generate solutions, forming the LMDefects dataset.
- Applied statistical fault localization (SFL) to identify likely bug locations in incorrect solutions, providing guidance for APR tools.
- Evaluated traditional APR tools (TBar and Recoder) on their ability to fix bugs in Codex-generated code using test suites.
- Used Codex-e as a black-box repair tool, prompting it with natural language instructions and bug location hints to generate patches.
- Compared the repair success rates of TBar, Recoder, and Codex-e under varying conditions, including with and without fault localization guidance.
- Analyzed patch characteristics and bug patterns to identify recurring defects and repair challenges in LLM-generated code.

Experimental results
Research questions
- RQ1What types of bugs are commonly introduced in code generated by large language models like Codex?
- RQ2How effective are existing pattern-based and learning-based APR tools (e.g., TBar, Recoder) in repairing bugs in LLM-generated code?
- RQ3Can Codex's edit mode (Codex-e) outperform traditional APR tools in repairing incorrect solutions from large language models?
- RQ4How does the inclusion of fault localization information affect the quality and success rate of patches generated by Codex-e?
- RQ5What are the key limitations of current APR techniques when applied to LLM-generated code, and how can future APR research be guided by language model capabilities?
Key findings
- 57% of bugs in Codex-generated code are algorithmic, and 11% are syntax errors, indicating that LLMs make mistakes similar to human programmers.
- 13.4% of bugs require only small changes (e.g., operator or variable replacement), while 18.5% require larger code modifications, showing significant repair complexity.
- Codex-e outperforms both TBar and Recoder in repairing incorrect solutions when provided with fault localization guidance, achieving higher repair success rates.
- Even without explicit fault location, Codex-e performs comparably to or better than traditional APR tools, suggesting strong potential as a flexible repair mechanism.
- Existing APR tools struggle with limited search space, inability to generate multi-edit patches, and poor awareness of program dependencies, highlighting key scalability and expressivity limitations.
- The study identifies that future APR research should focus on improving fault localization flexibility and leveraging language models to automatically curate repair patterns from large-scale code generation data.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.