AI Open Source · Agent 框架
microsoft/autogen
微软的 agent 编程框架,强调多 agent 协作与可编排的对话模式。 AutoGen 把 agent 视为可组合的程序单元,适合写需要多角色配合的 自动化流程,比如代码生成 + 评审 + 执行的小组协作。
A programming framework for agentic AI
- Stars
- ★ 58k
- Language
- Python
- License
- CC-BY-4.0
- Last push
- 1mo ago
- Created
- 2023-08-18
- Topics
- agenticagentic-agiagentsaiautogenautogen-ecosystem
README
<a name="readme-top"></a>
<div align="center"> <img src="https://microsoft.github.io/autogen/0.2/img/ag.svg" alt="AutoGen Logo" width="100"> </div>AutoGen 
AutoGen is a framework for creating multi-agent AI applications that can act autonomously or work alongside humans.
[!CAUTION] ⚠️ Maintenance Mode
AutoGen is now in maintenance mode. It will not receive new features or enhancements and is community managed going forward.
New users should start with Microsoft Agent Framework. Existing users are encouraged to migrate using the AutoGen → Microsoft Agent Framework migration guide.
Microsoft Agent Framework (MAF) is the enterprise‑ready successor to AutoGen. Microsoft Agent FrameworkAF in now available as a production-ready release: stable APIs, and a commitment to long-term support. Whether you're building a single assistant or orchestrating a fleet of specialized agents, Microsoft Agent Framework 1.0 gives you enterprise-grade multi-agent orchestration, multi-provider model support, and cross-runtime interoperability via A2A and MCP.
Installation
AutoGen requires Python 3.10 or later.
# Install AgentChat and OpenAI client from Extensions
pip install -U "autogen-agentchat" "autogen-ext[openai]"
The current stable version can be found in the releases. If you are upgrading from AutoGen v0.2, please refer to the Migration Guide for detailed instructions on how to update your code and configurations.
# Install AutoGen Studio for no-code GUI
pip install -U "autogenstudio"
Quickstart
The following samples call OpenAI API, so you first need to create an account and export your key as export OPENAI_API_KEY="sk-...".
Hello World
Create an assistant agent using OpenAI's GPT-4o model. See other supported models.
import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient
async def main() -> None:
model_client = OpenAIChatCompletionClient(model="gpt-4.1")
agent = AssistantAgent("assistant", model_client=model_client)
print(await agent.run(task="Say 'Hello World!'"))
await model_client.close()
asyncio.run(main())
MCP Server
Create a web browsing assistant agent that uses the Playwright MCP server.
# First run `npm install -g @playwright/mcp@latest` to install the MCP server.
import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.ui import Console
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_ext.tools.mcp import McpWorkbench, StdioServerParams
async def main() -> None:
model_client = OpenAIChatCompletionClient(model="gpt-4.1")
server_params = StdioServerParams(
command="npx",
args=[
"@playwright/mcp@latest",
"--headless",
],
)
async with McpWorkbench(server_params) as mcp:
agent = AssistantAgent(
"web_browsing_assistant",
model_client=model_client,
workbench=mcp, # For multiple MCP servers, put them in a list.
model_client_stream=True,
max_tool_iterations=10,
)
await Console(agent.run_stream(task="Find out how many contributors for the microsoft/autogen repository"))
asyncio.run(main())
Warning: Only connect to trusted MCP servers as they may execute commands in your local environment or expose sensitive information.
Multi-Agent Orchestration
You can use AgentTool to create a basic multi-agent orchestration setup.
import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.tools import AgentTool
from autogen_agentchat.ui import Console
from autogen_ext.models.openai import OpenAIChatCompletionClient
async
同一分类的其他项