Agent 计划
Agent 如何传达其执行计划
计划是需要多个步骤的复杂任务的执行策略。Agent 可以通过 session/update 通知与客户端共享计划,提供对其思考和进度的实时可见性。
创建计划
当语言模型创建执行计划时,Agent 应当向客户端报告它:
{
"jsonrpc": "2.0",
"method": "session/update",
"params": {
"sessionId": "sess_abc123def456",
"update": {
"sessionUpdate": "plan",
"entries": [
{
"content": "Analyze the existing codebase structure",
"priority": "high",
"status": "pending"
},
{
"content": "Identify components that need refactoring",
"priority": "high",
"status": "pending"
},
{
"content": "Create unit tests for critical functions",
"priority": "medium",
"status": "pending"
}
]
}
}
}
| 字段 | 类型 | 必需 | 描述 |
|---|---|---|---|
entries | PlanEntry[] | 是 | 代表要完成的任务的计划条目数组 |
计划条目
每个计划条目代表整体执行策略中的特定任务或目标:
| 字段 | 类型 | 必需 | 描述 |
|---|---|---|---|
content | string | 是 | 此任务旨在完成什么的人类可读描述 |
priority | PlanEntryPriority | 是 | 此任务的相对重要性。可选值:high、medium、low |
status | PlanEntryStatus | 是 | 此任务的当前执行状态。可选值:pending、in_progress、completed |
更新计划
随着 Agent 在计划中的进展,它应当通过发送更多具有相同结构的 session/update 通知来报告更新。Agent 必须在每次更新中发送所有计划条目的完整列表及其当前状态。客户端必须完全替换当前计划。
动态规划
计划可以在执行期间演变。Agent 可以在发现新需求或完成任务时添加、移除或修改计划条目,允许它根据所学的进行适应。