MetaGPT: The Complete Guide to the Best AI Agents Currently Available

With large language models (LLMs) like ChatGPT, OpenAI has grown in enterprise and user adoption, with monthly revenues currently around $80 million. According to a recent report by The Information, the San Francisco-based company is on pace to reach $1 billion in annual revenue.

Last time we explored AutoGPT and GPT-Engineering, early mainstream open-source LLM-based AI agents designed to automate complex tasks. While promising, these systems had their fair share of problems: inconsistent results, performance bottlenecks, and limitations in handling multifaceted demands. They show proficiency in code generation, but their abilities often stop there. They lack critical project management functionality such as PRD generation, technical design generation, and API interface prototyping.

Enter MetaGPT—a multi-agent system by Sirui Hong that uses large language models and fuses standardized operating procedures (SOPs) with LLM-based multi-agent systems. This emerging paradigm disrupts the existing limitations of LLMs in fostering effective collaboration and task decomposition in complex, real-world applications.

The beauty of MetaGPT lies in its structure. It capitalizes on meta-programming techniques to manipulate, analyze and transform code in real-time. The goal? To realize agile, flexible software architectures that adapt to dynamic programming tasks.

Agile Development - Metagpt

Agile development

SOPs act as a meta-function here, coordinating agents to auto-generate code based on defined inputs. Simply put, it’s like you’ve turned a highly coordinated team of software engineers into an adaptive, intelligent software system.

Understanding the MetaGPT Framework

The MetaGPT Framework

