Skip to main content
Sessions represent a specific conversation or thread between the Client and Agent. Each session has its own context, conversation history, and state, so one Agent can run several independent sessions. Before creating a session, Clients MUST first complete the initialization phase to establish protocol compatibility and capabilities. If the Agent requires authentication, session methods may fail with -32000 (Authentication required) until the Client completes the authentication flow.

Session lifecycle

A session exists from session/new until the Agent discards it. Agents choose how long to keep sessions: for example, they can skip storing a session that was never prompted, expire old sessions, or remove one through session/delete. session/list and session/resume only see sessions the Agent still has, and resuming one it no longer has fails with -32002. On a connection, a session is active from a successful session/new or session/resume until session/close or the end of the connection. Agents SHOULD NOT discard a session while it is active, except through session/delete, which closes it first.
  • Session-scoped requests such as session/prompt and session/set_config_option require an active session. Otherwise the Agent responds with -32002. See Unknown Sessions. Agents ignore session/cancel for a session that isn’t active.
  • A child session is not active in this sense. The Client does not create, resume, or close it. The Agent announces it with subagent_update, and the Client can then name it only in the requests that Restricted methods allows, until the child’s root session stops being active.
  • Closing a session ends it on the connection but doesn’t discard it. Whether a closed session stays listed and resumable depends on how long the Agent keeps it.
  • Resuming a session that is already active on the connection synchronizes it again, like any resume. Ongoing work continues, and the request’s MCP servers and workspace roots replace the previous ones.
  • Whether a session can be active on more than one connection at once is up to the Agent. An Agent that doesn’t allow it MAY reject a session/resume for a session active on another connection, or end the session’s activity on that other connection as if it were closed, for example when a Client reconnects before the Agent notices the old connection is gone.
  • When the connection ends, its sessions stop being active. The Agent MAY continue or cancel their foreground work, and it MAY insert or discard the prompts it was holding. A later session/resume reports current activity, not whether an unanswered prompt was inserted or its idempotencyKey was retained. Retrying with a forgotten key is a new submission. See Retrying a prompt.

Creating a session

Clients create a new session by calling the session/new method with:
The Agent MUST respond with a unique Session ID that identifies this conversation:

Initial session state

New sessions default to idle until a state_update reports otherwise. Updates may arrive before or after the session/new response. Clients MUST NOT overwrite an already-reported state when the response arrives. An optional initial idle notification is a snapshot, not completed work. Agents SHOULD put initial state in the session/new response rather than sending notifications before it. For configOptions and availableCommands, the response is required, as described below. Agents SHOULD NOT send session-scoped requests, such as permission requests or elicitations, before the response, because the Client cannot yet show them for that session. While a session/new is pending, Clients MAY buffer notifications for a sessionId they don’t recognize and apply them in order once the response arrives, or drop them. Agents cannot rely on such notifications being seen. An Agent whose new session is not idle, for example because it started work when the session was created, MUST send the session’s state_update after the response. session/resume does not imply idle: an existing session may still be running or waiting for user action. See Current-State Synchronization. The session/new and session/resume responses carry the session’s configuration options in configOptions and available slash commands in availableCommands. Because a setup response replaces the lists the Client holds, an Agent whose session has configuration options or commands MUST include them in that response. For example, a new session can return both:
configOptions and availableCommands are optional. Each is the complete current list for the session: omission or [] means none. Agents MUST NOT send null for these fields. When a session/new or session/resume response arrives, Clients replace the lists they hold for the session with the response’s lists, including lists from updates received before the response. Later config_option_update and available_commands_update notifications each replace the complete list, including [] to clear it.

Resuming sessions

Agents that advertise capabilities.session MUST support session/resume, which Clients use to reconnect to existing sessions. By default, resume restores the session context without replaying prior conversation history. Clients that need history replay can request it with replayFrom. To resume an existing session, Clients MUST call the session/resume method with:
When replayFrom is omitted or null, the Agent MUST NOT replay the conversation history via session/update notifications before responding. It restores the session context, reconnects to the requested MCP servers, and returns once the session is active and its current foreground state has been synchronized. The required current-state snapshot is live synchronization, not history replay. Updates that report in-progress work, such as the content of a message that is still streaming, are live updates, not history replay. A resume without replay synchronizes the session’s state, not its conversation. The Agent sends the current state_update. The background list on that update names terminals, tool calls, and child sessions by ID, and the Agent announces an item before it lists it. So it first sends a current terminal_update, tool_call_update, or subagent_update for each listed item. Current-state synchronization defines both rules. The snapshot names no foreground work, and the Agent is not required to send anything about it: a message that is still streaming, or a foreground tool call that is still running, continues with its next live update.
  • A Client that still holds the session’s entities and has missed no updates can keep them.
  • A Client that wants them resynchronized, for example after the connection ended, requests replay with replayFrom.
