COAST: Enhancing the Code Debugging Ability of LLMs through Communicative Agent Based Data Synthesis

Weiqing Yang, Hanbin Wang, Zhenghao Liu, Xinze Li, Yukun Yan, Shuo Wang, Yu Gu, Minghe Yu, Zhiyuan Liu, Ge Yu

Abstract

While Large Language Models (LLMs) have shown promise in code generation, their debugging capabilities are often limited to simple code repair. This paper introduces DEBUGEVAL, a benchmark that treats debugging as a multi-stage pipeline: localization, identification, repair, and recognition. To bridge the performance gap for smaller models, the authors propose COAST (COmmunicative Agent-based data SynThesis), a multi-agent framework that generates high-quality training data through teacher-student interactions. Fine-tuning 7B-scale models on COAST-synthesized data allows them to rival the performance of much larger models like GPT-3.5-Turbo.

Introduction: Beyond Simple Code Repair

In current LLM research, "debugging" is frequently reduced to a single task: Code Repair. However, for a human developer, debugging is a structured process. It involves finding the buggy line (Localization), understanding the root cause (Identification), implementing a fix (Repair), and verifying the solution (Recognition).

Comparison between standard LLM code repair and the multi-stage human debugging pipeline.

The authors identify two major gaps in the field. First, an Evaluation Gap, where existing benchmarks focus almost exclusively on the final repair stage, failing to assess if a model truly understands the bug. Second, a Performance Gap, where smaller 7B-scale models—ideal for local deployment—struggle with the semantic reasoning required for the earlier stages of the debugging pipeline.

The DEBUGEVAL Benchmark

To address the evaluation gap, the researchers developed DEBUGEVAL, a comprehensive benchmark consisting of 5,712 instances across Python, C++, and Java. It pulls from diverse sources like DebugBench, LiveCodeBench, and human-submitted code from AtCoder. DEBUGEVAL explicitly tests models on four distinct tasks:

  • BUG Localization: Identifying the specific line containing the error.
  • BUG Identification: Classifying the error type (e.g., Syntax, Logical, Reference).
  • Code Repair: Generating the corrected code snippet.
  • Code Recognition: Distinguishing between a buggy and a correct version of the same code.

The COAST Framework

To improve model performance, the authors created the COmmunicative Agent-based data SynThesis (COAST) framework. This framework uses a "society" of three specialized LLM agents to synthesize high-quality training data.

The COAST framework featuring the Code Quizzer, Code Learner, and Code Teacher agents.

The framework operates through a collaborative loop:

  1. Code Quizzer: Generates diverse debugging problems based on seed examples.
  2. Code Learner: Acts as a "student" and a filter. It attempts to solve the generated problems. If the Learner succeeds, the problem is discarded as too easy. If it fails, the problem is flagged as having high "educational value."
  3. Code Teacher: Takes the failed problems and provides detailed Chain-of-Thought (CoT) explanations and the correct solutions.

This process generated approximately 24,892 high-quality samples, which were used for Supervised Fine-Tuning (SFT) to create the NeuDebugger models.

Key Insights and Results

The researchers found that the "Educational Value" filter was essential for efficiency, focusing the SFT process on the model's specific weaknesses. They also discovered that while Chain-of-Thought reasoning significantly boosts performance in reasoning-heavy tasks like Localization and Identification, it can occasionally introduce noise during the Code Repair stage.

Experimental results showed that NeuDebugger-DS-6.7B achieved an average improvement of 27.7% over its base model. Remarkably, these COAST-trained 7B models achieved debugging performance comparable to GPT-3.5-Turbo, proving that targeted synthetic data can effectively compensate for smaller model sizes.

Conclusion

COAST demonstrates that multi-agent collaboration can produce training signals superior to those from human-curated data or single-model generation. While currently focused on single-file debugging, future work aims to extend this framework to multi-file environments and a broader range of programming languages.

Summary updated

BibTeX
@inproceedings{yang2025coast,
  author = {Weiqing Yang and Hanbin Wang and Zhenghao Liu and Xinze Li and Yukun Yan and Shuo Wang and Yu Gu and Minghe Yu and Zhiyuan Liu and Ge Yu},
  title = {{COAST: Enhancing the Code Debugging Ability of LLMs through Communicative Agent Based Data Synthesis}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2025},
  doi = {10.18653/v1/2025.findings-naacl.139},
}
Figure