0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Microsoft Agent Framework 1.0入門 — Semantic Kernel後継のマルチエージェントSDK全解説

0
Last updated at Posted at 2026-06-11

Microsoft Agent Framework 1.0 の概念図

はじめに

2026年4月3日、Microsoftは Agent Framework 1.0 を正式リリース(GA)しました。このSDKは、これまで別々に開発されていた Semantic KernelAutoGen の後継となる統合フレームワークで、.NET と Python の両方でプロダクション対応のAIエージェントを構築できます。

本記事では、Agent Framework 1.0 の主要機能・インストール方法・コードサンプルを公式ドキュメントをもとに解説します。

この記事で学べること

  • Agent Framework 1.0 の全体像とアーキテクチャ
  • Python / .NET での基本的なエージェント作成
  • ツール呼び出しと MCP(Model Context Protocol)サポート
  • マルチエージェントオーケストレーションパターン
  • Semantic Kernel / AutoGen からの移行方針

対象読者

  • Semantic Kernel または AutoGen を利用中の開発者
  • AIエージェント・マルチエージェントシステムを構築したいエンジニア
  • Python や .NET でプロダクション品質のAIシステムを実装したい方

前提環境

  • Python 3.10 以上 または .NET 8.0 以上
  • Azure サブスクリプション(Microsoft Foundry / Azure OpenAI 利用時)
  • OpenAI API キーや Anthropic API キーがあればクラウドなしでも動作可能

TL;DR

  • Agent Framework 1.0 は Semantic Kernel + AutoGen の統合後継 SDK(MIT オープンソース)
  • Python は pip install agent-framework、.NET は dotnet add package Microsoft.Agents.AI で導入可能
  • Azure OpenAI / OpenAI / Anthropic Claude / Gemini / Amazon Bedrock / Ollama など 7種類以上のプロバイダー をサポート
  • MCP サーバーをツールとして動的に接続可能。A2A プロトコルによるエージェント間通信は近日対応予定(1.0 GA 時点では preview 段階)
  • グラフベースのワークフローエンジンで Sequential / Concurrent / Handoff / Group Chat / Magentic-One の5パターンを提供

背景:Semantic Kernel と AutoGen の統合

Microsoftは2023年以降、AIエージェント開発のために2つのOSSフレームワークを並行して提供していました。

フレームワーク 特徴
Semantic Kernel エンタープライズ向け。型安全・セッション管理・テレメトリ・豊富なモデルサポート
AutoGen シンプルなエージェント抽象化。マルチエージェントパターンの実験的な探索に強い

両フレームワークは機能が重複しており、開発者はどちらを使うべきか判断が難しい状況でした。Agent Framework 1.0 はこれらを統合した 次世代SDK です。公式ドキュメントには次のように記されています:

Agent Framework combines AutoGen's simple agent abstractions with Semantic Kernel's enterprise features — session-based state management, type safety, middleware, telemetry — and adds graph-based workflows for explicit multi-agent orchestration.
Microsoft Agent Framework Overview

Semantic Kernel と AutoGen から Agent Framework 1.0 への統合アーキテクチャ


インストール

Python

pip install agent-framework

.NET / C#

dotnet add package Microsoft.Agents.AI

Azure Foundry 統合を使う場合は追加パッケージが必要です:

# Python
pip install agent-framework-foundry

# .NET
dotnet add package Microsoft.Agents.AI.Foundry
dotnet add package Azure.AI.Projects --prerelease
dotnet add package Azure.Identity

基本的なエージェントの作成

Python(Azure Foundry 経由)

公式ドキュメントに記載されている最小構成のコードです:

import asyncio
from agent_framework.foundry import FoundryChatClient
from agent_framework import Agent
from azure.identity import AzureCliCredential

async def main():
    client = FoundryChatClient(
        project_endpoint="https://your-project.services.ai.azure.com",
        model="gpt-4o",
        credential=AzureCliCredential(),
    )

    agent = Agent(
        client=client,
        name="HelloAgent",
        instructions="You are a friendly assistant. Keep your answers brief.",
    )

    # Non-streaming
    result = await agent.run("What is the capital of France?")
    print(f"Agent: {result}")

    # Streaming
    print("Agent (streaming): ", end="", flush=True)
    async for chunk in agent.run("Tell me a one-sentence fun fact.", stream=True):
        if chunk.text:
            print(chunk.text, end="", flush=True)
    print()