To request full history replay, Clients set replayFrom to { "type": "start" }:
Replay cursors are inclusive: replay includes the position identified by the cursor. For { "type": "start" }, that means replaying all retained conversation history. When replayFrom.type is "start", the Agent MUST replay all retained conversation history to the Client in the form of session/update notifications before responding. It marks the end of the replay with replay_complete. The schema accepts custom and future replayFrom.type values so intermediaries can preserve them. An Agent that does not support the supplied cursor type MUST reject session/resume with -32602 (Invalid params). It MUST NOT silently substitute another cursor or resume without replay. Malformed replayFrom values also result in -32602.

Replay contents

Replay reports retained history with the same updates and semantics as live delivery: messages, tool calls, display terminals, plans, and compactions. The Agent can replay each entity’s updates or only its current state, for example a whole message instead of its chunks, or a terminal output snapshot instead of every output chunk. A replayed tool call whose work is no longer running or waiting SHOULD have a final status (completed, failed, or cancelled). Work that is still running after resuming keeps its live status and continues with live updates. Replay does not include:
  • Historical state_update notifications. See Current-State Synchronization.
  • Historical usage_update, session_info_update, config_option_update, and available_commands_update notifications. They describe past values and SHOULD NOT be replayed. See Current-State Synchronization.
  • Notices, which are live-only and SHOULD NOT be replayed. If the condition is still relevant after resuming, the Agent MAY send a new notice.
  • Pending permission requests and elicitations. See Current-State Synchronization.
Agents are not required to persist every inserted user message or retain it for any minimum period. Live-only messages, including locally handled commands, may be absent from replay. A successful prompt response confirms insertion, not future availability in history. Absence from replay does not contradict it. For example, a user message from the conversation history:
Followed by the Agent’s response:
During replay, the Agent MUST include an opaque messageId for each replayed message, unique among messages of the same type. A retained user message inserted by session/prompt MUST use the ID returned in that prompt response, including after reconnecting or restarting the Agent. Replaying a command reports its message. It does not execute the command again. Agents SHOULD preserve the IDs of all other replayed entities, such as Agent and thought message IDs, toolCallId, terminalId, planId, and compactionId, across replay when possible, but these IDs are not guaranteed to remain stable across reconnects or Agent restarts. Clients MUST NOT rely on them to deduplicate replay against previously received history. A Client attaching to a session can rebuild its transcript from a full replay. It contains the history the Agent retained, not necessarily everything the Client saw live. user_message, agent_message, agent_thought, and session_message updates are upserts keyed by messageId. Their content arrays replace the whole message content, while chunk updates with the same messageId append content. When replay reconstructs an entity from its beginning using chunks, the Agent MUST first send that entity’s update with the same ID and the chunked field emptied: This initializes or clears content under the ID used for that replay before replayed chunks append. It does not reconcile an entity previously delivered under a different ID. An update that carries the whole content can instead replace it under the replayed ID directly. The rule does not apply to an entity that the Agent replays without chunks. Clients apply replayed message updates and chunks in the order they are received. If a message update with content arrives after chunks for the same messageId, it replaces the content accumulated from those chunks. If chunks arrive after a message update, they append to that update’s current content. Message updates that omit content can update other optional fields without changing the current content. Tool calls, terminals, and compactions follow the same order for content, output, and summary. Replay also applies top-level _meta as a metadata patch and does not reset it. A message update that replaces content leaves _meta keys it does not mention. When the Client may already hold metadata for an entity, the Agent removes stale keys by setting them to null, or sends _meta: null before the current object. When all requested replay entries have been reported to the Client, the Agent MUST send replay_complete, synchronize current state as described below, then respond to the original session/resume request.
The response also includes the current configOptions and availableCommands as described in Initial Session State, whether or not history replay was requested.

Replay complete

For each session/resume request with a replayFrom cursor, the Agent marks the end of the replay with a replay_complete update:
The update has no required fields.
  • The Agent MUST send replay_complete exactly once on the session named in the request, after the last replayed update and before the response.
  • The Agent MUST send it for an empty replay too. It is then the first session/update the Agent sends for that session after it receives the request.
  • The Agent MUST NOT send it when replayFrom is omitted or null, or for session/new.
  • The Agent MUST NOT send it when it cannot finish the replay.
