Table of Contents
Fetching ...

MaCTG: Multi-Agent Collaborative Thought Graph for Automatic Programming

Zixiao Zhao, Jing Sun, Zhe Hou, Zhiyuan Wei, Cheng-Hao Cai, Miao Qiao, Jin Song Dong

TL;DR

MaCTG presents a dynamic graph-based multi-agent framework for automatic programming that distributes planning, coding, and testing across specialized agents. By combining context-aware planning with a multi-scale validation and assembly process, MaCTG mitigates cascading hallucinations and enhances code reliability, while a hybrid LLM deployment reduces operational costs. Evaluation on the BCVPP image-processing benchmark shows an overall accuracy of 83.33% and an 89.09% cost reduction compared with other multi-agent frameworks, demonstrating strong practicality for complex project-level software tasks. The approach enables scalable, reliable auto-programming with improved task decomposition and verification, offering a significant advancement for large-scale LLM-assisted software development.

Abstract

With the rapid advancement of Large Language Models (LLMs), LLM-based approaches have demonstrated strong problem-solving capabilities across various domains. However, in automatic programming, a single LLM is typically limited to function-level code generation, while multi-agent systems composed of multiple LLMs often suffer from inefficient task planning. This lack of structured coordination can lead to cascading hallucinations, where accumulated errors across agents result in suboptimal workflows and excessive computational costs. To overcome these challenges, we introduce MaCTG (Multi-Agent Collaborative Thought Graph), a novel multi-agent framework that employs a dynamic graph structure to facilitate precise task allocation and controlled collaboration among LLM agents. MaCTG autonomously assigns agent roles based on programming requirements, dynamically refines task distribution through context-aware adjustments, and systematically verifies and integrates project-level code, effectively reducing hallucination errors and improving overall accuracy. MaCTG enhances cost-effectiveness by implementing a hybrid LLM deployment, where proprietary models handle complex reasoning, while open-source models are used for routine coding and validation tasks. To evaluate MaCTG's effectiveness, we applied it to traditional image processing auto-programming tasks, achieving a state-of-the-art accuracy of 83.33%. Additionally, by leveraging its hybrid LLM configuration, MaCTG significantly reduced operational costs by 89.09% compared to existing multi-agent frameworks, demonstrating its efficiency, scalability, and real-world applicability.

MaCTG: Multi-Agent Collaborative Thought Graph for Automatic Programming

TL;DR

MaCTG presents a dynamic graph-based multi-agent framework for automatic programming that distributes planning, coding, and testing across specialized agents. By combining context-aware planning with a multi-scale validation and assembly process, MaCTG mitigates cascading hallucinations and enhances code reliability, while a hybrid LLM deployment reduces operational costs. Evaluation on the BCVPP image-processing benchmark shows an overall accuracy of 83.33% and an 89.09% cost reduction compared with other multi-agent frameworks, demonstrating strong practicality for complex project-level software tasks. The approach enables scalable, reliable auto-programming with improved task decomposition and verification, offering a significant advancement for large-scale LLM-assisted software development.

Abstract

With the rapid advancement of Large Language Models (LLMs), LLM-based approaches have demonstrated strong problem-solving capabilities across various domains. However, in automatic programming, a single LLM is typically limited to function-level code generation, while multi-agent systems composed of multiple LLMs often suffer from inefficient task planning. This lack of structured coordination can lead to cascading hallucinations, where accumulated errors across agents result in suboptimal workflows and excessive computational costs. To overcome these challenges, we introduce MaCTG (Multi-Agent Collaborative Thought Graph), a novel multi-agent framework that employs a dynamic graph structure to facilitate precise task allocation and controlled collaboration among LLM agents. MaCTG autonomously assigns agent roles based on programming requirements, dynamically refines task distribution through context-aware adjustments, and systematically verifies and integrates project-level code, effectively reducing hallucination errors and improving overall accuracy. MaCTG enhances cost-effectiveness by implementing a hybrid LLM deployment, where proprietary models handle complex reasoning, while open-source models are used for routine coding and validation tasks. To evaluate MaCTG's effectiveness, we applied it to traditional image processing auto-programming tasks, achieving a state-of-the-art accuracy of 83.33%. Additionally, by leveraging its hybrid LLM configuration, MaCTG significantly reduced operational costs by 89.09% compared to existing multi-agent frameworks, demonstrating its efficiency, scalability, and real-world applicability.

Paper Structure

This paper contains 26 sections, 7 equations, 5 figures, 2 tables.

Figures (5)

  • Figure 1: MaCTG’s collaborative workflow of four phases: Planning, Execution, Validation and Assembly
  • Figure 2: Dynamic Module Leader configuration: Module Leaders are only initialised after the Team Leader determines the module decomposition.
  • Figure 3: Comparison of Multi-agent planning process
  • Figure 4: Agent planning error: Separate planning procedure leads to inconsistencies between modules.
  • Figure 5: Context-aware planning adjustment: Context sharing mitigates the inter-module inconsistency; Supervised adjustment further reinforces structured communication.