Collaborative Multi-Agent Code Generation and Test-Driven Refactoring in Autonomous Software Engineering
Mitigating Semantic Drift, Tool Execution Errors, and Hallucination Cascades through Role-Specialized Iterative Consensus
Abstract
Automated software engineering powered by large language models (LLMs) has transitioned from rudimentary snippet completion to autonomous end-to-end repository modification. However, single-agent architectures suffer from compounding errors: semantic drift across multi-step plans, unverified tool hallucinations, and unconstrained side-effects in complex codebases. This study investigates the efficacy of collaborative multi-agent architectures in autonomous code refactoring and bug resolution. We design and implement a role-specialized three-agent orchestration pipeline comprising an Architect Agent (task decomposition and contract definition), a Coder Agent (sandboxed patch generation), and a Test-Driven Auditor Agent (automated unit test synthesis and static analysis validation). Evaluating the framework across 14 non-trivial engineering tasks—including reactive framework migrations, database optimization, and secure API endpoints—the multi-agent pipeline demonstrated an 85.7% first-pass verification success rate (Pass@1), compared to 57.1% achieved by a monolithic single-agent baseline. Crucially, the auditor agent intercepted 100% of breaking schema mutations and syntax regressions before deployment, bounding the blast radius through isolated verification loops. These findings establish that iterative consensus and rigorous role separation significantly outstrip monolithic LLM prompting, offering a verifiable paradigm for mission-critical software automation.
References
Downloads
Published
Issue
Section
License
This work is licensed under a Creative Commons Attribution 4.0 International (CC BY 4.0) license.