# MetaGPT: Meta Programming for A Multi-Agent Collaborative Framework

MetaGPT encodes human software SOPs so LLM agents produce more coherent code

Sirui Hong, Mingchen Zhuge, Jiaqi Chen, Xiawu Zheng, Yuheng Cheng, Ceyao Zhang and 9 more · arXiv · 2023-8-1

- **Problem** Chaining LLM agents naively lets hallucinations cascade, so complex multi-step tasks end with inconsistent logic. Earlier chat-based multi-agent systems also oversimplify such tasks.
- **Method** MetaGPT is a framework that encodes Standardized Operating Procedures into prompt sequences. Role-based agents then pass structured documents along an assembly line, so each agent checks the output of the step before it.
- **Results** On HumanEval and MBPP, MetaGPT scored 85.9% and 87.7% Pass@1 with a single attempt. Those numbers depend on the authors' slightly modified prompts.

## Where chained agents get stuck

Naively chaining LLMs lets hallucinations cascade, so a multi-step task can end with inconsistent logic. Existing systems tend to oversimplify such tasks and struggle when agents must collaborate in a meaningful way. Earlier role-based work improved productivity but did not use structured output formats, which makes complex software problems harder to handle.

So the question is whether encoding human SOPs into role-based agents yields more coherent software outputs than chat-based systems.

Free-form role-play adds a second risk, because agents can spend turns on idle chatter that introduces errors. The telephone game shows the same drift, since meaning degrades after several rounds of natural-language relay. This is why the authors focus on structure rather than on more dialogue.

## Borrowing procedures from software teams

The key idea is to give LLM agents the division of labor and the document standards that human software teams already use. Standardized Operating Procedures assign responsibilities to each member and set standards for intermediate outputs. MetaGPT encodes such procedures into prompt sequences, so each agent checks the intermediate results of the step before it.

The authors expect this to cut errors, because a role can verify the output another role produced.

Five roles are defined: Product Manager, Architect, Project Manager, Engineer and QA Engineer. Each agent has a profile with a name, profile, goal and constraints, plus its own context and skills. Agents follow the ReAct-style behavior and watch a shared environment for messages that matter to them.

## How one task moves through the roles

The workflow starts when the Product Manager turns the user requirement into a PRD with user stories and a requirement pool. The Project Manager then distributes tasks, and Engineers implement the designated classes and functions. A QA Engineer writes test cases after that stage, so the final output is checked before it is delivered.

These outputs carry the module design and interaction sequences that the Engineers need, so they don't have to reconstruct them from chat. A shared message pool lets every agent publish structured messages and read what it needs without asking other agents directly. Subscriptions narrow the flow: an agent acts only after its prerequisite inputs arrive, so the Architect focuses on PRDs while QA documents matter less to it.

## Running the code inside the loop

Earlier systems relied on code review and self-reflection without running the code, so errors can slip through. The authors' first implementations missed some errors during review because of LLM hallucinations. The fix is an executable feedback loop: after the first draft, the Engineer writes and runs unit tests, then debugs the code. The Engineer draws on its own execution history and debugging memory to repair the code.

The loop stops when the test passes or after a maximum of 3 retries. So code that still fails after three retries is left as it is, with no further correction.

## Benchmark results and their conditions

The authors use HumanEval with 164 handwritten tasks and MBPP with 427 Python tasks. They also build SoftwareDev, a set of 70 engineering-oriented tasks such as mini-games and data visualization. Pass@k is the unbiased estimator the authors take from earlier work, used to score functional accuracy of the top-k generated codes.

On HumanEval and MBPP, MetaGPT scored 85.9% and 87.7% Pass@1 with a single attempt. The authors slightly modified the prompts to fit response formats, and that modification is a condition of these numbers. Without executable feedback, the variant scored 81.7 and 82.3, so the feedback adds 4.2% on HumanEval and 5.4% on MBPP.

On seven randomly selected SoftwareDev tasks, full MetaGPT scored 3.75 on Executability, compared to 2.25 for ChatDev. Human Revision Cost fell to 0.83, compared to 2.5 for ChatDev. The price is more tokens in total: 31,255 for MetaGPT against 19,292 for ChatDev. Per line of code the cost is lower, at 124.3 tokens against 248.9 for ChatDev, so the extra tokens buy more code.

## Which roles and features carry the design

The partial configurations don't rise steadily, since the Engineer with Product Manager and Project Manager scored 2.0, below 2.5 for the three-role Architect row. So the role gain is clearest at the full set, and the two-task design limits how far it generalizes.

Table 2 marks PRD generation, technical design generation, API interface generation and precompilation execution as present only in MetaGPT. This is a presence-or-absence comparison of features, not a measurement of code quality.

## Limits and open questions

Executable feedback stops at three retries, so the loop can't fix code that still fails at that point. The SoftwareDev comparison uses seven randomly selected tasks out of 70, and Executability is a human rating. The role ablation uses only two tasks.

The authors report a 100% task completion rate, but the criterion for completion isn't defined alongside it. MetaGPT spends more tokens in total than ChatDev, so the cost trade-off is real even though the per-line cost is lower. Whether the gains carry to other languages or to larger codebases remains open, since the tests cover Python tasks and the SoftwareDev set.

## Paper info

