Slide 1

Slide 1 text

正式リリースされた Semantic Kernel の Agent Framework 全部紹介! 2025/05/10 (土) 日本マイクロソフト Cloud Solution Architect & Evangelist 大田 一希

Slide 2

Slide 2 text

自己紹介 日本マイクロソフト Cloud Solution Architect & Evangelist 大田 一希 (Kazuki Ota) X: @okazuki https://zenn.dev/okazuki 好き: .NET (20年以上)、Azure PaaS、Azure AI 苦手: インテリセンスの弱い言語 趣味: 技術ブログ書き、お絵描き、ゲーム (最近は原神)

Slide 3

Slide 3 text

本セッションの目的 Agent を作るのに Semantic Kernel 使ってみようかなって思ってもらう

Slide 4

Slide 4 text

前提条件 2025年5月10日時点の情報です C#、Python、Java (Preview) に対応していますが 今回は C# で説明を行います Preview 機能も紹介しますが、Preview 機能の本番環境での採用は慎重に

Slide 5

Slide 5 text

もくじ  Semantic Kernel のコア機能  Agent Framework  まとめ

Slide 6

Slide 6 text

Semantic Kernel のコア機能

Slide 7

Slide 7 text

Semantic Kernel Build intelligent AI agents and multi- agent systems with this enterprise- ready orchestration framework エンタープライズ対応の インテリジェントな AI エージェント とマルチ エージェント システムを 構築するフレームワーク

Slide 8

Slide 8 text

Semantic Kernel のコア機能と特徴  モデル非依存の API  OpenAI, Azure OpenAI, Hugging Face, Ollama, etc…  プロンプトを扱うための機能  プロンプト テンプレート エンジン (独自, Handlebars, Liquid)  YAML 形式のプロンプトの読み込み機能  Plugins による拡張機能 (Function calling)  エンタープライズ向けの機能  可観測性、フィルター  安定した API  プレビューが外れた API には破壊的変更はほぼ無い  対応プログラミング言語  Python: 3.10+  .NET: 8.0+, .NET Standard 2.0  Java: JDK17+

Slide 9

Slide 9 text

デモ: Semantic Kernel 1: 純粋なプロンプト呼び出し 2: モデル非依存の Chat Completions API 3: 自動関数呼び出し、フィルターによる Human In The Loop

Slide 10

Slide 10 text

Semantic Kernel のコア機能 便利に AI を使えるユーテリティ的な立ち位置 • モデル非依存のコードを書ける • プラグインを使って拡張可能 • 便利機能も揃ってる • プロンプト用のテンプレートエンジン • エンタープライズ用途を想定されている • 安定した API 、フィルターなど

Slide 11

Slide 11 text

Semantic Kernel の高度な機能やプレビュー機能 フレームワーク •エージェント フレームワーク •シングル エージェント •マルチ エージェント機能 (Preview) •プロセス フレームワーク (Preview) その他の機能 •便利な組み込みプラグイン (Preview) •OpenAPI をプラグインとして読み込む •ベクトル検索、ハイブリッド検索の API の抽象化 (Preview) •テキスト検索機能の抽象化 (Preview) •Model Context Protocol サポート (Preview)

Slide 12

Slide 12 text

Semantic Kernel の高度な機能やプレビュー機能 フレームワーク •エージェント フレームワーク •シングル エージェント •マルチ エージェント機能 (Preview) •プロセス フレームワーク (Preview) その他の機能 •便利な組み込みプラグイン (Preview) •OpenAPI をプラグインとして読み込む •メモリによるベクトル検索、ハイブリッド検索の API の抽象化 (Preview) •テキスト検索機能の抽象化 (Preview) •Model Context Protocol サポート (Preview) 本日のフォーカスエリア

Slide 13

Slide 13 text

Agent Framework とは

Slide 14

Slide 14 text

Agent Framework Semantic Kernel のコア機能の上に構築された AI Agent を構築するため のフレームワーク  Agent 抽象化レイヤーを提供  抽象レイヤーに対して様々な実装を提供  ChatCompletionAgent: Chat Completions API を使用した Agent の実装  OpenAIAssistantAgent: Assistant API を使用した Agent の実装 (Preview)  AzureAIAgent: Azure AI Agent Service を使用した Agent の実装 (Preview)  OpenAIResponsesAgent: OpenAI Responses API を使用した Agent の実装 (Preview)  BedrockAgent: AWS の Bedrock を使用した Agent の実装 (Preview)  マルチエージェント機能  AgentGroupChat (Preview)  Agent の Plugin 化 (Preview)

Slide 15

Slide 15 text