From the time the Agent receives the replay request until it sends replay_complete, each session/update it sends for that session MUST be replayed history. The Agent holds every other update for the session and sends it after replay_complete. Examples are the chunks of a message that is still streaming, notice, available_commands_update, config_option_update, and the updates of current-state synchronization. Sending session/resume does not mark the start of replay for the Client. If that session is already active on the connection, a live user_message the Agent sent before it received the request can arrive after the Client sent it. The Client can therefore receive that message just before replay_complete even if the replay was empty. Foreground work that is still running during a resume is split at a cut point. The updates up to the cut are history and come before replay_complete. The rest comes after it. Chunks are keyed by messageId, so the later chunks append to the replayed message. Agent requests such as session/request_permission and elicitation/create are not history, so they SHOULD also wait until after replay_complete. This includes a pending request that the Agent reestablishes after a connection loss. A Client applies the toolCall of a permission request’s tool_call subject like a tool_call_update, so replayed updates that arrive after the request could overwrite that newer state. replay_complete does not make the session active. A session that was not active before the request becomes active with the successful response, so session/prompt fails with -32002 until then. replay_complete means that the Agent sent every update it selected for the replay. It does not mean that the Agent retained all history. Agents SHOULD report known gaps after replay_complete, for example with a notice. Together with the response, replay_complete tells the Client whether the replay was complete: A session/resume that is cancelled with $/cancel_request still gets a response. A -32800 response is an error response in this table. An Agent that rejects the replayFrom cursor with -32602 replays nothing and does not send replay_complete. Clients SHOULD NOT send a second session/resume with a replayFrom cursor for a session while the first one is pending.

Child sessions

A resume with replay can also replay the history of child sessions, at any depth. Each session has its own replay_complete on its own sessionId, and the rules above apply to each session separately:
  • The Agent MUST send replay_complete exactly once on each child session that it announces with subagent_update between the request and the response. It sends it after the announcement and after the last replayed update for that child. An announced child with no replayed history gets one too, like the session named in the request. A child that the Agent does not announce gets none.
  • After receiving the resume request, the Agent holds live updates and requests for each announced child until that child’s replay_complete. They do not wait for the replay of any other session.
  • A subagent_update is an update for the parent session, so the parent’s replay_complete separates replayed associations from current ones. The capabilities and state in a replayed subagent_update are historical. See Resuming.
  • The replay_complete updates of different sessions have no required order. A parent’s replay_complete says nothing about its children.
  • The table above applies to each session, with that session’s replay_complete and the response to the request.
Each marker covers only its own session. The successful session/resume response confirms that the Agent finished the replay for the requested session and all the children it included.

Current-state synchronization

For every successful resume, the Agent MUST send a current state_update after any requested history replay and before the resume response. This is required even when replayFrom is omitted or null. The snapshot reports the current foreground state after resuming: idle, running, or requires_action, or the unknown state when activity is unobservable. The snapshot carries the background list like any other. Before it, the Agent MUST send a current update for each listed item that the requested replay did not already deliver at its current state: a terminal_update for each terminal, a tool_call_update for each tool call, and a subagent_update for each child. When no replay was requested, this means all of them. It does not include foreground work in progress, which a resume without replay does not resynchronize. A replayed subagent_update never delivers a child’s current capabilities or state, so after a replay the Agent sends one for each listed child after the parent’s replay_complete. See Resuming. Agents MUST NOT replay historical state_update notifications as current activity. The snapshot and subsequent live state changes MUST be delivered in order, without replacing a newer state with a stale snapshot. An idle snapshot may include the last stop reason for context, but does not report a new completion or cancellation. Clients MUST NOT reset the state to idle on the resume response. If connection loss made a pending permission request or elicitation unusable, the Agent SHOULD reestablish it or safely resolve the wait. Agents SHOULD also send current session info through session_info_update after any requested history replay and before responding, even when replayFrom is omitted or null. This synchronizes current state rather than replaying historical configuration or metadata changes. Agents that report usage MAY likewise send a current usage_update after any requested history replay and before responding.

Closing active sessions

