TL;DR — AutoGen (v0.4, the "AG2" rewrite) is Microsoft Research's framework for multi-agent conversations. You define agents with roles, give them tools and models, and let them talk to each other in structured patterns — round-robin, selector-based, or custom. The runtime handles async messaging, state, and can distribute agents across processes. Best for research-flavored multi-agent systems where the agents collaborate through conversation.
What it is
AutoGen models AI applications as groups of agents that communicate via messages. Each agent has a system prompt, a model, and tools. A team orchestrates how agents take turns — who speaks next, when to stop, how to handle tool results. The v0.4 rewrite replaced the monolithic v0.2 API with a layered architecture: a core messaging runtime at the bottom, an AgentChat high-level API on top.
Fig 1 — Agents send messages through a team orchestrator that controls turn-taking.
Why it exists
Single-agent loops hit a ceiling when tasks need different expertise, debate, or review. AutoGen's insight: model the collaboration as a conversation protocol — agents argue, refine, and check each other's work, just like a human team would. The framework manages message routing, turn order, and termination so you focus on agent roles.
Install & setup
pip install autogen-agentchat autogen-ext[openai]
export OPENAI_API_KEY=sk-...
Building a basic team
import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_agentchat.conditions import TextMentionTermination
from autogen_ext.models.openai import OpenAIChatCompletionClient
model = OpenAIChatCompletionClient(model="gpt-4o")
researcher = AssistantAgent(
"researcher",
model_client=model,
system_message="You research topics and provide facts.",
)
writer = AssistantAgent(
"writer",
model_client=model,
system_message="You write polished summaries from research. Say APPROVE when done.",
)
team = RoundRobinGroupChat(
[researcher, writer],
termination_condition=TextMentionTermination("APPROVE"),
max_turns=6,
)
async def main():
result = await team.run(task="Write a summary of vLLM's architecture")
print(result.messages[-1].content)
asyncio.run(main())
Tools
from autogen_agentchat.agents import AssistantAgent
async def search_web(query: str) -> str:
"""Search the web for information."""
return f"Results for: {query}"
agent = AssistantAgent(
"agent",
model_client=model,
tools=[search_web],
system_message="Use search_web to find information.",
)
Selector-based teams
Instead of round-robin, let a model pick who speaks next based on the conversation:
from autogen_agentchat.teams import SelectorGroupChat
team = SelectorGroupChat(
[researcher, writer, reviewer],
model_client=model,
termination_condition=TextMentionTermination("DONE"),
)
Human-in-the-loop
from autogen_agentchat.agents import UserProxyAgent
human = UserProxyAgent("human")
team = RoundRobinGroupChat([agent, human], max_turns=4)
Distributed runtime
The core runtime supports distributed agents across processes via gRPC. Agents communicate through the same message-passing interface whether they're in-process or remote — useful for scaling or isolating heavy tools.
When to use, when to skip
Use it when you want multiple agents to collaborate through conversation — debate, review, multi-role workflows. The research pedigree and Microsoft backing make it strong for experimentation and prototyping multi-agent systems.
Skip it for single-agent tool-calling (LangChain is simpler). For production graph-based control flow, LangGraph gives more explicit control. CrewAI is more opinionated but faster to scaffold role-based teams.
vs the alternatives
| Tool | Best for | Trade-off |
|---|---|---|
| AutoGen | Multi-agent conversations, research workflows | Async-first; API churn from v0.2→v0.4 |
| CrewAI | Quick role-based agent teams | Less flexible orchestration |
| LangGraph | Explicit graph control flow | Not conversation-native |
| CAMEL | Role-playing agent research | More academic, less production |
Verified against AutoGen v0.4 docs (microsoft.github.io/autogen), May 2026.