AI/TLDR

AG2

Open-source framework for building and orchestrating cooperating AI agents

Multi-Agent SystemsOpen source
Language
Python
$pip install ag2[openai]

Overview

AG2 (formerly AutoGen) is an open-source Python framework for building AI agents and coordinating several of them to work together on a task. It came out of the AutoGen project and is now maintained by a group of volunteers from several organizations, available on PyPI as `ag2` (with `autogen` as an alias).

It is aimed at developers who want to go beyond a single chatbot call and instead set up multiple agents that exchange messages, call tools, run code, and bring a human into the loop when needed. Agents are built from a common `ConversableAgent` base class, so a coder agent and a reviewer agent, for example, can talk to each other through the same message-passing model.

As a multi-agent framework, AG2 provides built-in conversation patterns such as group chats, swarms, nested chats, and sequential chats, plus support for various large language models and tool use. It fits the agent-frameworks category as a building block for agentic applications rather than a finished product.

What it does

  • Conversable agents that send and receive messages and generate replies using LLMs, tools, or human input
  • Built-in orchestration patterns: group chats, swarms, nested chats, and sequential chats
  • Human-in-the-loop workflows to insert human input into an agent conversation
  • Tool support so agents can register, invoke, and execute external functions
  • Works with multiple large language models via a JSON config file (OAI_CONFIG_LIST)
  • Advanced concepts including structured outputs, RAG, and code execution

Getting started

AG2 requires Python 3.10 or newer. Install it from PyPI, add your LLM API key in a config file, then run a first agent.

Install AG2

Install from PyPI with the OpenAI extra. On Windows/Linux use the unquoted form; on Mac quote the package name so the shell does not expand the brackets.

bashbash
pip install ag2[openai]

Set up your API keys

Store your keys in a config file (the examples use a file named OAI_CONFIG_LIST). Add it to .gitignore so it is never committed.

jsonjson
[
  {
    "model": "gpt-5",
    "api_key": "<your OpenAI API key here>"
  }
]

Run your first agent

Create a script or notebook with an assistant and a user proxy, then send the assistant a message.

pythonpython
from autogen import AssistantAgent, UserProxyAgent, LLMConfig

llm_config = LLMConfig.from_json(path="OAI_CONFIG_LIST")

assistant = AssistantAgent("assistant", llm_config=llm_config)

user_proxy = UserProxyAgent("user_proxy", code_execution_config={"work_dir": "coding", "use_docker": False})

user_proxy.run(assistant, message="Summarize the main differences between Python lists and tuples.").process()

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Build a two-agent workflow where one agent writes code and another reviews it
  • Orchestrate several agents in a group chat or swarm to break down and solve a larger task
  • Add human-in-the-loop checkpoints so a person can review or guide an agent conversation
  • Give agents tools and code execution to act on external systems and run generated scripts

How AG2 compares

AG2 alongside other open-source multi-agent systems tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
Ruflo★ 72.8kAgent meta-harness that wraps Claude Code and Codex with 100+ specialized agents, swarm coordination, vector memory, background workers and cross-machine agent federation.
MetaGPT★ 70.5kA multi-agent framework that models a software company, assigning roles like product manager, architect, and engineer to generate code from a single prompt.
AutoGen★ 61kMicrosoft Research's framework for building applications where multiple agents converse with each other and with tools to solve tasks.
CrewAI★ 58.7kA framework for assembling teams ('crews') of role-playing agents that divide tasks and collaborate to complete a goal.
AgentScope★ 31.9kA framework for building multi-agent applications with message passing, visual debugging tools, and distributed execution.
OpenAI Agents SDK★ 29.6kOpenAI's lightweight Python SDK for building multi-agent workflows using explicit handoffs, tools, and guardrails.
A2A★ 25.8kOpen Agent2Agent protocol from Google (now in the Linux Foundation) that lets agents from different frameworks discover each other and collaborate over JSON-RPC.
AG2★ 4.9kOpen-source framework for building and orchestrating cooperating AI agents