- **Authors**: Sirui Hong, Mingchen Zhuge, Jiaqi Chen, Xiawu Zheng, Yuheng Cheng, Ceyao Zhang, Jinlin Wang, Zili Wang, Steven Ka Shing Yau, Zijuan Lin, Liyang Zhou, Chenyu Ran, Lingfeng Xiao, Chenglin Wu, Jürgen Schmidhuber
- **Venue**: arXiv · Preprint
- **First published**: 2023-8-1
- **Added**: 2026-11-13
- **Updated**: 2024-11-1
- **Version**: v7
- **arXiv**: 2308.00352
- **Category**: cs.AI · cs.MA
- **Original paper terms**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/2308.00352v7) · [PDF ↗](https://arxiv.org/pdf/2308.00352v7)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Sirui Hong, Mingchen Zhuge, Jiaqi Chen, Xiawu Zheng, Yuheng Cheng, Ceyao Zhang, Jinlin Wang, Zili Wang, Steven Ka Shing Yau, Zijuan Lin, Liyang Zhou, Chenyu Ran, Lingfeng Xiao, Chenglin Wu, Jürgen Schmidhuber (2023). MetaGPT: Meta Programming for A Multi-Agent Collaborative Framework. arXiv:2308.00352v7. https://arxiv.org/abs/2308.00352v7

**BibTeX**

```
@misc{hong2023metagpt,
  title = {{MetaGPT: Meta Programming for A Multi-Agent Collaborative Framework}},
  author = {Sirui Hong and Mingchen Zhuge and Jiaqi Chen and Xiawu Zheng and Yuheng Cheng and Ceyao Zhang and Jinlin Wang and Zili Wang and Steven Ka Shing Yau and Zijuan Lin and Liyang Zhou and Chenyu Ran and Lingfeng Xiao and Chenglin Wu and Jürgen Schmidhuber},
  year = {2023},
  eprint = {2308.00352},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2308.00352v7}
}
```

## Other paper commentary

- [The Surprising Effectiveness of PPO in Cooperative, Multi-Agent Games](https://refivu.com/en/papers/7c9c355e-16b7-49a8-b767-07760b1c48a4-the-surprising-effectiveness-of-ppo-in-cooperative-multi.md)
- [AutoGen: Enabling Next-Gen LLM Applications via Multi-Agent Conversation](https://refivu.com/en/papers/d3d2ade6-3bed-4a94-9439-088b61554b00-autogen-enabling-next-gen-llm-applications-via-multi.md)
- [Deep Multi-agent Reinforcement Learning for Highway On-Ramp Merging in Mixed Traffic](https://refivu.com/en/papers/5a4426df-329c-4335-a2f9-61fd8bab85a2-deep-multi-agent-reinforcement-learning-for-highway-on.md)
- [Reflexion: Language Agents with Verbal Reinforcement Learning](https://refivu.com/en/papers/a572f458-b121-4d38-bfc9-7a77309a3aba-reflexion-language-agents-with-verbal-reinforcement-learning.md)
- [A Generalist Agent](https://refivu.com/en/papers/890475cb-e797-43df-8de3-0d0eb9ed882e-a-generalist-agent.md)
- [Implicit Intelligence - Evaluating Agents on What Users Don’t Say](https://refivu.com/en/papers/46a3027e-e7cd-4c3e-be85-2fe588fd1675-implicit-intelligence-evaluating-agents-on-what-users-don.md)
- [GQA: A New Dataset for Real-World Visual Reasoning and Compositional Question Answering](https://refivu.com/en/papers/d0afea32-dc3f-4529-bea4-dbdd41e95856-gqa-a-new-dataset-for-real-world-visual.md)
- [Moment Matching for Multi-Source Domain Adaptation](https://refivu.com/en/papers/8dd0a99c-d46a-4b5e-bfd0-6d72f38da2fc-moment-matching-for-multi-source-domain-adaptation.md)
- [Semi-Supervised Learning with Deep Generative Models](https://refivu.com/en/papers/e4821cb7-e7f9-4874-ba36-d94522c55bbb-semi-supervised-learning-with-deep-generative-models.md)
- [The Google Similarity Distance](https://refivu.com/en/papers/bb278d2d-7ba0-4fc6-9c9b-7e248f6965c2-the-google-similarity-distance.md)
- [HOGWILD!: A Lock-Free Approach to Parallelizing Stochastic Gradient Descent](https://refivu.com/en/papers/4f25abad-2562-433a-bc64-107b6d812ffb-hogwild-a-lock-free-approach-to-parallelizing-stochastic.md)
- [Fourier Features Let Networks Learn High Frequency Functions in Low Dimensional Domains](https://refivu.com/en/papers/0db80d86-03b8-4275-8e19-39d4c7f0fd3d-fourier-features-let-networks-learn-high-frequency-functions.md)

## Terms in this paper

- [GPT-4](https://refivu.com/en/terms/1e2d0d2cdc44-gpt-4)
- [Large Language Models](https://refivu.com/en/terms/f2404476b183-large-language-models)
- [HumanEval](https://refivu.com/en/terms/3c3dbcadfdda-humaneval)
- [pass@k](https://refivu.com/en/terms/c162514bd507-pass-k)
- [MBPP](https://refivu.com/en/terms/717e657dd0b2-mbpp)
- [Codex](https://refivu.com/en/terms/1afc2735b086-codex)
- [ReAct](https://refivu.com/en/terms/420780a0fd8c-react)
- [hallucinations](https://refivu.com/en/terms/d409eeeeb3c7-hallucinations)
- [Reflexion](https://refivu.com/en/terms/ae549dc1c40e-reflexion)
- [AutoGPT](https://refivu.com/en/terms/84b91e52d879-autogpt)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/91dd7973-493a-4820-91e2-46a50eb0a70e-metagpt-meta-programming-for-a-multi-agent-collaborative)
