Problem Context
Single-agent LLM systems hit a ceiling fast: one prompt has to be planner, executor, critic, and editor at the same time. The result is a mega-prompt that nobody can debug and a context window that fills up in three turns. AutoGen โ Microsoft Research's conversational multi-agent framework โ answers this by letting you spin up several specialised agents and have them talk to each other (and optionally to a human) until the work is done.
- Your single "do everything" prompt has grown past 4 KB and is still missing edge cases
- You want a coder agent, a reviewer agent, and a tester agent, but don't want to hand-roll the message bus
- You need a human-in-the-loop checkpoint without rewriting the agent graph
The Mental Model
AutoGen treats multi-agent collaboration as a typed message protocol. Each agent has a name, a system prompt, an LLM config, and a set of tools. Conversations are orchestrated by a GroupChat manager that decides who speaks next using a selection strategy (round-robin, auto/LLM-based, manual). Termination is explicit: a regex on the last message, a max-round counter, or an agent emitting TERMINATE.
flowchart LR
U[UserProxyAgent] --> M[GroupChatManager]
M --> P[PlannerAgent]
M --> C[CoderAgent]
M --> R[ReviewerAgent]
M --> T[TesterAgent]
P -. plan .-> M
C -. code .-> M
R -. critique .-> M
T -. test result .-> M
M -->|TERMINATE| U
Minimal Working Example (AutoGen v0.4, async)
from autogen_agentchat.agents import AssistantAgent, UserProxyAgent
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_agentchat.conditions import TextMentionTermination
from autogen_ext.models.openai import AzureOpenAIChatCompletionClient
model = AzureOpenAIChatCompletionClient(model="gpt-4o", api_version="2024-08-01-preview")
planner = AssistantAgent("planner", model_client=model,
system_message="Decompose the task into 3 steps. Hand off to coder.")
coder = AssistantAgent("coder", model_client=model,
system_message="Implement the next step in Python. Hand off to reviewer.")
reviewer = AssistantAgent("reviewer", model_client=model,
system_message="If the code is correct, reply TERMINATE. Otherwise critique.")
team = RoundRobinGroupChat(
participants=[planner, coder, reviewer],
termination_condition=TextMentionTermination("TERMINATE"),
max_turns=12,
)
await team.run(task="Write a function that detects palindromes in O(n).")What v0.4 Fixed
- Async-first runtime โ agents no longer block each other; you get real parallelism across tool calls.
- Typed messages โ
TextMessage,ToolCallMessage,HandoffMessageinstead of dict soup. - Distributed execution โ agents can live in different processes/machines via the
autogen-coreruntime. - Pluggable termination & selection โ composable conditions instead of one big
is_terminatecallback.
Common Failure Modes
- Infinite politeness loop โ agents keep thanking each other. Fix: require
TERMINATEin the reviewer's system prompt and capmax_turns. - Tool spam โ every agent gets every tool. Fix: scope tools per agent (planner = none, coder = code-exec, reviewer = lint only).
- Cost blowout โ round-robin on 4 agents ร 12 turns ร 8 KB context = surprise invoice. Fix: summarise after every N turns, and prefer
SelectorGroupChatfor sparse handoffs. - Human-proxy timing out โ long-running approval steps stall the loop. Fix: persist conversation state and use the resumable runtime (
autogen-coreworkers).
When to Reach for AutoGen vs LangGraph
- AutoGen wins when the natural unit is a conversation between roles (write/review/test, research/critique/edit).
- LangGraph wins when the natural unit is a state machine with explicit nodes and edges and durable checkpoints.
- If you need human-in-the-loop at arbitrary points, AutoGen's
UserProxyAgentis the lowest-friction option.
Production Checklist
- Pin model versions per agent โ "gpt-4o" without a date silently changes capability.
- Log every
TextMessage+ToolCallMessageto your trace store; AutoGen integrates cleanly with OpenTelemetry. - Run agents in a sandbox if they execute code (Docker, Azure Container Apps Jobs, or
autogen-ext.code_executors.docker). - Budget tokens per conversation, not per call โ a 12-turn loop on gpt-4o can quietly cost $0.40 a run.
Key Takeaways
- AutoGen models collaboration as a typed conversation, not a giant prompt.
- v0.4 is the version to learn โ async runtime, typed messages, distributed execution.
- Win by scoping tools per agent and forcing an explicit termination condition.

