Core Concepts
Reasoning
Memory & Retrieval
Agent Types
Design Patterns
Training & Alignment
Frameworks
Tools
Safety & Security
Evaluation
Meta
Core Concepts
Reasoning
Memory & Retrieval
Agent Types
Design Patterns
Training & Alignment
Frameworks
Tools
Safety & Security
Evaluation
Meta
MetaGPT is a multi-agent collaboration framework introduced by Hong et al. (2023) that assigns LLM-powered agents to specialized software company roles — Product Manager, Architect, Engineer, and QA — and coordinates them through Standardized Operating Procedures (SOPs) encoded as structured prompts. By mimicking real-world software development workflows in an assembly-line paradigm, MetaGPT significantly reduces cascading hallucinations and produces higher-quality software artifacts than chat-based multi-agent approaches.
MetaGPT organizes agents into a pipeline reflecting a real software company:
Each role is encoded as a specialized prompt template that constrains the agent's behavior to its domain expertise. The SOPs define not just what each agent does, but the handoff protocols between stages.
Rather than allowing unconstrained agent-to-agent chat (which leads to role confusion and hallucination cascading), MetaGPT uses a shared message pool architecture:
This structured communication is key to MetaGPT's advantage over frameworks like AutoGPT and ChatDev, where free-form conversation often leads to degraded outputs.
MetaGPT incorporates a code execution feedback loop that debugs and runs generated code, feeding runtime results back to the Engineer agent:
# Simplified MetaGPT role definition pattern from metagpt.roles import Role from metagpt.actions import WriteCode, WriteDesign class Architect(Role): name: str = "Alice" profile: str = "Architect" goal: str = "Design a concise, usable, complete software system" def __init__(self, **kwargs): super().__init__(**kwargs) self.set_actions([WriteDesign]) # Subscribe only to ProductManager outputs self.watch([WritePRD]) class Engineer(Role): name: str = "Bob" profile: str = "Engineer" goal: str = "Write elegant, readable, extensible code" def __init__(self, **kwargs): super().__init__(**kwargs) self.set_actions([WriteCode]) # Subscribe to Architect design documents self.watch([WriteDesign])
MetaGPT achieves state-of-the-art performance on standard coding benchmarks using GPT-4 as the base LLM:
| Benchmark | MetaGPT Pass@k | Improvement with Feedback |
|---|---|---|
| HumanEval | 85.9% | +4.2% Pass@1 |
| MBPP | 87.7% | +5.4% Pass@1 |
On collaborative software engineering tasks, MetaGPT scores 3.9/5 compared to ChatDev (2.1) and AutoGPT (1.0), with a 100% task completion rate and lower time and token costs.
The SOP-guided workflow can be modeled as a directed acyclic graph (DAG) of role transitions:
<latex>G = (V, E) \text{ where } V = \{r_1, r_2, \ldots, r_n\} \text{ are roles}</latex>
Each edge represents an artifact handoff:
<latex>e_{ij} = (r_i, r_j, a_{ij}) \text{ where } a_{ij} \text{ is the structured artifact from role } i \text{ to } j</latex>