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}
27
28/// A single entry in the execution plan.
29///
30/// Represents a task or goal that the assistant intends to accomplish
31/// as part of fulfilling the user's request.
32/// See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries)
33#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
34#[serde(rename_all = "camelCase")]
35pub struct PlanEntry {
36    /// Human-readable description of what this task aims to accomplish.
37    pub content: String,
38    /// The relative importance of this task.
39    /// Used to indicate which tasks are most critical to the overall goal.
40    pub priority: PlanEntryPriority,
41    /// Current execution status of this task.
42    pub status: PlanEntryStatus,
43}
44
45/// Priority levels for plan entries.
46///
47/// Used to indicate the relative importance or urgency of different
48/// tasks in the execution plan.
49/// See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries)
50#[derive(Deserialize, Serialize, JsonSchema, Debug, Clone)]
51#[serde(rename_all = "snake_case")]
52pub enum PlanEntryPriority {
53    /// High priority task - critical to the overall goal.
54    High,
55    /// Medium priority task - important but not critical.
56    Medium,
57    /// Low priority task - nice to have but not essential.
58    Low,
59}
60
61/// Status of a plan entry in the execution flow.
62///
63/// Tracks the lifecycle of each task from planning through completion.
64/// See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries)
65#[derive(Deserialize, Serialize, JsonSchema, Debug, Clone)]
66#[serde(rename_all = "snake_case")]
67pub enum PlanEntryStatus {
68    /// The task has not started yet.
69    Pending,
70    /// The task is currently being worked on.
71    InProgress,
72    /// The task has been successfully completed.
73    Completed,
74}