Agents that advertise capabilities.session MUST support session/close, which tells the Agent to cancel any ongoing work for a session and free any resources associated with that active session. To close an active session, Clients MUST call the session/close method with the session ID:
SessionId
required
The ID of the active session to close.
The Agent MUST cancel any ongoing work for that session as if session/cancel had been called, then free the resources associated with the session. Before responding to session/close, the Agent MUST cancel every pending permission request and elicitation scoped to that session with $/cancel_request. Clients SHOULD dismiss permission and elicitation prompts for a closed session. Unlike cancellation, closing also stops the session’s background work, including everything in the latest background list. After a successful close, the Client SHOULD treat every listed tool call, and every tool call that references a listed terminal, that has not reported a final status as cancelled, and every listed terminal without exitStatus as exited with no known exit status. The Agent MAY send final updates for listed work before responding, but does not have to. Closing also stops the session’s child sessions, at any depth. When closing cancels active foreground work, the Agent MUST send the final updates for that work and the idle state_update with stopReason: "cancelled" before responding successfully to session/close. Closing an idle session does not itself require another idle update. Closing also cancels pending session/prompt requests whose messages have not been inserted, including held prompts. If closing prevents a prompt’s user message from being inserted, the Agent MUST answer that request with -32800 (Request cancelled). If the message has already been inserted, the Agent MUST respond successfully with its messageId, as described in Prompt Accepted. Prompt responses need not precede the close response. After the close response, the Agent sends no notifications or requests for the session on that connection. It still answers session/prompt requests that were pending. On success, the Agent responds with an empty result object:
Closing is idempotent. If the session does not exist or is not active, for example because it was already closed, the Agent SHOULD respond with the same empty result. Clients SHOULD treat a -32002 response to session/close as a successful close. See Unknown Sessions. A child session is the exception. Agents SHOULD reject a session/close that names one with -32602.

Additional workspace roots

Agents that advertise session.additionalDirectories allow Clients to include additionalDirectories on supported session lifecycle requests to expand the session’s effective workspace root set. The supported stable requests are session/new and session/resume.
When present, additionalDirectories has the following behavior:
  • cwd remains the primary working directory and the base for relative paths
  • each additionalDirectories entry MUST be an absolute path
  • omitting the field or providing an empty array activates no additional roots for the resulting session
  • on session/resume, Clients MUST send the full intended additional-root list again. That list MAY differ from any previous or reported list as long as the request cwd matches the session’s cwd, and omitting the field or providing an empty array does not restore stored roots implicitly
Clients MUST only send additionalDirectories when the Agent advertises session.additionalDirectories. Agents that advertise the capability MUST reject a request with -32602 if any entry is not an absolute path, and MAY reject entries that don’t exist or aren’t directories. Agents MAY ignore duplicate entries and entries equal to cwd, so the list reported in SessionInfo can differ from the request. Agents that don’t advertise the capability ignore the field.

System prompt

Agents that advertise session.systemPrompt allow Clients to include system-level instructions on session/new and session/resume.
systemPrompt has the following behavior:
  • mode is required and selects how the Agent combines content with its own instructions
  • mode values beginning with _ are reserved for implementation-specific modes, and other unknown values for future ACP modes. Clients MUST only use a mode the Agent advertised. An Agent that receives a mode it does not support MUST return an error rather than treating it as append or override
  • append adds content to the Agent’s own instructions rather than replacing them. The Agent SHOULD give it system-level precedence, for example in the model’s system prompt or developer instructions rather than in user-turn content. Where it is placed and how it is formatted is up to the Agent
  • override replaces the Agent’s built-in default instructions. It does not change tool availability, MCP servers, permissions, or session configuration. Context the Agent supplies from the workspace or environment, such as AGENTS.md files or skill listings, MAY still be included, and Agents SHOULD document what they keep. Clients that use override take responsibility for any tool guidance or safety instructions the Agent’s default instructions provided
  • only text content blocks are supported for now: Agents MUST accept them, and Clients MUST NOT send other content block types until a future capability allows them. Agents MUST return an error for content blocks they do not support, including unknown types
  • Clients MUST NOT send an empty content array. Agents MAY reject one with -32602 without creating or resuming the session
  • omitting the field or setting it to null on session/new means the Agent uses its default instructions
  • on session/resume, Clients SHOULD send the same systemPrompt they used when the session was created. When it is omitted, the Agent MAY keep a prompt it stored with the session or use its default. When it differs, the Agent SHOULD apply it, and MAY defer the change until it next rebuilds its prompt (for example, after compaction) when applying it immediately would discard prompt caches or preserved reasoning
  • if the Agent cannot apply a supplied systemPrompt, it MUST return an error and MUST NOT create or resume the session. When the cause is the value itself, such as an unadvertised mode, an unsupported content block type, or content that exceeds its limits, the error MUST be -32602 (Invalid params)
Clients MUST only send systemPrompt when the Agent advertises session.systemPrompt, and MUST only use override mode when the Agent also advertises session.systemPrompt.mode.override:
Content delivered at system level carries more weight with the model than user turns or tool output. Clients SHOULD only send content they trust at that level.

Session ID

The session ID returned by session/new is a unique identifier for the conversation context. Clients use this ID to:
  • Send prompt requests via session/prompt
  • Cancel foreground work via session/cancel
  • Resume previous sessions via session/resume
  • Close active sessions via session/close

