-32000 (Authentication required) until the Client completes the authentication flow.
Session lifecycle
A session exists fromsession/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/promptandsession/set_config_optionrequire an active session. Otherwise the Agent responds with-32002. See Unknown Sessions. Agents ignoresession/cancelfor 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/resumefor 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/resumereports current activity, not whether an unanswered prompt was inserted or itsidempotencyKeywas retained. Retrying with a forgotten key is a new submission. See Retrying a prompt.
Creating a session
Clients create a new session by calling thesession/new method with:
- The working directory for the session
- A list of MCP servers the Agent should connect to
Initial session state
New sessions default toidle 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 advertisecapabilities.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:
- The Session ID to resume
- MCP servers to connect to
- The working directory
- Optionally, a
replayFromcursor
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.
replayFrom to
{ "type": "start" }:
{ "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 terminaloutput 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_updatenotifications. See Current-State Synchronization. - Historical
usage_update,session_info_update,config_option_update, andavailable_commands_updatenotifications. 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.
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.
configOptions and availableCommands as
described in Initial Session State, whether or not
history replay was requested.
Replay complete
For eachsession/resume request with a replayFrom cursor, the Agent marks the end of the replay with a replay_complete update:
- The Agent MUST send
replay_completeexactly 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/updatethe Agent sends for that session after it receives the request. - The Agent MUST NOT send it when
replayFromis omitted ornull, or forsession/new. - The Agent MUST NOT send it when it cannot finish the replay.
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 ownreplay_complete on its own sessionId, and the rules above apply to each session separately:
- The Agent MUST send
replay_completeexactly once on each child session that it announces withsubagent_updatebetween 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_updateis an update for the parent session, so the parent’sreplay_completeseparates replayed associations from current ones. Thecapabilitiesandstatein a replayedsubagent_updateare historical. See Resuming. - The
replay_completeupdates of different sessions have no required order. A parent’sreplay_completesays nothing about its children. - The table above applies to each session, with that session’s
replay_completeand the response to the request.
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 currentstate_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 advertisecapabilities.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:
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:
-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 advertisesession.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.
additionalDirectories has the following behavior:
cwdremains the primary working directory and the base for relative paths- each
additionalDirectoriesentry 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 requestcwdmatches the session’scwd, and omitting the field or providing an empty array does not restore stored roots implicitly
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 advertisesession.systemPrompt allow Clients to include
system-level instructions on session/new and session/resume.
systemPrompt has the following behavior:
modeis required and selects how the Agent combinescontentwith its own instructionsmodevalues 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 asappendoroverrideappendaddscontentto 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 Agentoverridereplaces 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 asAGENTS.mdfiles or skill listings, MAY still be included, and Agents SHOULD document what they keep. Clients that useoverridetake responsibility for any tool guidance or safety instructions the Agent’s default instructions provided- only
textcontent 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
contentarray. Agents MAY reject one with-32602without creating or resuming the session - omitting the field or setting it to
nullonsession/newmeans the Agent uses its default instructions - on
session/resume, Clients SHOULD send the samesystemPromptthey 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)
systemPrompt when the Agent advertises session.systemPrompt, and MUST only use override mode when the Agent also advertises session.systemPrompt.mode.override:
Session ID
The session ID returned bysession/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
Thecwd (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
cwdwith-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
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 usingsession.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 atype 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 supportssession.mcp.stdio, Clients can specify MCP servers configurations using the stdio transport.
The path to the MCP server executable. It MUST be an absolute path. Agents
reject a request with a relative
command with -32602.Environment variables to set when launching the server. Omitted and empty
values are equivalent.
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 supportssession.mcp.http, Clients can specify MCP servers configurations using the HTTP transport.
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.Checking transport support
Before using stdio or HTTP transports, Clients MUST verify the Agent’s capabilities during initialization: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 theirenv and headers values are credentials.
- Agents SHOULD launch
commandwithargsas 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
envorheadersvalues in session updates, errors,_meta,session/listresults, replayed history, model context, or command lines, and SHOULD NOT log or persist them. - Agents SHOULD send
headersonly to the configured origin. - Clients that persist
mcpServersSHOULD keep credentials in operating-system secret storage and SHOULD NOT log them.