AutoGen is Microsoft's multi-agent conversation framework. Agents communicate via messages, support hierarchical conversation patterns, and can run distributed across machines.
pip install pyautogen
from autogen import AssistantAgent, UserProxyAgent
assistant = AssistantAgent(
name="Assistant",
llm_config={"config_list": [{"model": "gpt-4o", "api_key": "..."}]}
)
user = UserProxyAgent(
name="User",
human_input_mode="NEVER",
code_execution_config=False
)
user.initiate_chat(
assistant,
message="Explain the concept of agentic AI in simple terms."
)
| Pattern | Description |
|---|---|
| Two-Agent Chat | Basic conversation between assistant and user |
| Group Chat | Multiple agents discuss with a manager |
| Sequential Chat | Chain of agent conversations |
| Nested Chat | Chats within chats for complex workflows |
AutoGen agents can process images, execute code, and scrape web content.
# Multimodal agent
assistant = AssistantAgent(
name="MultimodalAssistant",
llm_config={"config_list": [{"model": "gpt-4o"}]}
)
# Agent can analyze images sent as messages
AutoGen Core enables distributed agent communication via gRPC. Agents can run on different machines and communicate asynchronously.
# Agent running on a remote worker
from autogen.runtime import GrpcWorkerAgent
worker = GrpcWorkerAgent(
name="Worker1",
address="localhost:50051"
)
# Orchestrator sends tasks to workers
orchestrator.send_message(worker, "Process this data")
Build agents that can autonomously deploy code, spin up new agents, and manage their own lifecycle.