Copilot Studio

Copilot Studio 統合を使用すると、エージェント フレームワーク内で Copilot Studio エージェントを使用できます。

次の例は、Copilot Studio を使用してエージェントを作成する方法を示しています。

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

// Create a Copilot Studio agent using the IChatClient pattern
// Requires: dotnet add package Microsoft.Agents.AI.CopilotStudio --prerelease
var copilotClient = new CopilotStudioChatClient(
    environmentId: "<your-environment-id>",
    agentIdentifier: "<your-agent-id>",
    credential: new AzureCliCredential());

AIAgent agent = copilotClient.AsAIAgent(
    instructions: "You are a helpful enterprise assistant.");

Console.WriteLine(await agent.RunAsync("What are our company policies on remote work?"));

ツール

エージェントCopilot Studioリモートで実行されます。エージェント定義 (トピック、ナレッジ ソース、生成アクション、プラグイン、MCP サーバー) は、Copilot Studio ポータルで作成されます。 Agent Framework Copilot Studio クライアントは、発行されたエージェントを呼び出し、その応答を表示します。 エージェント フレームワーク ツールの種類 (関数ツール、コード インタープリター、ファイル検索、ホスト/ローカル MCP など) をクライアントで公開します。 エージェントの機能を拡張するには、Copilot Studio エージェント自体でこれらの機能を構成します。

Copilot Studio エージェントの Python サポートは、 agent-framework-copilotstudio パッケージを通じて利用できます。

Installation

pip install agent-framework-copilotstudio --pre

コンフィギュレーション

自動構成用に次の環境変数を設定します。

COPILOTSTUDIOAGENT__ENVIRONMENTID="<your-environment-id>"
COPILOTSTUDIOAGENT__SCHEMANAME="<your-agent-schema-name>"
COPILOTSTUDIOAGENT__AGENTAPPID="<your-client-id>"
COPILOTSTUDIOAGENT__TENANTID="<your-tenant-id>"

Copilot Studio エージェントを作成する

CopilotStudioAgent は、環境変数から接続設定を自動的に読み取ります。

import asyncio
from agent_framework.microsoft import CopilotStudioAgent

async def main():
    agent = CopilotStudioAgent()

    result = await agent.run("What are our company policies on remote work?")
    print(result)

asyncio.run(main())

ツール

CopilotStudioAgent は、リモートで実行されるCopilot Studio エージェントを呼び出します。 エージェントの動作 (トピック、ナレッジ ソース、生成アクション、プラグイン、MCP サーバー) は、Python コードではなく、Copilot Studio ポータルで構成されます。 Agent Framework クライアントは、Agent Framework ツールの種類 (関数ツール、コード インタープリター、ファイル検索、ホスト/ローカル MCP など) をクライアントで公開 しません 。 エージェントの機能を拡張するには、Copilot Studio エージェント自体でこれらの機能を構成します。

ストリーミング

async def streaming_example():
    agent = CopilotStudioAgent()

    print("Agent: ", end="", flush=True)
    async for chunk in agent.run("What is the largest city in France?", stream=True):
        if chunk.text:
            print(chunk.text, end="", flush=True)
    print()

次のステップ