asyncio.run(main())

.NET / C#

using System;
using Azure.AI.Projects;
using Azure.Identity;
using Microsoft.Agents.AI;

var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")
    ?? throw new InvalidOperationException("Set AZURE_OPENAI_ENDPOINT");

AIAgent agent = new AIProjectClient(new Uri(endpoint), new DefaultAzureCredential())
    .AsAIAgent(
        model: "gpt-4o-mini",
        instructions: "You are a friendly assistant. Keep your answers brief.",
        name: "HelloAgent");

Console.WriteLine(await agent.RunAsync("What is the largest city in France?"));

// Streaming
await foreach (var update in agent.RunStreamingAsync("Tell me a fun fact."))
{
    Console.Write(update);
}

対応プロバイダー一覧

Agent Framework 1.0 では以下のプロバイダーに対応しています(公式 Providers ページ参照):

プロバイダー 説明
Microsoft Foundry Azure AI 統合(クラウド版、推奨)
Foundry Local ローカル環境での Microsoft Foundry 実行
Azure OpenAI Azure 上の OpenAI モデル
OpenAI OpenAI API 直接接続
Anthropic Claude Claude 3.5 / Opus 4.x 等
Ollama ローカル LLM 実行
GitHub Copilot GitHub Copilot 統合

リリースブログでは Amazon Bedrock・Google Gemini も言及されていますが、公式 Providers ドキュメントの掲載状況は時期によって異なります。最新の対応状況は公式ドキュメントをご確認ください。


ツールの追加

エージェントにツール(関数)を持たせる方法は、Python デコレータで簡潔に記述できます:

from agent_framework import Agent, tool
from agent_framework.foundry import FoundryChatClient
from azure.identity import AzureCliCredential

@tool
def get_weather(city: str) -> str:
    """Get the current weather for a given city."""
    # 実際のAPIコールをここに実装
    return f"The weather in {city} is sunny with a high of 25°C."

async def main():
    client = FoundryChatClient(
        project_endpoint="https://your-project.services.ai.azure.com",
        model="gpt-4o",
        credential=AzureCliCredential(),
    )

    agent = Agent(
        client=client,
        name="WeatherAgent",
        instructions="You are a helpful weather assistant.",
        tools=[get_weather],
    )

    result = await agent.run("What's the weather like in Tokyo?")
    print(result)

MCP サーバーとの連携

Agent Framework 1.0 の重要な特徴として、MCP(Model Context Protocol)サーバーをツールとして動的に接続 できます。公式ドキュメントには次のように記されています:

MCP support lets agents dynamically discover and invoke external tools exposed over MCP-compliant servers
Agent Framework 1.0 Release Notes

MCPサーバー接続の概要(.NET の例):

// MCP サーバーをエージェントのツールとして登録
var agent = new AIProjectClient(new Uri(endpoint), new DefaultAzureCredential())
    .AsAIAgent(
        model: "gpt-4o",
        instructions: "Use available tools to answer questions.",
        name: "MCPAgent")
    .WithMcpServer("http://localhost:3000"); // MCP サーバーのエンドポイント

var result = await agent.RunAsync("Search for the latest AI news.");
Console.WriteLine(result);

MCP と A2A(Agent-to-Agent)プロトコルの役割分担は以下の通りです:

プロトコル 用途
MCP エージェント → ツール(縦方向の接続)
A2A エージェント ↔ エージェント(横方向の協調)※ 1.0 GA 時点では preview 段階、近日 GA 予定

マルチエージェントオーケストレーション

Agent Framework 1.0 では5種類のマルチエージェントパターンが提供されています:

マルチエージェントオーケストレーションの5パターン

