AutoGen も v0.4 から MCP に対応しています。最新版の v0.7.4 安定版の README を翻訳します。
AutoGen は、自律的に行動したり人間とともに作業可能なマルチエージェント AI アプリケーションを作成するためのフレームワークです。
AutoGen 0.7 : マルチエージェント・フレームワーク : 概要
作成 : クラスキャット・セールスインフォメーション
作成日時 : 08/26/2025
バージョン : python-v0.7.4
* 本記事は github microsoft/autogen の以下のページを独自に翻訳した上でまとめ直し、補足説明を加えています :
* サンプルコードの動作確認はしておりますが、必要な場合には適宜、追加改変しています。
* ご自由にリンクを張って頂いてかまいませんが、sales-info@classcat.com までご一報いただけると嬉しいです。
AutoGen 0.7 : マルチエージェント・フレームワーク : 概要
AutoGen は、自律的に行動したり人間とともに作業可能なマルチエージェント AI アプリケーションを作成するためのフレームワークです。
インストール
AutoGen は Python 3.10 またはそれ以降 のバージョンが必要です。
# Install AgentChat and OpenAI client from Extensions
pip install -U "autogen-agentchat" "autogen-ext[openai]"
# Install AutoGen Studio for no-code GUI
pip install -U "autogenstudio"
クイックスタート
Hello World
OpenAI の GPT-4o モデルを使用してアシスタント・エージェントを作成します。他のサポートされているモデル を確認してください。
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())
messages=[TextMessage(source='user', models_usage=None, metadata={}, content="Say 'Hello World!'", type='TextMessage'), TextMessage(source='assistant', models_usage=RequestUsage(prompt_tokens=41, completion_tokens=3), metadata={}, content='Hello World!', type='TextMessage')] stop_reason=None
MCP サーバ
Playwright MCP サーバを使用する、web ブラウジング・アシスタントを作成します。
# 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@0.0.35
#"@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.
マルチエージェント・オーケストレーション
AgentTool を使用して基本的なマルチエージェント・オーケストレーションのセットアップを作成できます。
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 def main() -> None:
model_client = OpenAIChatCompletionClient(model="gpt-4.1")
math_agent = AssistantAgent(
"math_expert",
model_client=model_client,
system_message="You are a math expert.",
description="A math expert assistant.",
model_client_stream=True,
)
math_agent_tool = AgentTool(math_agent)
#math_agent_tool = AgentTool(math_agent, return_value_as_last_message=True)
chemistry_agent = AssistantAgent(
"chemistry_expert",
model_client=model_client,
system_message="You are a chemistry expert.",
description="A chemistry expert assistant.",
model_client_stream=True,
)
chemistry_agent_tool = AgentTool(chemistry_agent)
#chemistry_agent_tool = AgentTool(chemistry_agent, return_value_as_last_message=True)
agent = AssistantAgent(
"assistant",
system_message="You are a general assistant. Use expert tools when needed.",
model_client=model_client,
model_client_stream=True,
tools=[math_agent_tool, chemistry_agent_tool],
max_tool_iterations=10,
)
await Console(agent.run_stream(task="What is the integral of x^2?"))
await Console(agent.run_stream(task="What is the molecular weight of water?"))
asyncio.run(main())
For more advanced multi-agent orchestrations and workflows, read AgentChat documentation.
AutoGen Studio
AutoGen Studio を使用して、コードを記述することなくマルチエージェント・ワークフローのプロトタイプを作成して実行できます。
# Run AutoGen Studio on http://localhost:8080
autogenstudio ui --port 8080 --appdir ./my-app
Why Use AutoGen?
AutoGen エコシステムは AI エージェント、特にマルチエージェント・ワークフローを作成するために必要なものすべて — フレームワーク、開発者ツール、そしてアプリケーションを提供します。
フレームワークは階層化された拡張可能な設計を使用しています。レイヤーは明確に分割された役割を持ち、下のレイヤーの上に構築されます。この設計は高位 API から低位コンポーネントまで、様々な抽象化レベルでフレームワークを使用することを可能にします。
- Core API は、柔軟で強力なメッセージパッシング、イベント駆動型エージェント、ローカル/分散ランタイムを実装しています。それはまた .NET と Python のためにクロス言語サポートもサポートしています。
- AgentChat API は、ラピッドプロトタイピングのためにより単純で設計思想の強い (opinionated) API を実装しています。この API は Core API 上に構築されており、v0.2 のユーザに馴染みのあるものに非常に近く、そして 2 エージェント・チャットやグループチャットのような一般的なマルチエージェント・パターンをサポートします。
- Extensions API は、ファーストパーティやサードパーティの拡張が継続的にフレームワークの機能を拡張できるようにします。それは LLM クライアント (e.g., OpenAI, AzureOpenAI) の特定の実装とコード実行のような機能をサポートします。
エコシステムはまた 2 つの不可欠な開発者ツールもサポートします :
- AutoGen Studio は、マルチエージェント・アプリケーションを構築するためのノーコード GUI を提供します。
- AutoGen Bench は、エージェント性能を評価するためのベンチマーク・スイートを提供します。
AutoGen フレームワークと開発者ツールを使用して独自ドメイン用のアプリケーションを作成できます。例えば、Magentic-One は、AgentChat API and Extensions API を使用して構築された最先端のマルチエージェント・チームで、Web ブラウジング、コード実行やファイル処理を必要とする様々なタスクを処理できます。
Legal Notices
(訳註: 原文 参照)
以上