NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

INTERVENOR: Prompt the Coding Ability of Large Language Models with the Interactive Chain of Repairing

Hanbin Wang, Zhenghao Liu, Shuo Wang, Ganqu Cui, Ning Ding, Zhiyuan Liu, Ge Yu

Abstract

This paper introduces INTERVENOR (INTERactiVE chaiN Of Repair), a system designed to emulate the interactive code repair processes observed in humans, encompassing both code diagnosis and code repair. INTERVENOR prompts Large Language Models (LLMs) to play distinct roles during the code repair process, functioning as both a Code Learner and a Code Teacher. Specifically, the Code Learner is tasked with adhering to instructions to generate or repair code, while the Code Teacher is responsible for crafting a Chain-of-Repair (CoR) to serve as guidance for the Code Learner. During generating the CoR, the Code Teacher needs to check the generated codes from Code Learner and reassess how to address code bugs based on error feedback received from compilers. Experimental results demonstrate that INTERVENOR surpasses baseline models, exhibiting improvements of approximately 18% and 4.3% over GPT-3.5 in code generation and code translation tasks, respectively. Our further analyses show that CoR is effective to illuminate the reasons behind bugs and outline solution plans in natural language. With the feedback of code compilers, INTERVENOR can accurately identify syntax errors and assertion errors and provide precise instructions to repair codes.

Introduction: Overcoming Cognitive Inertia in Coding

Even advanced Large Language Models (LLMs) struggle to generate bug-free code on the first attempt. While "Self-Repair" techniques—where a model attempts to fix its own mistakes—have shown promise, they often fall victim to Degeneration-of-Thought (DoT). DoT is a form of cognitive inertia: if a model wrote the buggy code, it is statistically likely to overlook that same bug during review because the error aligns with its internal pre-existing thinking. To fix complex bugs, models require external grounding from a compiler and a structured way to rethink the problem.

The INTERVENOR Framework

INTERVENOR facilitates an interactive dialogue between two specialized agents to break the cycle of buggy code generation. The system mimics human-like interactive debugging by splitting the LLM into distinct roles:

  1. The Code Learner (Student): Responsible for generating the initial code and subsequently repairing it based on specific instructions.
  2. The Code Teacher: Acts as an experienced instructor. It examines the buggy code and the compiler's error message to craft a Chain-of-Repair (CoR).
The INTERVENOR framework architecture, illustrating the interaction between the Code Learner, Code Teacher, and Code Judger.

The Workflow

  • Generation: The Student generates code for a specific task.
  • Check: The code is processed by a compiler. If it fails, the compiler provides a specific error message (e.g., AssertionError or TypeError).
  • Instruction: The Teacher analyzes the bug and the error message to generate the CoR—a natural language explanation of why the code failed and a plan to fix it.
  • Repair: The Student uses the CoR to rewrite the code. This loop continues until the code passes or a turn limit is reached.

The Chain-of-Repair (CoR)

The core innovation of this framework is the CoR, which acts as a bridge between cryptic compiler errors and the final code fix. By forcing the model to "think" in natural language before jumping back into syntax, INTERVENOR provides the necessary grounding to resolve complex logic errors.

An example of the Chain-of-Repair (CoR) process, where a teacher agent diagnoses an AssertionError and provides natural language instructions for the student to fix the code.

Experimental Evaluation

The researchers evaluated INTERVENOR on several standard benchmarks, including HumanEval, MBPP, HumanEval-X (multi-lingual), and DS-1000 (data science). Additionally, the authors introduced CodeError, a new benchmark containing 4,463 examples of buggy code snippets across six error types (Assertion, Name, Type, Index, Value, and Syntax errors) to specifically test repair proficiency.

Key Results

  • Performance Gains: INTERVENOR achieved an 18% improvement over GPT-3.5 on standard code generation benchmarks and a 4.3% improvement in code translation.
  • Repair Proficiency: On the CodeError benchmark, INTERVENOR doubled the number of successfully repaired codes compared to standard prompting methods.
  • Iterative Efficiency: Performance generally peaks around three turns of repair, suggesting that a few rounds of structured feedback are sufficient for most common bugs.
  • Cross-Model Synergy: A stronger model (like GPT-4) acting as a Teacher can significantly improve the performance of a smaller Student model.

Conclusion and Future Work

INTERVENOR demonstrates that role-playing and natural language reasoning can effectively mitigate Degeneration-of-Thought in LLMs. However, the system's success remains tethered to the underlying LLM's reasoning capabilities and the robustness of the test suite. Future work may involve agents that generate their own unit tests to identify logical errors that do not trigger standard compiler failures.

Summary updated

BibTeX
@inproceedings{wang2024intervenor,
  author = {Hanbin Wang and Zhenghao Liu and Shuo Wang and Ganqu Cui and Ning Ding and Zhiyuan Liu and Ge Yu},
  title = {{INTERVENOR: Prompt the Coding Ability of Large Language Models with the Interactive Chain of Repairing}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.findings-acl.124},
}
Figure