Agent 抽象化レイヤー エージェントの機能を Agent と AgentThread に抽象化 Agent agent = ...Agentを作る...; const string userInput = "こんにちは!!"; AgentThread? thread = null; await foreach (AgentResponseItem response in agent.InvokeAsync(userInput, thread)) { thread = response.Thread; Console.WriteLine(response.Message.Content); } if (thread !. null) await thread.DeleteAsync(); const string userInput = "こんにちは!!"; var response = await agent.InvokeAsync(userInput).FirstAsync(); Console.WriteLine(response.Message.Content); 複数の応答に対応したいとき 単発の応答のみの場合

Slide 16

Slide 16 text

Agent 抽象化レイヤー エージェントの機能を Agent と AgentThread に抽象化 Agent agent = ...Agentを作る...; const string userInput = "こんにちは!!"; AgentThread? thread = null; await foreach (AgentResponseItem response in agent.InvokeAsync(userInput, thread)) { thread = response.Thread; Console.WriteLine(response.Message.Content); } if (thread !. null) await thread.DeleteAsync(); const string userInput = "こんにちは!!"; var response = await agent.InvokeAsync(userInput).FirstAsync(); Console.WriteLine(response.Message.Content); 複数の応答に対応したいとき 単発の応答のみの場合 会話のスレッド Agent を呼び出す 結果をハンドリング 終わったらスレッドを削除

Slide 17

Slide 17 text

Agent 抽象化レイヤー エージェントの機能を Agent と AgentThread に抽象化 Agent agent = ...Agentを作る...; const string userInput = "こんにちは!!"; AgentThread? thread = null; await foreach (AgentResponseItem response in agent.InvokeAsync(userInput, thread)) { thread = response.Thread; Console.WriteLine(response.Message.Content); } if (thread !. null) await thread.DeleteAsync(); const string userInput = "こんにちは!!"; var response = await agent.InvokeAsync(userInput).FirstAsync(); Console.WriteLine(response.Message.Content); 複数の応答に対応したいとき 単発の応答のみの場合 Agent を呼び出して結果を受け取る

Slide 18

Slide 18 text

Agent 抽象化レイヤー エージェントの機能を Agent と AgentThread に抽象化 Agent agent = ...Agentを作る...; const string userInput = "こんにちは!!"; AgentThread? thread = null; await foreach (AgentResponseItem response in agent.InvokeAsync(userInput, thread)) { thread = response.Thread; Console.WriteLine(response.Message.Content); } if (thread !. null) await thread.DeleteAsync(); const string userInput = "こんにちは!!"; var response = await agent.InvokeAsync(userInput).FirstAsync(); Console.WriteLine(response.Message.Content); 複数の応答に対応したいとき 単発の応答のみの場合 どの Agent も同じコードで 呼び出し可能

Slide 19

Slide 19 text

ChatCompletionAgent の作成方法 Agent の名前や指示 (System Prompt) などを設定して作成 Agent agent = new ChatCompletionAgent { /. Agent 名 Name = "CatAgent", /. Agent への指示 (System Prompt) Instructions = """ あなたは猫型アシスタンスです。猫らしく振舞うために語尾は「にゃん」にしてください。 わからないことに関しては素直にわからないという旨を猫っぽく伝えてください。 """, /. Agent が使用するプラグインなどを含んだ Kernel Kernel = kernel, /. モデルを呼ぶときの細かい設定 Arguments = new(new PromptExecutionSettings() { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto(), }), }; 名前を設定 システムプロンプトを設定 プラグインを含んだ Kernel を設定 関数呼び出しの自動化などの細かい設定

Slide 20

Slide 20 text

Agent 抽象化レイヤー Semantic Kernel のコア機能の上に構築  Semantic Kernel のコア機能の機能をシームレスに利用可能  プラグイン呼び出し  プロンプトのテンプレート エンジン  フィルター  など…

Slide 21

Slide 21 text

デモ: シンプルな Agent 1: 猫型エージェント 2: Plugin 機能を使ったエージェント 3: フィルターによる Human In The Loop 4: Azure AI Agent Service を使った Agent

Slide 22

Slide 22 text

マルチエージェント機能 (Preview)  AgentGroupChat  複数の Agent が参加するグループチャットを作る機能  Agent のプラグイン化  Agent をプラグインとして別の Agent から呼ぶことが出来るようになる機能

Slide 23

Slide 23 text

AgentGroupChat 複数の Agent を連携させてタスクをこなすための機能  複数の Agent を追加可能  ChatCompletionAgent, AzureAIAgent など複数のタイプの Agent を追加可能  AI のオーケストレーション機能  SelectionStrategy 次に、どの Agent が話すべきかを決める  TerminationStrategy Agent 同士の会話を終了すべきかどうかを決める  エージェントのチャット履歴を減らす機能  Agent の会話履歴が長くなった時に短くするための機能  AgentGroupChat を Agent として扱う機能  AgentGroupChat の入れ子が可能になる

Slide 24

Slide 24 text

