自分で予定を設定するエージェント向けのリマインダー ツール

Important

この記事で "(プレビュー)" と付記されている項目は、現在、パブリック プレビュー段階です。 このプレビューはサービス レベル アグリーメントなしで提供されており、運用環境ではお勧めしません。 特定の機能がサポートされていないか、機能が制限されている可能性があります。 詳細については、「 Microsoft Azure プレビューの追加使用条件」を参照してください。

reminder_preview ツールを使用すると、ホストされたエージェントは、将来の時点で再度実行されるように 自身 をスケジュールできます。 実行時間の長いタスクを確認したり、状態の更新をユーザーに求めたりするなど、エージェントが実行中に後でフォローアップする必要があると判断した場合に、このパターンを使用します。

エージェントがアラーム ツールを呼び出すと、遅延が分単位で指定されます。 その遅延の後、Foundry は同じ会話で同じエージェントを再度呼び出します。 エージェントは、その作業を続行したり、外部システムを確認したり、ユーザーにプロンプトを表示したりできます。

Important

アラーム ツールは、ホストされているエージェントでのみ使用できます。 プロンプト エージェントでアラーム ツールを使用することはできません。 アラーム ツールを使用するには、 reminder_preview ツールを含むツールボックスを作成し、ホストされているエージェントにツールボックスをアタッチします。

前提条件

アラーム ツールのしくみ

アラーム ツールは、次の引数を受け取ります。

引数 タイプ 範囲 Description
minutes 整数 1–43,200 エージェントを再呼び出す前に待機する時間 (分)。
input 文字列 アラームによって呼び出されたときにエージェントが実行する必要がある操作の手順。

エージェントは、ツールを呼び出すときに、その理由に基づいて遅延時間を決定します。 その後、Foundry は、指定された遅延の後に起動する スケジュールされたルーチン を作成し、同じ会話で同じホストされたエージェントを再呼び出します。 この方法では、新しい会話を開始する通常のルーチンとは異なり、呼び出し間でコンテキストが保持されます。

ツールボックスにアラーム ツールを追加する

アラーム ツールはコネクションレスです。 外部サービスまたは認証を構成する必要はありません。

Foundry ポータルのツールボックスのreminder_preview ツールを示すスクリーンショット。

  1. Foundry ポータルで、プロジェクトに移動します。
  2. 左側のウィンドウで、 ビルドとカスタマイズ>Toolboxes の順に選択します。
  3. [+ 新規] を選択してツールボックスを作成するか、編集する既存のツールボックスを選択します。
  4. ツールボックス エディターで、[ + ツールの追加] を選択します。
  5. [組み込みツール] で、[アラーム (プレビュー)] を選択します。
  6. ツールの名前と説明を構成し、[ 追加] を選択します。
  7. [ 保存] を 選択してツールボックスを保存します。

ツールボックスの詳細ページに MCP エンドポイントが表示されます。 このエンドポイントをコピーして、ホストされているエージェントに接続します。

from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient
from azure.ai.projects.models import ReminderPreviewToolboxTool

# Create Foundry project client
endpoint = "https://<your-foundry-account>.services.ai.azure.com/api/projects/<your-project>"
project = AIProjectClient(
    endpoint=endpoint,
    credential=DefaultAzureCredential(),
)

# Create toolbox version with reminder tool
toolbox_version = project.toolboxes.create_version(
    name="reminder-toolbox",
    description="Built-in reminder tool for a self-scheduling agent",
    tools=[
        ReminderPreviewToolboxTool(
            name="schedule_reminder",
            description="Schedule a reminder that re-invokes this agent at a future time.",
        ),
    ],
)
print(f"Created toolbox: {toolbox_version.name}, version: {toolbox_version.version}")
print(f"MCP endpoint: {toolbox_version.mcp_endpoint}")
using Azure.Identity;
using Azure.AI.Projects;

// Create Foundry project client
var projectEndpoint = "https://<your-foundry-account>.services.ai.azure.com/api/projects/<your-project>";
AIProjectClient projectClient = new(new Uri(projectEndpoint), new DefaultAzureCredential());

// Create toolbox version with reminder tool
var reminderTool = new ReminderPreviewToolboxTool
{
    Name = "schedule_reminder",
    Description = "Schedule a reminder that re-invokes this agent at a future time."
};

ToolboxVersionObject toolboxVersion = await projectClient.Toolboxes.CreateVersionAsync(
    name: "reminder-toolbox",
    tools: [reminderTool],
    description: "Built-in reminder tool for a self-scheduling agent"
);
Console.WriteLine($"Created toolbox: {toolboxVersion.Name}, version: {toolboxVersion.Version}");
Console.WriteLine($"MCP endpoint: {toolboxVersion.McpEndpoint}");
import { DefaultAzureCredential } from "@azure/identity";
import { AIProjectClient } from "@azure/ai-projects";

