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

INTERVENOR: Prompting the Coding Ability of Large Language Models with the Interactive Chain of Repair

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

Introduction

Even the most advanced Large Language Models (LLMs) rarely write perfect code on the first try. While "Self-Repair" techniques—where a model attempts to fix its own errors—have become popular, they often hit a wall known as Degeneration-of-Thought (DoT). DoT is essentially the AI version of "cognitive inertia": just as a human writer might fail to spot a typo in their own essay because they know what they meant to say, an LLM often overlooks bugs in its own code because it is biased toward its original logic.

To overcome this, the INTERVENOR framework introduces an external "intervenor" to provide a fresh perspective and break the cycle of repetitive errors. By splitting the task between a "Code Learner" and a "Code Teacher," the system emulates human-like code repair and boosts performance by up to 18% over standard GPT-3.5 baselines.

The INTERVENOR Framework

The researchers developed INTERVENOR (INTERactiVE chaiN Of Repair), a system that decomposes the coding process into an interactive loop involving two distinct agents and a code compiler.

The INTERVENOR multi-agent architecture involving a Code Learner, Code Teacher, and Code Judger.

The framework consists of three primary components:

  1. The Code Learner: Tasked with generating the initial code and performing the actual repairs based on instructions.
  2. The Code Teacher: Acts as a senior developer or instructor. It examines the Learner's buggy code and the compiler's error messages to produce a Chain of Repair (CoR).
  3. The Compiler (Code Judger): Provides objective, external feedback, such as syntax errors or assertion failures, which serves as the ground truth for the repair process.

Chain of Repair (CoR): The "Secret Sauce"

The Chain of Repair (CoR) is a natural language plan that explains why a bug occurred and outlines a step-by-step strategy to fix it. By forcing the "Teacher" to explain the bug before the "Learner" tries to fix it, the system effectively "intervenes" in the Degeneration-of-Thought process.

An example of the Chain-of-Repair process, showing how a teacher's explanation guides the learner to fix a zero-case handling bug.

This role-playing approach helps the LLM switch "mental" contexts, reducing the bias toward the original buggy solution. Furthermore, using the compiler as the trigger for the "Teacher" ensures that the repair process is grounded in reality rather than the model's internal (and potentially flawed) logic. The study found that most significant improvements happen within just three turns of repair, suggesting that a focused, interactive approach is more efficient than brute-force sampling.

Experimental Setup and Benchmarks

INTERVENOR was evaluated across several standard and newly created benchmarks:

  • HumanEval & MBPP: Industry standards for Python code generation.
  • HumanEval-X: A multi-lingual benchmark covering C++, Java, and JavaScript.
  • DS-1000: A dataset focused on data science tasks (Pandas, NumPy, etc.).
  • CodeError (New): A benchmark specifically designed to test repair abilities, containing 4,463 examples across six error types (e.g., AttributeError, SyntaxError), featuring both AI-generated bugs and real-world user-submitted code.

Key Results

INTERVENOR demonstrated substantial gains over baseline models like GPT-3.5:

  • Code Generation: Achieved an 18% improvement in Pass@1 scores on HumanEval.
  • Code Translation: Showed a 4.3% improvement when translating code between different programming languages.
  • Bug Fixing: On the new CodeError dataset, INTERVENOR doubled the number of successfully repaired codes compared to standard zero-shot prompting.
  • Cross-Model Synergy: The framework is model-agnostic. Using a stronger model (like GPT-3.5) as the "Teacher" significantly improved the performance of a smaller "Learner" (like CodeLlama), proving that "teaching" is a viable way to upskill smaller models.

Conclusion and Future Directions

While INTERVENOR represents a significant step forward, its success remains tethered to the underlying LLM's ability to understand error messages. If the foundation model is too weak to diagnose the bug, the "Teacher" agent fails. Additionally, the effectiveness of the repair loop relies heavily on the robustness of provided test cases; compilers catch syntax and runtime errors, but logical errors require comprehensive unit tests.

Future research may involve integrating more sophisticated static analysis tools or exploring how this interactive loop could be utilized during the model training or fine-tuning phases to bake-in better repair capabilities from the start.

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: Prompting the Coding Ability of Large Language Models with the Interactive Chain of Repair}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.findings-acl.124},
}
Figure