diff --git a/Cargo.toml b/Cargo.toml
index e797b2d..1d88ef2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,9 +14,10 @@ categories = ["development-tools", "api-bindings"]
include = ["/src/**/*.rs", "/README.md", "/LICENSE", "/Cargo.toml"]
[features]
-unstable = ["unstable_session_model", "unstable_session_list"]
+unstable = ["unstable_session_model", "unstable_session_list", "unstable_session_fork"]
unstable_session_model = []
unstable_session_list = []
+unstable_session_fork = []
[[bin]]
name = "generate"
diff --git a/docs/protocol/schema.unstable.mdx b/docs/protocol/schema.unstable.mdx
index 32fac7b..ce79a94 100644
--- a/docs/protocol/schema.unstable.mdx
+++ b/docs/protocol/schema.unstable.mdx
@@ -196,6 +196,88 @@ See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/exte
The ID of the session to cancel operations for.
+
+### session/fork
+
+**UNSTABLE**
+
+This capability is not part of the spec yet, and may be removed or changed at any point.
+
+Forks an existing session to create a new independent session.
+
+This method is only available if the agent advertises the `session.fork` capability.
+
+The agent should create a new session with the same conversation context as the
+original, allowing operations like generating summaries without affecting the
+original session's history.
+
+#### ForkSessionRequest
+
+**UNSTABLE**
+
+This capability is not part of the spec yet, and may be removed or changed at any point.
+
+Request parameters for forking an existing session.
+
+Creates a new session based on the context of an existing one, allowing
+operations like generating summaries without affecting the original session's history.
+
+Only available if the Agent supports the `session.fork` capability.
+
+**Type:** Object
+
+**Properties:**
+
+
+ The _meta property is reserved by ACP to allow clients and agents to attach additional
+metadata to their interactions. Implementations MUST NOT make assumptions about values at
+these keys.
+
+See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
+
+
+SessionId} required>
+ The ID of the session to fork.
+
+
+#### ForkSessionResponse
+
+**UNSTABLE**
+
+This capability is not part of the spec yet, and may be removed or changed at any point.
+
+Response from forking an existing session.
+
+**Type:** Object
+
+**Properties:**
+
+
+ The _meta property is reserved by ACP to allow clients and agents to attach additional
+metadata to their interactions. Implementations MUST NOT make assumptions about values at
+these keys.
+
+See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
+
+
+SessionModelState | null>} >
+ **UNSTABLE**
+
+This capability is not part of the spec yet, and may be removed or changed at any point.
+
+Initial model state if supported by the Agent
+
+
+SessionModeState | null>} >
+ Initial mode state if supported by the Agent
+
+See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)
+
+
+SessionId} required>
+ Unique identifier for the newly created forked session.
+
+
### session/list
@@ -2591,6 +2673,14 @@ these keys.
See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
+
+SessionForkCapabilities | null>} >
+ **UNSTABLE**
+
+This capability is not part of the spec yet, and may be removed or changed at any point.
+
+Whether the agent supports `session/fork`.
+
SessionListCapabilities | null>} >
**UNSTABLE**
@@ -2601,6 +2691,29 @@ Whether the agent supports `session/list`.
+## SessionForkCapabilities
+
+**UNSTABLE**
+
+This capability is not part of the spec yet, and may be removed or changed at any point.
+
+Capabilities for the `session/fork` method.
+
+By supplying `\{\}` it means that the agent supports forking of sessions.
+
+**Type:** Object
+
+**Properties:**
+
+
+ The _meta property is reserved by ACP to allow clients and agents to attach additional
+metadata to their interactions. Implementations MUST NOT make assumptions about values at
+these keys.
+
+See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
+
+
+
## SessionId
A unique identifier for a conversation session between a client and agent.
diff --git a/schema/meta.unstable.json b/schema/meta.unstable.json
index 7fad892..8d38112 100644
--- a/schema/meta.unstable.json
+++ b/schema/meta.unstable.json
@@ -3,6 +3,7 @@
"authenticate": "authenticate",
"initialize": "initialize",
"session_cancel": "session/cancel",
+ "session_fork": "session/fork",
"session_list": "session/list",
"session_load": "session/load",
"session_new": "session/new",
diff --git a/schema/schema.unstable.json b/schema/schema.unstable.json
index 7deb9b6..30b01be 100644
--- a/schema/schema.unstable.json
+++ b/schema/schema.unstable.json
@@ -208,6 +208,9 @@
{
"$ref": "#/$defs/ListSessionsResponse"
},
+ {
+ "$ref": "#/$defs/ForkSessionResponse"
+ },
{
"$ref": "#/$defs/SetSessionModeResponse"
},
@@ -573,6 +576,14 @@
],
"description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nLists existing sessions known to the agent.\n\nThis method is only available if the agent advertises the `listSessions` capability.\n\nThe agent should return metadata about sessions with optional filtering and pagination support."
},
+ {
+ "allOf": [
+ {
+ "$ref": "#/$defs/ForkSessionRequest"
+ }
+ ],
+ "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nForks an existing session to create a new independent session.\n\nThis method is only available if the agent advertises the `session.fork` capability.\n\nThe agent should create a new session with the same conversation context as the\noriginal, allowing operations like generating summaries without affecting the\noriginal session's history."
+ },
{
"allOf": [
{
@@ -1076,6 +1087,68 @@
},
"type": "object"
},
+ "ForkSessionRequest": {
+ "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nRequest parameters for forking an existing session.\n\nCreates a new session based on the context of an existing one, allowing\noperations like generating summaries without affecting the original session's history.\n\nOnly available if the Agent supports the `session.fork` capability.",
+ "properties": {
+ "_meta": {
+ "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)"
+ },
+ "sessionId": {
+ "allOf": [
+ {
+ "$ref": "#/$defs/SessionId"
+ }
+ ],
+ "description": "The ID of the session to fork."
+ }
+ },
+ "required": ["sessionId"],
+ "type": "object",
+ "x-method": "session/fork",
+ "x-side": "agent"
+ },
+ "ForkSessionResponse": {
+ "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nResponse from forking an existing session.",
+ "properties": {
+ "_meta": {
+ "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)"
+ },
+ "models": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SessionModelState"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nInitial model state if supported by the Agent"
+ },
+ "modes": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SessionModeState"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Initial mode state if supported by the Agent\n\nSee protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)"
+ },
+ "sessionId": {
+ "allOf": [
+ {
+ "$ref": "#/$defs/SessionId"
+ }
+ ],
+ "description": "Unique identifier for the newly created forked session."
+ }
+ },
+ "required": ["sessionId"],
+ "type": "object",
+ "x-method": "session/fork",
+ "x-side": "agent"
+ },
"HttpHeader": {
"description": "An HTTP header to set when making requests to the MCP server.",
"properties": {
@@ -2182,6 +2255,17 @@
"description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)",
"type": ["object", "null"]
},
+ "fork": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SessionForkCapabilities"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nWhether the agent supports `session/fork`."
+ },
"list": {
"anyOf": [
{
@@ -2196,6 +2280,15 @@
},
"type": "object"
},
+ "SessionForkCapabilities": {
+ "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nCapabilities for the `session/fork` method.\n\nBy supplying `{}` it means that the agent supports forking of sessions.",
+ "properties": {
+ "_meta": {
+ "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)"
+ }
+ },
+ "type": "object"
+ },
"SessionId": {
"description": "A unique identifier for a conversation session between a client and agent.\n\nSessions maintain their own context, conversation history, and state,\nallowing multiple independent interactions with the same agent.\n\nSee protocol docs: [Session ID](https://agentclientprotocol.com/protocol/session-setup#session-id)",
"type": "string"
diff --git a/src/agent.rs b/src/agent.rs
index dc04a0a..05a6aa7 100644
--- a/src/agent.rs
+++ b/src/agent.rs
@@ -601,6 +601,137 @@ impl LoadSessionResponse {
}
}
+// Fork session
+
+/// **UNSTABLE**
+///
+/// This capability is not part of the spec yet, and may be removed or changed at any point.
+///
+/// Request parameters for forking an existing session.
+///
+/// Creates a new session based on the context of an existing one, allowing
+/// operations like generating summaries without affecting the original session's history.
+///
+/// Only available if the Agent supports the `session.fork` capability.
+#[cfg(feature = "unstable_session_fork")]
+#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
+#[schemars(extend("x-side" = "agent", "x-method" = SESSION_FORK_METHOD_NAME))]
+#[serde(rename_all = "camelCase")]
+#[non_exhaustive]
+pub struct ForkSessionRequest {
+ /// The ID of the session to fork.
+ pub session_id: SessionId,
+ /// The _meta property is reserved by ACP to allow clients and agents to attach additional
+ /// metadata to their interactions. Implementations MUST NOT make assumptions about values at
+ /// these keys.
+ ///
+ /// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
+ #[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
+ pub meta: Option,
+}
+
+#[cfg(feature = "unstable_session_fork")]
+impl ForkSessionRequest {
+ pub fn new(session_id: impl Into) -> Self {
+ Self {
+ session_id: session_id.into(),
+ meta: None,
+ }
+ }
+
+ /// The _meta property is reserved by ACP to allow clients and agents to attach additional
+ /// metadata to their interactions. Implementations MUST NOT make assumptions about values at
+ /// these keys.
+ ///
+ /// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
+ #[must_use]
+ pub fn meta(mut self, meta: serde_json::Value) -> Self {
+ self.meta = Some(meta);
+ self
+ }
+}
+
+/// **UNSTABLE**
+///
+/// This capability is not part of the spec yet, and may be removed or changed at any point.
+///
+/// Response from forking an existing session.
+#[cfg(feature = "unstable_session_fork")]
+#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
+#[schemars(extend("x-side" = "agent", "x-method" = SESSION_FORK_METHOD_NAME))]
+#[serde(rename_all = "camelCase")]
+#[non_exhaustive]
+pub struct ForkSessionResponse {
+ /// Unique identifier for the newly created forked session.
+ pub session_id: SessionId,
+ /// Initial mode state if supported by the Agent
+ ///
+ /// See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub modes: Option,
+ /// **UNSTABLE**
+ ///
+ /// This capability is not part of the spec yet, and may be removed or changed at any point.
+ ///
+ /// Initial model state if supported by the Agent
+ #[cfg(feature = "unstable_session_model")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub models: Option,
+ /// The _meta property is reserved by ACP to allow clients and agents to attach additional
+ /// metadata to their interactions. Implementations MUST NOT make assumptions about values at
+ /// these keys.
+ ///
+ /// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
+ #[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
+ pub meta: Option,
+}
+
+#[cfg(feature = "unstable_session_fork")]
+impl ForkSessionResponse {
+ #[must_use]
+ pub fn new(session_id: impl Into) -> Self {
+ Self {
+ session_id: session_id.into(),
+ modes: None,
+ #[cfg(feature = "unstable_session_model")]
+ models: None,
+ meta: None,
+ }
+ }
+
+ /// Initial mode state if supported by the Agent
+ ///
+ /// See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)
+ #[must_use]
+ pub fn modes(mut self, modes: SessionModeState) -> Self {
+ self.modes = Some(modes);
+ self
+ }
+
+ /// **UNSTABLE**
+ ///
+ /// This capability is not part of the spec yet, and may be removed or changed at any point.
+ ///
+ /// Initial model state if supported by the Agent
+ #[cfg(feature = "unstable_session_model")]
+ #[must_use]
+ pub fn models(mut self, models: SessionModelState) -> Self {
+ self.models = Some(models);
+ self
+ }
+
+ /// The _meta property is reserved by ACP to allow clients and agents to attach additional
+ /// metadata to their interactions. Implementations MUST NOT make assumptions about values at
+ /// these keys.
+ ///
+ /// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
+ #[must_use]
+ pub fn meta(mut self, meta: serde_json::Value) -> Self {
+ self.meta = Some(meta);
+ self
+ }
+}
+
// List sessions
/// **UNSTABLE**
@@ -1639,6 +1770,14 @@ pub struct SessionCapabilities {
#[cfg(feature = "unstable_session_list")]
#[serde(skip_serializing_if = "Option::is_none")]
pub list: Option,
+ /// **UNSTABLE**
+ ///
+ /// This capability is not part of the spec yet, and may be removed or changed at any point.
+ ///
+ /// Whether the agent supports `session/fork`.
+ #[cfg(feature = "unstable_session_fork")]
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub fork: Option,
/// The _meta property is reserved by ACP to allow clients and agents to attach additional
/// metadata to their interactions. Implementations MUST NOT make assumptions about values at
/// these keys.
@@ -1662,6 +1801,14 @@ impl SessionCapabilities {
self
}
+ #[cfg(feature = "unstable_session_fork")]
+ /// Whether the agent supports `session/fork`.
+ #[must_use]
+ pub fn fork(mut self, fork: SessionForkCapabilities) -> Self {
+ self.fork = Some(fork);
+ self
+ }
+
/// The _meta property is reserved by ACP to allow clients and agents to attach additional
/// metadata to their interactions. Implementations MUST NOT make assumptions about values at
/// these keys.
@@ -1710,6 +1857,45 @@ impl SessionListCapabilities {
}
}
+/// **UNSTABLE**
+///
+/// This capability is not part of the spec yet, and may be removed or changed at any point.
+///
+/// Capabilities for the `session/fork` method.
+///
+/// By supplying `{}` it means that the agent supports forking of sessions.
+#[cfg(feature = "unstable_session_fork")]
+#[derive(Default, Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
+#[non_exhaustive]
+pub struct SessionForkCapabilities {
+ /// The _meta property is reserved by ACP to allow clients and agents to attach additional
+ /// metadata to their interactions. Implementations MUST NOT make assumptions about values at
+ /// these keys.
+ ///
+ /// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
+ #[serde(skip_serializing_if = "Option::is_none", rename = "_meta")]
+ pub meta: Option,
+}
+
+#[cfg(feature = "unstable_session_fork")]
+impl SessionForkCapabilities {
+ #[must_use]
+ pub fn new() -> Self {
+ Self::default()
+ }
+
+ /// The _meta property is reserved by ACP to allow clients and agents to attach additional
+ /// metadata to their interactions. Implementations MUST NOT make assumptions about values at
+ /// these keys.
+ ///
+ /// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
+ #[must_use]
+ pub fn meta(mut self, meta: serde_json::Value) -> Self {
+ self.meta = Some(meta);
+ self
+ }
+}
+
/// Prompt capabilities supported by the agent in `session/prompt` requests.
///
/// Baseline agent functionality requires support for [`ContentBlock::Text`]
@@ -1869,6 +2055,9 @@ pub struct AgentMethodNames {
/// Method for listing existing sessions.
#[cfg(feature = "unstable_session_list")]
pub session_list: &'static str,
+ /// Method for forking an existing session.
+ #[cfg(feature = "unstable_session_fork")]
+ pub session_fork: &'static str,
}
/// Constant containing all agent method names.
@@ -1884,6 +2073,8 @@ pub const AGENT_METHOD_NAMES: AgentMethodNames = AgentMethodNames {
session_set_model: SESSION_SET_MODEL_METHOD_NAME,
#[cfg(feature = "unstable_session_list")]
session_list: SESSION_LIST_METHOD_NAME,
+ #[cfg(feature = "unstable_session_fork")]
+ session_fork: SESSION_FORK_METHOD_NAME,
};
/// Method name for the initialize request.
@@ -1906,6 +2097,9 @@ pub(crate) const SESSION_SET_MODEL_METHOD_NAME: &str = "session/set_model";
/// Method name for listing existing sessions.
#[cfg(feature = "unstable_session_list")]
pub(crate) const SESSION_LIST_METHOD_NAME: &str = "session/list";
+/// Method name for forking an existing session.
+#[cfg(feature = "unstable_session_fork")]
+pub(crate) const SESSION_FORK_METHOD_NAME: &str = "session/fork";
/// All possible requests that a client can send to an agent.
///
@@ -1974,6 +2168,19 @@ pub enum ClientRequest {
///
/// The agent should return metadata about sessions with optional filtering and pagination support.
ListSessionsRequest(ListSessionsRequest),
+ #[cfg(feature = "unstable_session_fork")]
+ /// **UNSTABLE**
+ ///
+ /// This capability is not part of the spec yet, and may be removed or changed at any point.
+ ///
+ /// Forks an existing session to create a new independent session.
+ ///
+ /// This method is only available if the agent advertises the `session.fork` capability.
+ ///
+ /// The agent should create a new session with the same conversation context as the
+ /// original, allowing operations like generating summaries without affecting the
+ /// original session's history.
+ ForkSessionRequest(ForkSessionRequest),
/// Sets the current mode for a session.
///
/// Allows switching between different agent modes (e.g., "ask", "architect", "code")
@@ -2027,6 +2234,8 @@ impl ClientRequest {
Self::LoadSessionRequest(_) => AGENT_METHOD_NAMES.session_load,
#[cfg(feature = "unstable_session_list")]
Self::ListSessionsRequest(_) => AGENT_METHOD_NAMES.session_list,
+ #[cfg(feature = "unstable_session_fork")]
+ Self::ForkSessionRequest(_) => AGENT_METHOD_NAMES.session_fork,
Self::SetSessionModeRequest(_) => AGENT_METHOD_NAMES.session_set_mode,
Self::PromptRequest(_) => AGENT_METHOD_NAMES.session_prompt,
#[cfg(feature = "unstable_session_model")]
@@ -2053,6 +2262,8 @@ pub enum AgentResponse {
LoadSessionResponse(#[serde(default)] LoadSessionResponse),
#[cfg(feature = "unstable_session_list")]
ListSessionsResponse(ListSessionsResponse),
+ #[cfg(feature = "unstable_session_fork")]
+ ForkSessionResponse(ForkSessionResponse),
SetSessionModeResponse(#[serde(default)] SetSessionModeResponse),
PromptResponse(PromptResponse),
#[cfg(feature = "unstable_session_model")]
diff --git a/src/bin/generate.rs b/src/bin/generate.rs
index 49b45e0..adabaa8 100644
--- a/src/bin/generate.rs
+++ b/src/bin/generate.rs
@@ -816,6 +816,7 @@ and control access to resources."
"session/new" => self.agent_methods.get("NewSessionRequest").unwrap(),
"session/load" => self.agent_methods.get("LoadSessionRequest").unwrap(),
"session/list" => self.agent_methods.get("ListSessionsRequest").unwrap(),
+ "session/fork" => self.agent_methods.get("ForkSessionRequest").unwrap(),
"session/set_mode" => self.agent_methods.get("SetSessionModeRequest").unwrap(),
"session/prompt" => self.agent_methods.get("PromptRequest").unwrap(),
"session/cancel" => self.agent_methods.get("CancelNotification").unwrap(),
diff --git a/src/rpc.rs b/src/rpc.rs
index cb356e0..07ec773 100644
--- a/src/rpc.rs
+++ b/src/rpc.rs
@@ -283,6 +283,10 @@ impl Side for AgentSide {
m if m == AGENT_METHOD_NAMES.session_list => serde_json::from_str(params.get())
.map(ClientRequest::ListSessionsRequest)
.map_err(Into::into),
+ #[cfg(feature = "unstable_session_fork")]
+ m if m == AGENT_METHOD_NAMES.session_fork => serde_json::from_str(params.get())
+ .map(ClientRequest::ForkSessionRequest)
+ .map_err(Into::into),
m if m == AGENT_METHOD_NAMES.session_set_mode => serde_json::from_str(params.get())
.map(ClientRequest::SetSessionModeRequest)
.map_err(Into::into),