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
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, PartialEq, Eq)]
19#[serde(rename_all = "camelCase")]
20#[schemars(inline)]
21pub struct Plan {
22 /// The list of tasks to be accomplished.
23 ///
24 /// When updating a plan, the agent must send a complete list of all entries
25 /// with their current status. The client replaces the entire plan with each update.
26 pub entries: Vec<PlanEntry>,
27 /// Extension point for implementations
28 #[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
29 pub meta: Option<serde_json::Value>,
30}
31
32/// A single entry in the execution plan.
33///
34/// Represents a task or goal that the assistant intends to accomplish
35/// as part of fulfilling the user's request.
36/// See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries)
37#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
38#[serde(rename_all = "camelCase")]
39pub struct PlanEntry {
40 /// Human-readable description of what this task aims to accomplish.
41 pub content: String,
42 /// The relative importance of this task.
43 /// Used to indicate which tasks are most critical to the overall goal.
44 pub priority: PlanEntryPriority,
45 /// Current execution status of this task.
46 pub status: PlanEntryStatus,
47 /// Extension point for implementations
48 #[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
49 pub meta: Option<serde_json::Value>,
50}
51
52/// Priority levels for plan entries.
53///
54/// Used to indicate the relative importance or urgency of different
55/// tasks in the execution plan.
56/// See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries)
57#[derive(Deserialize, Serialize, JsonSchema, Debug, Clone, PartialEq, Eq)]
58#[serde(rename_all = "snake_case")]
59pub enum PlanEntryPriority {
60 /// High priority task - critical to the overall goal.
61 High,
62 /// Medium priority task - important but not critical.
63 Medium,
64 /// Low priority task - nice to have but not essential.
65 Low,
66}
67
68/// Status of a plan entry in the execution flow.
69///
70/// Tracks the lifecycle of each task from planning through completion.
71/// See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries)
72#[derive(Deserialize, Serialize, JsonSchema, Debug, Clone, PartialEq, Eq)]
73#[serde(rename_all = "snake_case")]
74pub enum PlanEntryStatus {
75 /// The task has not started yet.
76 Pending,
77 /// The task is currently being worked on.
78 InProgress,
79 /// The task has been successfully completed.
80 Completed,
81}