パターン 説明 適用例
Sequential エージェントを順番に実行 翻訳 → 要約 → 校正のパイプライン
Concurrent 複数エージェントを並列実行 複数ソースからの情報収集
Handoff 条件に応じてエージェントを切り替え カスタマーサポートのエスカレーション
Group Chat 複数エージェントが会話形式で協調 コードレビューチーム
Magentic-One 特化型エージェントを統括するオーケストレーター 複雑なリサーチタスク

Python でのSequentialパターンの例:

from agent_framework import Agent
from agent_framework.orchestrations import SequentialBuilder
from agent_framework.foundry import FoundryChatClient
from azure.identity import AzureCliCredential
import asyncio

async def main():
    client = FoundryChatClient(
        project_endpoint="https://your-project.services.ai.azure.com",
        model="gpt-4o",
        credential=AzureCliCredential(),
    )

    researcher = Agent(
        client=client,
        name="Researcher",
        instructions="You research topics and provide detailed summaries.",
    )

    writer = Agent(
        client=client,
        name="Writer",
        instructions="You take research summaries and write concise blog posts.",
    )

    # Sequential: researcher → writer
    workflow = SequentialBuilder(participants=[researcher, writer]).build()
    result = await workflow.run("Write a blog post about Microsoft Agent Framework 1.0.")
    print(result)

asyncio.run(main())

グラフベースのワークフローエンジン

複雑な多ステップ処理には、グラフベースのワークフローエンジンが利用できます:

  • 条件分岐:ルーティングロジックで次のノードを動的に選択
  • 並列実行:独立したノードを同時実行
  • チェックポイント:長時間実行プロセスの途中状態を保存
  • Human-in-the-loop:人間の承認が必要なステップを定義

ワークフローはYAMLで宣言的に記述することも可能です。


ミドルウェアパイプライン

Agent Framework 1.0 のミドルウェアは、エージェントの動作をプロンプトを変更せずに横断的に拡張できます:

from agent_framework import Agent, agent_middleware, AgentRunContext
from agent_framework.foundry import FoundryChatClient

@agent_middleware
async def logging_middleware(context: AgentRunContext, next_handler):
    print(f"[LOG] Agent run started")
    result = await next_handler(context)
    print(f"[LOG] Agent run completed")
    return result

agent = Agent(
    client=client,
    name="LoggedAgent",
    instructions="You are a helpful assistant.",
    middleware=[logging_middleware],
)

ミドルウェアの活用例:

  • コンテンツ安全性フィルター:有害なコンテンツをブロック
  • ロギング・テレメトリ:OpenTelemetry との統合
  • コンプライアンスポリシー:社内規程に合わせた制御
  • レート制限:API コストの制御

メモリアーキテクチャ

Agent Framework 1.0 では3層のメモリ管理が提供されています:

レイヤー 説明 バックエンド例
会話履歴 マルチターン対話の文脈管理 In-memory
キー・バリュー状態 セッション間でのデータ永続化 Redis, Azure Table
ベクトル検索 セマンティック検索によるコンテキスト取得 Redis, Neo4j, Mem0

Semantic Kernel / AutoGen からの移行

既存の Semantic Kernel や AutoGen プロジェクトを移行する場合、公式の移行ガイドが提供されています:

また、移行を支援する Migration Assistant ツールも提供されており、既存コードベースの自動変換をサポートします。

Semantic Kernel と AutoGen は引き続きメンテナンスされますが、新規プロジェクトでは Agent Framework 1.0 が推奨されます。


まとめ

  • Agent Framework 1.0 は Semantic Kernel と AutoGen を統合した Microsoft の次世代 AIエージェント SDK(2026年4月3日 GA)
  • Python・.NET の両方に対応し、MIT ライセンスで公開
  • Azure OpenAI・OpenAI・Anthropic Claude・Gemini など7種以上のモデルプロバイダーをサポート
  • MCP によるツール動的接続でオープンなエコシステムを実現。A2A プロトコルは近日 GA 予定
  • Sequential / Concurrent / Handoff など5パターンのマルチエージェントオーケストレーションをネイティブサポート
  • ミドルウェアパイプライン・グラフベースワークフロー・3層メモリ管理でプロダクション品質を担保

参考リンク

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?