Working directory

The cwd (current working directory) parameter establishes the primary file system context for the session. This directory:
  • MUST be an absolute path. Agents reject a request with a relative cwd with -32602.
  • MUST be used for the session regardless of where the Agent subprocess was spawned
  • MUST remain the base for relative-path resolution
  • MUST be part of the session’s effective root set
On session/resume, Clients MUST send the session’s working directory. Agents MAY reject a different directory with -32602. Agents MAY normalize paths when comparing, for example ignoring a trailing separator. When session.additionalDirectories is in use, the session’s effective root set is [cwd, ...additionalDirectories]. This root set SHOULD serve as a boundary for tool operations on the file system.

Workspace root security

The root set declares the session’s scope. It confines shell commands only when a sandbox enforces it.
  • Clients SHOULD only include directories the user expects the Agent to access, such as the workspace or directories the Client provides, like skills.
  • Agents SHOULD NOT treat model output, Agent content, or replayed history as granting access outside the root set. Access outside it goes through a permission request.
  • Implementations that enforce the root set SHOULD check the resolved path at the time of use, compare paths by component, and fail closed.

MCP servers

The Model Context Protocol (MCP) allows Agents to access external tools and data sources. When creating a session, Clients MAY include connection details for MCP servers that the Agent should connect to. MCP servers can be connected to using different transports. Agents advertise supported transports during initialization using session.mcp.stdio, session.mcp.http, and any extension-specific transport capabilities. Agents MUST reject a request with a transport they don’t support with -32602, including a transport they did not advertise and sse, which this protocol version does not define. Each server name MUST be unique within mcpServers. Agents reject duplicates with -32602. On session/resume, mcpServers is the complete set of Client-provided servers for the session. Omitted and [] mean none. Agents SHOULD NOT restore servers from earlier session/new or session/resume requests. MCP servers the Agent is configured with independently of ACP are unaffected.

Transport types

Every MCP server object has a type discriminator that identifies its transport. Custom implementation-specific transport types MUST begin with _. Unknown non-underscore transport types are reserved for future ACP variants.

Stdio transport

When the Agent supports session.mcp.stdio, Clients can specify MCP servers configurations using the stdio transport.
string
required
Must be "stdio" to indicate stdio transport
string
required
A human-readable identifier for the server
string
required
The path to the MCP server executable. It MUST be an absolute path. Agents reject a request with a relative command with -32602.
string[]
Command-line arguments to pass to the server. Omitted and empty values are equivalent.
EnvVariable[]
Environment variables to set when launching the server. Omitted and empty values are equivalent.
Example stdio transport configuration:
Agents SHOULD launch stdio servers with the session’s cwd as the working directory. env entries are added to the environment the Agent would otherwise give the process, replacing variables with the same name. Each env entry SHOULD have a unique name. Agents MAY reject duplicates with -32602. Otherwise the last entry with a given name wins.

HTTP transport

When the Agent supports session.mcp.http, Clients can specify MCP servers configurations using the HTTP transport.
string
required
Must be "http" to indicate HTTP transport
string
required
A human-readable identifier for the server
string
required
The URL of the MCP server
HttpHeader[]
HTTP headers to include in requests to the server. Omitted and empty values are equivalent. Headers that the MCP transport itself defines, such as Accept and MCP-Protocol-Version, are owned by the transport: Agents use the transport’s values for them.
Example HTTP transport configuration:

Checking transport support

Before using stdio or HTTP transports, Clients MUST verify the Agent’s capabilities during initialization:
If session.mcp.stdio is omitted or null, the Agent does not support stdio transport. If session.mcp.http is omitted or null, the Agent does not support HTTP transport. Supplying {} means the Agent supports the corresponding transport. Agents SHOULD connect to all MCP servers specified by the Client. If a server fails to launch or connect, the Agent SHOULD continue without that server and tell the user, for example with a notice. Clients MAY use this ability to provide tools directly to the underlying language model by including their own MCP server.

Security

MCP server configurations can launch processes, and their env and headers values are credentials.
  • Agents SHOULD launch command with args as separate arguments, without a shell.
  • Clients SHOULD NOT send a stdio server from workspace files or Agent output until the user has approved its exact command, arguments, and environment variable names.
  • Agents SHOULD NOT include env or headers values in session updates, errors, _meta, session/list results, replayed history, model context, or command lines, and SHOULD NOT log or persist them.
  • Agents SHOULD send headers only to the configured origin.
  • Clients that persist mcpServers SHOULD keep credentials in operating-system secret storage and SHOULD NOT log them.