MetaGPT Framework (

infrastructure and collaboration levels

MetaGPT’s architecture is divided into two layers: the infrastructure layer and the collaboration layer.

  1. Infrastructure level: This layer focuses on individual agent operations and facilitates system-wide information exchange. It introduces core building blocks such as environment, memory, roles, actions, and tools. The environment sets the stage for shared workspaces and communication channels, while memory serves as historical data storage. Roles embody domain-specific skills, actions implement modular tasks, and tools provide common services. This layer essentially serves as the operating system for the agents. More details on how these work together can be found in ‘Beyond ChatGPT; AI Agents: The New World of Workers
  2. Collaboration level: Built on top of infrastructure components, this layer manages and streamlines the collaborative efforts of individual agents. It introduces two mechanisms: knowledge sharing and encapsulating workflow.
    • Exchange of knowledge: It acts as an associative glue that binds the agents together. Agents can store, retrieve and share information at different levels, thus reducing redundancy and increasing operational efficiency.
    • Encapsulating the workflow: This is where Standard Operating Procedures (SOPs) come into play. SOPs act as blueprints that break tasks down into manageable components. Agents are assigned these sub-tasks and their performance is aligned with standardized outputs.

Also uses MetaGPTRole definitionAs we discussed above, product managers, architects, etc. Initiating various specific agents like These roles are characterized by key attributes such as name, profile, mission, limitations, and description.

A comparative illustration of software development SOPs in MetaGPT and real-world humanteams

Moreover, “Anchor Agent” provides role-specific guidance to these agents. For example, a product manager role may be initiated with the obligation to “build a functionally successful product.” Anchor agents ensure that the agent’s behavior aligns with optimal goals, thereby optimizing performance.

Cognitive processes in MetaGPT agents

MetaGPT can observe, think, reflect and act. They work with specific behaviors such as _think(), _observe(), _publish_message()etc. This cognitive modeling equips agents as active learners who can adapt and evolve.

  1. Observe: Agents scan their environment and insert key data into their memory.
  2. Think and reflect: through the _think() Action, conscious stance before action.
  3. Broadcast the message: agent used _publish_message() To share current work status and related action records.
  4. Enlightenment and Law: Agents evaluate incoming messages and update their internal repository before deciding on the next course of action.
  5. State management: With features such as task locking and status updating, roles can process multiple actions sequentially without interruption, mirroring real-world human collaboration.

A code-review mechanism for MetaGPT

Code review is an important element in the software development life cycle, yet it is absent from many popular frameworks. Both MetaGPT and AgentVerse support code review capabilities, but MetaGPT goes a step further. It also includes pre-compilation execution, which helps in early error detection and improves code quality later. Given the iterative nature of coding, this feature is not just an add-on but a must for any mature development framework.

Quantitative experiments conducted across several tasks have shown that MetaGPT outperforms its counterparts in almost every scenario. Pass@1 is a measure of a framework’s ability to generate correct code in a single iteration. This metric provides a more realistic reflection of the usefulness of the framework in a practical setting. A higher Pass@1 rate means less debugging and more efficiency, directly impacting development cycles and costs. While stacked on top of other advanced code generation tools like CodeX, CodeT, and even GPT-4, MetaGPT Performs excellently Mall. To achieve the potential of the framework 81.7% to do 82.3% Pass@1 rate on HumanEval and MBPP benchmarks.

Comparing MBPP and HumanEval metrics b/w MetaGPT and other leading models (

Comparing MBPP and HumanEval metrics b/w MetaGPT and other leading models (

The framework also uses fewer tokens and computational resources, achieving higher success rates at a fraction of traditional software engineering costs. The data only indicate the average cost $1.09 Per project with MetaGPT is only a fraction of what a developer would charge for the same work.

Steps to install MetaGPT locally on your system

NPM, Python installation

  1. Check and install NPM: First things first, make sure NPM is installed on your system. If not, you need to install node.js. To check if you have npm, run this command in your terminal: npm --version. If you see a version number, you’re good to go.
  2. to install mermaid-jsDependencies for MetaGPT, run: sudo npm install -g @mermaid-js/mermaid-cli Or npm install -g @mermaid-js/mermaid-cli
  3. Verify the Python version: Make sure you have Python 3.9 or above. To check your Python version, open your terminal and type: python --version. If you are not up to date, download the latest version from the Python official website.
  4. Clone the metagpt repositoryStart by cloning the MetaGPT GitHub repository using the : command git clone For this make sure Git is installed in your system. If not, visit here.
  5. Navigate to the directory: Once cloned, navigate to the MetaGPT directory using the command cd metagpt.
  6. InstallationExecute the Python setup script to install MetaGPT with the : command python install.
  7. Create an application: Run python "ENTER-PROMPT" --code_review True


  • Your new project should now be in workspace/ directory
  • --code_review True GPT will allow additional operations to be performed on the model to ensure that the code runs correctly but note that this will be costly.
  • If you get a permission error during installation, try running it python install --user As an alternative.
  • For specific releases and access to more details, visit the official MetaGPT GitHub release page: MetaGPT Releases.

Docker installation

For those who prefer containerization, Docker simplifies the process:

  • Pull the Docker image: Download the MetaGPT official image and create the configuration file:

docker pull metagpt/metagpt:v0.3.1

mkdir -p /opt/metagpt/config,workspace

docker run --rm metagpt/metagpt:v0.3.1 cat /app/metagpt/config/config.yaml > /opt/metagpt/config/key.yaml
vim /opt/metagpt/config/key.yaml

  • Run the MetaGPT containerRun the container with the following command:

docker run --rm --privileged \

-v /opt/metagpt/config/key.yaml:/app/metagpt/config/key.yaml \

-v /opt/metagpt/workspace:/app/metagpt/workspace \

metagpt/metagpt:v0.3.1 \

python "Create a simple and interactive CLI based rock, paper and scissors game" --code_review True

Configuring MetaGPT with your OpenAI API Key

After the initial setup, you need to integrate MetaGPT with your OpenAI API key. Here are the steps to do so:

  1. Find or generate your OpenAI key: You can find this key in your OpenAI dashboard under API Settings.
  2. Set the API key: You have the option to keep an API key config/key.yaml, config/config.yamlor set as an environment variable (env). is the order of precedence config/key.yaml > config/config.yaml > env.
  3. To set the key, navigate here config/key.yaml And replace the placeholder text with your OpenAI key: OPENAI_API_KEY: "sk-..."

Remember to secure your OpenAI API key. Never commit it to a public repository or share it with unauthorized persons.

Use-case illustration

I set out to develop a CLI-based Rock, Paper and Scissors game and MetaGPT did the job successfully.

Below is a video that demonstrates an actual run of the generated game code.

Run the MetaGPT demo

MetaGPT provides system design documentation in Markdown—a commonly used lightweight markup language. This Markdown file was filled with UML diagrams, giving a granular view of the architectural blueprint. Furthermore, the API specification was detailed with HTTP methods, endpoints, request/response objects, and status codes.

MetaGPT Output - System Design

MetaGPT Output – System Design Markdown

The class diagram details our properties and methods Game Classes provide an abstraction that is easy to understand. It visualizes the call flow of a program by effectively turning even the most abstract ideas into tangible steps.

Not only does this significantly reduce manual overhead in planning, it also speeds up the decision-making process, ensuring your development pipeline remains agile. With MetaGPT, you’re not just automating code generation, you’re also automating intelligent project planning, thus providing a competitive edge in rapid application development.

Conclusion: MetaGPT-revolutionizes software development

MetaGPT redefines the landscape of generative AI and software development, offering a seamless blend of intelligent automation and agile project management. It excels in task decomposition, efficient code generation and project planning, surpassing the capabilities of ChatGPT, AutoGPT and traditional LangChain models. Learn more above

Here are the key takeaways from this article:

  1. The power of meta-programming: Using meta-programming, MetaGPT provides an agile and adaptive software framework. It goes beyond the narrow functionality of legacy tools and introduces a transformative approach that not only handles coding but also aspects of project management and decision making.
  2. Two-tier architecture: With its infrastructure and collaboration layers, MetaGPT effectively creates a synergistic ecosystem where agents can work together like an expertly managed software team.
  3. Optimized code review: Beyond just generating code, MetaGPT offers precompilation execution features, essentially a pre-warning system for errors. This not only saves debugging time but also ensures code quality.
  4. cognitive agents: MetaGPT’s intelligent agents, complete with cognitive functions such as _observe(), _think(), and _publish_message(), evolve and adapt, ensuring that your software solution is not just coded, but ‘intelligent’.
  5. Installation and deployment: We’ve explained that MetaGPT can be easily set up, whether you prefer local installation via npm and Python, or containerization via Docker.

Leave a Comment