# AgentCoder: Multi-Agent-based Code Generation with Iterative Testing and Optimisation

Source: [AgentCoder: Multi-Agent-based Code Generation with Iterative Testing and Optimisation](<https://www.sota2.com/research/paper/68fa73561e209131cea5be79>)

Collection index: [llms.txt](<https://www.sota2.com/research/llms.txt>)

Data updated: 2026-01-04T03:58:04.010Z

Authors: Dong Huang, Jie M.Zhang, Michael Luck, Qingwen Bu, Yuhao Qing, Heming Cui

Published: 2023-12-20T13:22:41.000Z

## Abstract

The advancement of natural language processing (NLP) has been significantly boosted by the development of transformer-based large language models (LLMs). These models have revolutionized NLP tasks, particularly in code generation, aiding developers in creating software with enhanced efficiency. Despite their advancements, challenges in balancing code snippet generation with effective test case generation and execution persist. To address these issues, this paper introduces Multi-Agent Assistant Code Generation (AgentCoder), a novel solution comprising a multi-agent framework with specialized agents: the programmer agent, the test designer agent, and the test executor agent. During the coding procedure, the programmer agent will focus on the code generation and refinement based on the test executor agent's feedback. The test designer agent will generate test cases for the generated code, and the test executor agent will run the code with the test cases and write the feedback to the programmer. This collaborative system ensures robust code generation, surpassing the limitations of single-agent models and traditional methodologies. Our extensive experiments on 9 code generation models and 12 enhancement approaches showcase AgentCoder's superior performance over existing code generation models and prompt engineering techniques across various benchmarks. For example, AgentCoder (GPT-4) achieves 96.3\\% and 91.8\\% pass@1 in HumanEval and MBPP datasets with an overall token overhead of 56.9K and 66.3K, while state-of-the-art obtains only 90.2\\% and 78.9\\% pass@1 with an overall token overhead of 138.2K and 206.5K.

## Recorded benchmark results

A research result applies to its stated dataset, split, metric and evaluation configuration. Compare like-for-like settings, preserve the metric's unit and direction, and distinguish paper-reported results from independent reproduction. The best result recorded here is not a claim of exhaustive, current global coverage.

- [Code Generation on MBPP-ET](<https://www.sota2.com/research/sota/code-generation-on-mbpp-et.md>): Code Generation; MBPP-ET; Pass@1: 91.8.

- [Code Generation on MBPP (pass@1, Improvement Rate (%))](<https://www.sota2.com/research/sota/code-generation-on-mbpp-pass-at-1-improvement-rate-percent.md>): Code Generation; MBPP; Pass@1: 91.8.

- [Code Generation on MBPP (pass@1 accuracy)](<https://www.sota2.com/research/sota/code-generation-on-mbpp-pass-at-1-accuracy.md>): Code Generation; MBPP; Pass@1 Accuracy: 91.8.

- [Code Generation on MBPP (Pass@1 Python, Pass@1 Rust)](<https://www.sota2.com/research/sota/code-generation-on-mbpp-pass-at-1-python-pass-at-1-rust.md>): Code Generation; MBPP; Pass@1 Accuracy (Python): 91.8.

- [Code Generation on LiveCodeBench Post-March 2025 V6 (Pass@1)](<https://www.sota2.com/research/sota/code-generation-on-livecodebench-post-march-2025-v6-pass-at-1.md>): Code Generation; LiveCodeBench Post-March 2025 V6; Pass@1 (Easy): 88.9.

- [Code Generation on HumanEval-ET](<https://www.sota2.com/research/sota/code-generation-on-humaneval-et.md>): Code Generation; HumanEval-ET; Pass@1: 86.

- [Simulation generation on PLE (test)](<https://www.sota2.com/research/sota/simulation-generation-on-ple-test.md>): Simulation generation; PLE (test); Flappy Score: 18.

- [Code Generation on MBPP (test)](<https://www.sota2.com/research/sota/code-generation-on-mbpp-test.md>): Code Generation; MBPP (test); Pass@1: 91.8.

- [Code Generation on HumanEval](<https://www.sota2.com/research/sota/code-generation-on-humaneval.md>): Code Generation; HumanEval; Pass@1: 96.3.

## Original sources and implementation

[Original paper](<https://arxiv.org/abs/2312.13010>)

[PDF](<https://arxiv.org/pdf/2312.13010.pdf>)
