次の方法で共有


ツールの概要

Agent Framework では、エージェント機能を拡張するさまざまな種類のツールがサポートされています。 ツールを使用すると、エージェントは外部システムとの対話、コードの実行、データの検索などを行うことができます。

ツールの種類

ツールの種類 Description
関数ツール エージェントが会話中に呼び出すことができるカスタム コード
ツールの承認 ツール呼び出しに対する人間のループ内承認
コード インタープリター サンドボックス環境でコードを実行する
ファイル検索 アップロードしたファイルを検索する
Web 検索 Web で情報を検索する
ホストされている MCP ツール Azure AI Foundry によってホストされる MCP ツール
ローカル MCP ツール ローカルまたはカスタム サーバー上で実行されている MCP ツール

プロバイダー サポート マトリックス

OpenAI プロバイダーと Azure OpenAI プロバイダーはそれぞれ、異なるツール機能を備えた複数のクライアントの種類を提供します。 Azure OpenAI クライアントは、OpenAI に相当するものをミラー化します。

ツールの種類 チャットの完了 応答 アシスタント Azure AI Foundry Anthropic オラマ GitHub Copilot コピロット スタジオ
関数ツール
ツールの承認
コード インタープリター
ファイル検索
Web 検索
ホストされている MCP ツール
ローカル MCP ツール

[チャットの完了]、[応答]、および [アシスタント] 列は、OpenAI と Azure OpenAI の両方に適用されます。Azure バリアントは、対応する OpenAI と同じツール サポートを反映しています。

プロバイダー サポート マトリックス

OpenAI プロバイダーと Azure OpenAI プロバイダーはそれぞれ、異なるツール機能を備えた複数のクライアントの種類を提供します。 Azure OpenAI クライアントは、OpenAI に相当するものをミラー化します。

ツールの種類 チャットの完了 応答 アシスタント Azure AI Foundry Anthropic Claude Agent オラマ GitHub Copilot
関数ツール
ツールの承認
コード インタープリター
ファイル検索
Web 検索
画像生成
ホストされている MCP ツール
ローカル MCP ツール

[チャットの完了]、[応答]、および [アシスタント] 列は、OpenAI と Azure OpenAI の両方に適用されます。Azure バリアントは、対応する OpenAI と同じツール サポートを反映しています。 ローカル MCP ツールは、関数ツールをサポートする任意のプロバイダーと連携します。

エージェントを関数ツールとして使用する

エージェントを別のエージェントの関数ツールとして使用して、エージェントの構成とより高度なワークフローを有効にすることができます。 内部エージェントは関数ツールに変換され、外部エージェントに提供され、必要に応じて呼び出すことができます。

AIAgent.AsAIFunction()を呼び出して、別のエージェントに提供できる関数ツールに変換します。

// Create the inner agent with its own tools
AIAgent weatherAgent = new AzureOpenAIClient(
    new Uri("https://<myresource>.openai.azure.com"),
    new AzureCliCredential())
     .GetChatClient("gpt-4o-mini")
     .AsAIAgent(
        instructions: "You answer questions about the weather.",
        name: "WeatherAgent",
        description: "An agent that answers questions about the weather.",
        tools: [AIFunctionFactory.Create(GetWeather)]);

// Create the main agent and provide the inner agent as a function tool
AIAgent agent = new AzureOpenAIClient(
    new Uri("https://<myresource>.openai.azure.com"),
    new AzureCliCredential())
     .GetChatClient("gpt-4o-mini")
     .AsAIAgent(instructions: "You are a helpful assistant.", tools: [weatherAgent.AsAIFunction()]);

// The main agent can now call the weather agent as a tool
Console.WriteLine(await agent.RunAsync("What is the weather like in Amsterdam?"));

エージェント .as_tool() 呼び出して、別のエージェントに提供できる関数ツールに変換します。

from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential

# Create the inner agent with its own tools
weather_agent = AzureOpenAIChatClient(credential=AzureCliCredential()).as_agent(
    name="WeatherAgent",
    description="An agent that answers questions about the weather.",
    instructions="You answer questions about the weather.",
    tools=get_weather
)

# Create the main agent and provide the inner agent as a function tool
main_agent = AzureOpenAIChatClient(credential=AzureCliCredential()).as_agent(
    instructions="You are a helpful assistant.",
    tools=weather_agent.as_tool()
)

# The main agent can now call the weather agent as a tool
result = await main_agent.run("What is the weather like in Amsterdam?")
print(result.text)

ツール名、説明、引数名をカスタマイズすることもできます。

weather_tool = weather_agent.as_tool(
    name="WeatherLookup",
    description="Look up weather information for any location",
    arg_name="query",
    arg_description="The weather query or location"
)

次のステップ