AgentGroupChat のイメージ AgentGroupChat XXXXについて教えてください SelectionStrategy Agent A Agent B Agent C TerminationStrategy YYYYです! 誰が対応すべきか決める! 会話を終了すべきか決める!

Slide 25

Slide 25 text

AgentGroupChat この後のデモの内容 Writer agent Reviewer agent XXXについての 記事を書いて 記事 指摘事項 指摘有り 指摘無し 最終稿 この動きを実現するための AgentGroupChat の設定 SelectionStrategy : Agent を順番に実行 (標準提供のクラスを利用) TerminationStrategy : Reviewer agent が OK を出したら終了

Slide 26

Slide 26 text

デモ: AgentGroupChat Writer と Reviewer による記事作成 Agent

Slide 27

Slide 27 text

Agent のプラグイン化 Agent をプラグイン化  プラグイン化をした Agent を別の Agent から使うことで マルチエージェント化が可能 /. プラグインを作成 var plugin = KernelPluginFactory.CreateFromFunctions( "PluginName", /. Agent を関数化 [AgentKernelFunctionFactory.CreateFromAgent(agent)]); /. プラグインをカーネルに追加 kernel.Plugins.Add(plugin); Agent を関数化 関数をプラグイン化

Slide 28

Slide 28 text

Agent のプラグイン化を使用した場合のイメージ Orchestrator agent Reviewer agent Writer agent 指摘がゼロになるま でライターに記事を 書かせる Agent XXXについての 記事を書いて Writer plugin Reviewer plugin 記事書いて レビュー指摘反映して レビューして 最終稿

Slide 29

Slide 29 text

GA テクノロジーだけでマルチエージェントするには? 現時点では Agent 同士のオーケストレーションは手組が必要 1. Agent を複数呼び分けるコードを自分で書く 2. Agent をラップしたプラグインを自作

Slide 30

Slide 30 text

GA テクノロジーでマルチエージェントするには? Agent の実行基板 1. 短時間で終わるような処理 • Azure App Service • Container Apps • AKS • Azure Functions 2. 耐久性が欲しかったり実行時間が長い場合にも対応したい場合 1. Container Apps (ジョブ機能) 2. AKS 3. Azure Functions の Durable Functions (個人的な推し)

Slide 31

Slide 31 text

バックエンド フロントエンド この後のデモの内容 Reviewer agent Writer agent Durable Functions AI オーケストレーター レビュー指摘が 無くなるまで 執筆依頼をする 依頼 進捗確認 結果取得 レビュー依頼 執筆依頼

Slide 32

Slide 32 text

デモ: Durable Functions を使用したマルチエージェント Writer と Reviewer による記事作成 Agent

Slide 33

Slide 33 text

まとめ

Slide 34

Slide 34 text

今日説明した Semantic Kernel の機能 Semantic Kernel 各種LLM LLM の 抽象化 各種外部 リソース MCP サーバー Agent の 抽象化 Agent系 サービス Agentの 実装 AI対応 アプリ Kernel サービス フィルター プラグイン LLMごとの 実装 マルチ Agent機能

Slide 35

Slide 35 text

まとめ  Semantic Kernel 基本機能  プラグイン、フィルター、モデル非依存、など  Agent Framework  Semantic Kernel の基本機能の上に構築された Agent 開発のための機能  マルチエージェント系はまだプレビュー… (本番では手組が必要です)  AI を使ったアプリをホストするためのサービス  Azure Functions の Durable Functions (個人的な推し)  Container Apps  Azure App Service  AKS

Slide 36

Slide 36 text

まとめ  Semantic Kernel 基本機能  プラグイン、フィルター、モデル非依存、など  Agent Framework  Semantic Kernel の基本機能の上に構築された Agent 開発のための機能  マルチエージェント系はまだプレビュー… (本番では手組が必要です)  AI を使ったアプリをホストするためのサービス  Azure Functions の Durable Functions (個人的な推し)  Container Apps  Azure App Service  AKS Semantic Kernel を使って Agent 対応アプリを開発してみてください

Slide 37

Slide 37 text

参考資料  Semantic Kernel のドキュメント  https://learn.microsoft.com/ja-jp/semantic-kernel/overview/  Semantic Kernel の GitHub リポジトリ  リポジトリトップ: https://github.com/microsoft/semantic-kernel  サンプル(C#) : https://github.com/microsoft/semantic-kernel/tree/main/dotnet/samples  サンプル(Python) : https://github.com/microsoft/semantic-kernel/tree/main/python/samples  サンプル(Java) : https://github.com/microsoft/semantic-kernel-java/tree/main/samples  デモで使用したコード  https://github.com/runceel/GlobalAzure2025 サンプルめっちゃ有用

Slide 38

Slide 38 text

© Copyright Microsoft Corporation. All rights reserved.