Important
本文中標示為預覽的項目目前仍在預覽中。 此預覽版未簽訂服務等級協議,Microsoft 不建議用於生產工作負載。 某些功能可能不被支援或功能受限。 欲了解更多資訊,請參閱 Microsoft Azure 預覽版補充使用條款。
reminder_preview此工具可讓代管代理程式安排自己於未來某個時間再次執行。 當代理在執行過程中決定需要稍後跟進時,例如回頭檢查長期執行的任務或提示使用者更新狀態時,請使用此模式。
當客服呼叫提醒工具時,會指定延遲時間為分鐘。 在那段延遲之後,Foundry 在同一段對話中再次召喚同一位代理人。 代理程式接著可以繼續工作、檢查外部系統,或提示使用者。
Important
提醒工具僅適用於託管代理。 您不能將提醒工具用於提示 Agent。 要使用提醒工具,請建立一個包含該 reminder_preview 工具的工具箱,然後將工具箱附加到託管代理人。
先決條件
- 具有已部署模型的 Foundry 專案。
- 裝載 Agent。 請參閱 建立您的第一個託管代理人。
- Azure Developer CLI (
azd) 安裝並認證。 請參閱安裝 Azure 開發者 CLI。
提醒工具的運作方式
提醒工具可採納以下參數:
| Argument | 類型 | 分布範圍 | Description |
|---|---|---|---|
minutes |
整數 | 1–43,200 | 在再次叫用代理程式之前要等待的分鐘數。 |
input |
字串 | — | 當提醒功能叫用 Agent 時,Agent 需要執行哪些動作的指示。 |
當客服呼叫工具時,它會根據推理決定延遲多久。 Foundry 接著建立一個 排程例程 ,在指定的延遲後觸發,並在同一對話中重新呼叫同一託管代理。 這種方法能保留呼喚間的脈絡,與一般啟動新對話的例行程序不同。
將提醒工具加入工具箱
提醒工具是無連線的。 你不需要設定任何外部服務或驗證。
- 在 Foundry 入口網站中,前往你的專案。
- 在左側窗格,選擇 「建置與自訂>工具箱」。
- 選擇 + 新檔 以建立工具箱,或選擇現有工具箱進行編輯。
- 在工具箱編輯器中,選擇 + 新增工具。
- 在內建工具中,選擇提醒(預覽)。
- 設定工具名稱和描述,然後選擇 新增。
- 選擇 儲存 以儲存工具箱。
工具箱細節頁面顯示 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
範例情境:工作完成度的輪詢
一個常見的情境是輪詢外部系統,以確認工作是否完成。 在此模式中,代理人:
- 接收使用者提出的請求,以啟動一項長期執行的任務。
- 呼叫外部 API 啟動任務並接收任務 ID。
- 使用提醒工具安排在 15 分鐘後進行後續追蹤。
- 提醒觸發時,代理會檢查任務狀態。
- 如果任務仍在執行中,客服會排程另一次提醒。
- 當任務完成時,代理會通知使用者。
要啟用此行為,請在您的代理清單中包含指示:
# 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
模型會根據這些指示決定何時以及如何使用提醒工具。 你不需要寫程式碼來處理提醒呼叫。
局限性
- 僅裝載 Agent。 提醒工具僅適用於託管代理。 你無法將它與提示代理搭配使用。
- 同樣的對話。 提醒會在同一個交談中重新叫用 Agent。 他們不會主動開啟新的對話。
- 最小延遲。 最短延遲時間為1分鐘。
- 最大延遲。 最大延遲時間為43,200分鐘(30天)。