agent_client_protocol_schema/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
11use crate::{IntoOption, Meta};
12
13/// An execution plan for accomplishing complex tasks.
14///
15/// Plans consist of multiple entries representing individual tasks or goals.
16/// Agents report plans to clients to provide visibility into their execution strategy.
17/// Plans can evolve during execution as the agent discovers new requirements or completes tasks.
18///
19/// See protocol docs: [Agent Plan](https://agentclientprotocol.com/protocol/agent-plan)
20#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
21#[serde(rename_all = "camelCase")]
22#[non_exhaustive]
23pub struct Plan {
24 /// The list of tasks to be accomplished.
25 ///
26 /// When updating a plan, the agent must send a complete list of all entries
27 /// with their current status. The client replaces the entire plan with each update.
28 pub entries: Vec<PlanEntry>,
29 /// The _meta property is reserved by ACP to allow clients and agents to attach additional
30 /// metadata to their interactions. Implementations MUST NOT make assumptions about values at
31 /// these keys.
32 ///
33 /// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
34 #[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
35 pub meta: Option<Meta>,
36}
37
38impl Plan {
39 #[must_use]
40 pub fn new(entries: Vec<PlanEntry>) -> Self {
41 Self {
42 entries,
43 meta: None,
44 }
45 }
46
47 /// The _meta property is reserved by ACP to allow clients and agents to attach additional
48 /// metadata to their interactions. Implementations MUST NOT make assumptions about values at
49 /// these keys.
50 ///
51 /// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
52 #[must_use]
53 pub fn meta(mut self, meta: impl IntoOption<Meta>) -> Self {
54 self.meta = meta.into_option();
55 self
56 }
57}
58
59/// A single entry in the execution plan.
60///
61/// Represents a task or goal that the assistant intends to accomplish
62/// as part of fulfilling the user's request.
63/// See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries)
64#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
65#[serde(rename_all = "camelCase")]
66#[non_exhaustive]
67pub struct PlanEntry {
68 /// Human-readable description of what this task aims to accomplish.
69 pub content: String,
70 /// The relative importance of this task.
71 /// Used to indicate which tasks are most critical to the overall goal.
72 pub priority: PlanEntryPriority,
73 /// Current execution status of this task.
74 pub status: PlanEntryStatus,
75 /// The _meta property is reserved by ACP to allow clients and agents to attach additional
76 /// metadata to their interactions. Implementations MUST NOT make assumptions about values at
77 /// these keys.
78 ///
79 /// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
80 #[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
81 pub meta: Option<Meta>,
82}
83
84impl PlanEntry {
85 pub fn new(
86 content: impl Into<String>,
87 priority: PlanEntryPriority,
88 status: PlanEntryStatus,
89 ) -> Self {
90 Self {
91 content: content.into(),
92 priority,
93 status,
94 meta: None,
95 }
96 }
97
98 /// The _meta property is reserved by ACP to allow clients and agents to attach additional
99 /// metadata to their interactions. Implementations MUST NOT make assumptions about values at
100 /// these keys.
101 ///
102 /// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
103 #[must_use]
104 pub fn meta(mut self, meta: impl IntoOption<Meta>) -> Self {
105 self.meta = meta.into_option();
106 self
107 }
108}
109
110/// Priority levels for plan entries.
111///
112/// Used to indicate the relative importance or urgency of different
113/// tasks in the execution plan.
114/// See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries)
115#[derive(Deserialize, Serialize, JsonSchema, Debug, Clone, PartialEq, Eq)]
116#[serde(rename_all = "snake_case")]
117#[non_exhaustive]
118pub enum PlanEntryPriority {
119 /// High priority task - critical to the overall goal.
120 High,
121 /// Medium priority task - important but not critical.
122 Medium,
123 /// Low priority task - nice to have but not essential.
124 Low,
125}
126
127/// Status of a plan entry in the execution flow.
128///
129/// Tracks the lifecycle of each task from planning through completion.
130/// See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries)
131#[derive(Deserialize, Serialize, JsonSchema, Debug, Clone, PartialEq, Eq)]
132#[serde(rename_all = "snake_case")]
133#[non_exhaustive]
134pub enum PlanEntryStatus {
135 /// The task has not started yet.
136 Pending,
137 /// The task is currently being worked on.
138 InProgress,
139 /// The task has been successfully completed.
140 Completed,
141}