What Is AutoGen?
AutoGen is Microsoft Research's framework for building multi-agent AI systems through structured agent conversation. The core metaphor is dialogue: agents talk to each other, request things from each other, and iteratively produce outputs through back-and-forth exchange.
This distinguishes AutoGen from frameworks like CrewAI, where tasks flow sequentially from one agent to the next. In AutoGen, agents can challenge each other's outputs, request revisions, and converge on answers through genuine multi-turn dialogue.
The Two-Agent Pattern
The most common AutoGen pattern pairs an AssistantAgent with a UserProxyAgent:
import autogen
config_list = [{"model": "gpt-4o", "api_key": "YOUR_KEY"}]
assistant = autogen.AssistantAgent(
name="assistant",
llm_config={"config_list": config_list},
)
user_proxy = autogen.UserProxyAgent(
name="user_proxy",
human_input_mode="NEVER", # fully automated
max_consecutive_auto_reply=10,
code_execution_config={
"work_dir": "coding",
"use_docker": False,
},
)
user_proxy.initiate_chat(
assistant,
message="Plot a chart of AAPL stock price over the past year using yfinance.",
)
The AssistantAgent writes Python code. The UserProxyAgent executes it in a sandbox, sends back the output, and the loop continues until the task is complete or the reply limit is reached.