// Create Foundry project client
const projectEndpoint = "https://<your-foundry-account>.services.ai.azure.com/api/projects/<your-project>";
const project = new AIProjectClient(projectEndpoint, new DefaultAzureCredential());

const toolboxVersion = await project.toolboxes.createVersion(
  "reminder-toolbox",
  [
    {
      type: "reminder_preview",
      name: "schedule_reminder",
      description: "Schedule a reminder that re-invokes this agent at a future time.",
    },
  ],
  {
    description: "Built-in reminder tool for a self-scheduling agent",
  },
);
console.log(`Created toolbox: ${toolboxVersion.name}, version: ${toolboxVersion.version}`);
console.log(`MCP endpoint: ${toolboxVersion.mcpEndpoint}`);
POST https://{project_endpoint}/toolboxes/reminder-toolbox/versions?api-version=v1
Authorization: Bearer {token}
Content-Type: application/json

{
  "description": "Built-in reminder tool for a self-scheduling agent",
  "tools": [
    {
      "type": "reminder_preview",
      "name": "schedule_reminder",
      "description": "Schedule a reminder that re-invokes this agent at a future time."
    }
  ]
}

Note

ベアラー トークンを取得するときに、トークン スコープ https://ai.azure.com/.default を使用します。

応答には、 mcp_endpointが含まれます。 ホストされているエージェントをこのエンドポイントに接続します。

ツールボックス マニフェスト ファイルを作成します。

# reminder-toolbox.yaml
description: Built-in reminder tool for a self-scheduling agent
tools:
  - type: reminder_preview
    name: schedule_reminder
    description: Schedule a reminder that re-invokes this agent at a future time.

ツールボックスを作成します。

azd ai toolbox create reminder-toolbox --from-file reminder-toolbox.yaml

このコマンドは、ツールボックスの MCP エンドポイントを出力します。 ホストされているエージェントをこのエンドポイントに接続します。

ホストされるエージェントを構成する

ツールボックスを作成したら、それを使用するようにホストされているエージェントを構成します。 エージェント マニフェストで、 resourcesの下にツールボックス エンドポイントを追加します。

# agent.yaml
name: reminder-agent
model_deployment: gpt-4.1
instructions: |
  You are a helpful assistant. When the user asks you to follow up later,
  use the schedule_reminder tool to re-invoke yourself after the specified time.
resources:
  - kind: toolbox
    url: https://{project-endpoint}/agents/toolboxes/reminder-toolbox/mcp?version=1

シナリオ例: タスク完了のポーリング

一般的なシナリオは、タスクの完了のために外部システムをポーリングすることです。 このパターンでは、エージェントは次の操作を行います。

  1. 実行時間の長いタスクを開始するユーザー要求を受け取ります。
  2. 外部 API を呼び出してタスクを開始し、タスク ID を受け取ります。
  3. アラーム ツールを使用して、15 分でフォローアップをスケジュールします。
  4. アラームが発生すると、エージェントはタスクの状態を確認します。
  5. タスクがまだ実行されている場合、エージェントは別のアラームをスケジュールします。
  6. タスクが完了すると、エージェントはユーザーに通知します。

この動作を有効にするには、エージェント マニフェストに手順を含めます。

# agent.yaml
name: task-monitor
model_deployment: gpt-4.1
instructions: |
  You help users monitor long-running tasks.
  
  When a user asks you to start a task:
  1. Call the start_task tool with the user's parameters.
  2. Note the task_id in your response.
  3. Use the schedule_reminder tool to check back in 15 minutes.
  
  When you're re-invoked by a reminder:
  1. Call the check_status tool with the task_id.
  2. If the task is still running, schedule another reminder for 10 minutes.
  3. If the task is complete, summarize the results for the user.
resources:
  - kind: toolbox
    url: https://{project-endpoint}/agents/toolboxes/my-toolbox/mcp?version=1

モデルは、これらの手順に基づいて、アラーム ツールを使用するタイミングと方法を決定します。 アラーム呼び出しを処理するためにコードを記述する必要はありません。

Limitations

  • ホストされているエージェントのみ。 アラーム ツールは、ホストされているエージェントでのみ使用できます。 プロンプト エージェントでは使用できません。
  • 同じ会話。 アラームは、同じ会話でエージェントを再呼び出します。 新しい会話は開始されません。
  • 最小遅延。 最小遅延は 1 分です。
  • 最大遅延。 最大遅延時間は 43,200 分 (30 日) です。