AutoGen: Microsoft's Multi-Agent Conversation Framework
AutoGen by Microsoft Research enables multi-agent conversations where AI agents collaborate, debate, and solve complex tasks through dialogue. Agents can use tools, execute code, and involve humans in the loop.
Why AutoGen
- Agents converse to solve problems
- Code execution in sandboxed environment
- Human-in-the-loop at any step
- Group chat with multiple agents
- Tool use and function calling
The Free API
from autogen import AssistantAgent, UserProxyAgent
import os
config = [{"model": "gpt-4o", "api_key": os.getenv("OPENAI_API_KEY")}]
assistant = AssistantAgent(
name="coder",
llm_config={"config_list": config}
)
user = UserProxyAgent(
name="user",
human_input_mode="NEVER",
code_execution_config={"work_dir": "coding", "use_docker": True}
)
# Start conversation — assistant writes code, user executes it
user.initiate_chat(
assistant,
message="Write a Python script that downloads Bitcoin price for the last 30 days and plots it"
)
Group Chat (Multiple Agents)
from autogen import GroupChat, GroupChatManager
researcher = AssistantAgent("researcher", llm_config={"config_list": config},
system_message="You research topics and provide facts.")
writer = AssistantAgent("writer", llm_config={"config_list": config},
system_message="You write articles based on research.")
editor = AssistantAgent("editor", llm_config={"config_list": config},
system_message="You review and improve articles.")
groupchat = GroupChat(
agents=[researcher, writer, editor, user],
messages=[],
max_round=10
)
manager = GroupChatManager(groupchat=groupchat, llm_config={"config_list": config})
user.initiate_chat(manager, message="Write an article about eBPF in networking")
Function Calling
import requests
def get_weather(city: str) -> str:
"""Get current weather for a city."""
resp = requests.get(f"https://wttr.in/{city}?format=3")
return resp.text
assistant = AssistantAgent("assistant", llm_config={"config_list": config})
assistant.register_for_llm(name="get_weather", description="Get weather")(get_weather)
user.register_for_execution(name="get_weather")(get_weather)
user.initiate_chat(assistant, message="What is the weather in Tokyo?")
Real-World Use Case
A research lab needed to automate paper analysis. AutoGen group chat: Paper Reader (extracts key points) -> Critic (identifies weaknesses) -> Summarizer (creates brief). Processed 500 papers in a weekend, human reviewed only flagged ones.
Quick Start
pip install autogen-agentchat
Resources
Need AI agent data pipelines? Check out my tools on Apify or email spinov001@gmail.com.
Top comments (0)