agent_client_protocol/plan.rs
1//! Execution plans for complex tasks that require multiple steps.
2//!
3//! Plans are strategies that agents share with clients through session updates,
4//! providing real-time visibility into their thinking and progress.
5//!
6//! See: [Agent Plan](https://agentclientprotocol.com/protocol/agent-plan)
7
8use schemars::JsonSchema;
9use serde::{Deserialize, Serialize};
10
11/// An execution plan for accomplishing complex tasks.
12///
13/// Plans consist of multiple entries representing individual tasks or goals.
14/// Agents report plans to clients to provide visibility into their execution strategy.
15/// Plans can evolve during execution as the agent discovers new requirements or completes tasks.
16///
17/// See protocol docs: [Agent Plan](https://agentclientprotocol.com/protocol/agent-plan)
18#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
19#[serde(rename_all = "camelCase")]
20pub struct Plan {
21 /// The list of tasks to be accomplished.
22 ///
23 /// When updating a plan, the agent must send a complete list of all entries
24 /// with their current status. The client replaces the entire plan with each update.
25 pub entries: Vec<PlanEntry>,
26 /// Extension point for implementations
27 #[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
28 pub meta: Option<serde_json::Value>,
29}
30
31/// A single entry in the execution plan.
32///
33/// Represents a task or goal that the assistant intends to accomplish
34/// as part of fulfilling the user's request.
35/// See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries)
36#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
37#[serde(rename_all = "camelCase")]
38pub struct PlanEntry {
39 /// Human-readable description of what this task aims to accomplish.
40 pub content: String,
41 /// The relative importance of this task.
42 /// Used to indicate which tasks are most critical to the overall goal.
43 pub priority: PlanEntryPriority,
44 /// Current execution status of this task.
45 pub status: PlanEntryStatus,
46 /// Extension point for implementations
47 #[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
48 pub meta: Option<serde_json::Value>,
49}
50
51/// Priority levels for plan entries.
52///
53/// Used to indicate the relative importance or urgency of different
54/// tasks in the execution plan.
55/// See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries)
56#[derive(Deserialize, Serialize, JsonSchema, Debug, Clone)]
57#[serde(rename_all = "snake_case")]
58pub enum PlanEntryPriority {
59 /// High priority task - critical to the overall goal.
60 High,
61 /// Medium priority task - important but not critical.
62 Medium,
63 /// Low priority task - nice to have but not essential.
64 Low,
65}
66
67/// Status of a plan entry in the execution flow.
68///
69/// Tracks the lifecycle of each task from planning through completion.
70/// See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries)
71#[derive(Deserialize, Serialize, JsonSchema, Debug, Clone)]
72#[serde(rename_all = "snake_case")]
73pub enum PlanEntryStatus {
74 /// The task has not started yet.
75 Pending,
76 /// The task is currently being worked on.
77 InProgress,
78 /// The task has been successfully completed.
79 Completed,
80}