// AI NATIVE STACK

AI Native › AI Agent › Agent Framework › AutoGen

CRASH COURSE · AI-NATIVE · intermediate · 16 min read · v0.4

AutoGen — multi-agent conversations from Microsoft Research.

agent-framework ai-native autogen multi-agent microsoft python

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.

Researcher agent + tools Writer agent + tools Team Orchestrator round-robin / selector termination conditions Final Result

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

ToolBest forTrade-off
AutoGenMulti-agent conversations, research workflowsAsync-first; API churn from v0.2→v0.4
CrewAIQuick role-based agent teamsLess flexible orchestration
LangGraphExplicit graph control flowNot conversation-native
CAMELRole-playing agent researchMore academic, less production

Verified against AutoGen v0.4 docs (microsoft.github.io/autogen), May 2026.

← AI Native Stack
© cvam — written in plaintext, served warm