Core Concepts
Agents
Each agent has a role and system message:
planner = AssistantAgent("planner", model_client=model,
system_message="Break down complex tasks into steps. Coordinate with coder and reviewer.")
coder = AssistantAgent("coder", model_client=model,
system_message="Write clean, tested Python code.")
reviewer = AssistantAgent("reviewer", model_client=model,
system_message="Review code for bugs, edge cases, and improvements.")Teams
Round Robin — agents take turns:
team = RoundRobinGroupChat([planner, coder, reviewer], max_turns=6)Selector — a model picks who speaks next:
team = SelectorGroupChat([planner, coder, reviewer],
model_client=model) # Model decides speaking orderHuman-in-the-Loop
from autogen_agentchat.agents import UserProxyAgent
human = UserProxyAgent("human")
team = RoundRobinGroupChat([coder, reviewer, human], max_turns=10)
# Pauses for human input when human's turn comesCode Execution
Agents can write and run code in sandboxed environments:
from autogen_ext.code_executors.docker import DockerCommandLineCodeExecutor
executor = DockerCommandLineCodeExecutor()
coder = AssistantAgent("coder", model_client=model,
code_executor=executor)Tool Use
from autogen_core import FunctionTool
def search_web(query: str) -> str:
'Search the web for information.'
return tavily_search(query)
search_tool = FunctionTool(search_web, description="Search the web")
agent = AssistantAgent("researcher", model_client=model, tools=[search_tool])Real-World Example: Research Paper
researcher = AssistantAgent("researcher", tools=[search_tool])
writer = AssistantAgent("writer", system_message="Write academic-style content")
editor = AssistantAgent("editor", system_message="Edit for clarity and accuracy")
human = UserProxyAgent("professor")
team = SelectorGroupChat([researcher, writer, editor, human])
result = await team.run(task="Write a literature review on LLM agents in software engineering")Key Stats
- 40,000+ GitHub stars
- By Microsoft Research
- Event-driven architecture (v0.4)
- Human-in-the-loop support
- Docker code execution sandbox
FAQ
Q: What is AutoGen? A: A Microsoft Research framework for building multi-agent AI systems where agents converse and collaborate to solve complex tasks, with human-in-the-loop support.
Q: Is AutoGen free? A: Yes, open-source under MIT license.
Q: How is AutoGen different from CrewAI? A: AutoGen focuses on agent conversations and debate. CrewAI focuses on role-based task delegation. AutoGen is more flexible for complex multi-turn interactions.