Experimental TypeScript API for ACP v2, which is in Preview.
Remarks
ACP v2 is ready to build on, and it is not frozen. Its wire protocol and
this API may change incompatibly in any SDK release. The stable package
entry point remains ACP v1. The stable-feature set of v2 is available
through @agentclientprotocol/sdk/experimental/v2; additional unstable
protocol features require
@agentclientprotocol/sdk/experimental/v2/unstable.
Both entrypoints remain experimental.
Session state updates are aggregate snapshots, not per-prompt completions.
Apply repeated snapshots idempotently; a repeated idle stop reason is not a
new completion, cancellation, or usage report. Every successful
session/resume sends a current-state snapshot after replay and before its
response, including when replay was not requested. The response does not
imply idle. Agents may send live traffic after initialization even when no
client request is pending.
A session/resume with a replayFrom cursor replays history as
session/update notifications. The agent ends the replay with one
replay_complete update, after the last replayed update and before the
current-state snapshot and the response, also when the replay is empty.
From the time the agent receives the request until it sends
replay_complete, every update it sends for the session is replayed
history, and every update after it is not. Sending the request does not
mark the start of the replay: when the session is already active on the
connection, a live update that the agent sent before it received the
request can still arrive first. A replay that ends without
replay_complete and without a successful response is truncated. Agents
do not send it when replayFrom is omitted or null. Do not send a
second session/resume with a replayFrom cursor for a session while the
first one is pending.
A replay can include child sessions. Each child that it announces gets its
own replay_complete on its own sessionId, and the rule applies to each
session separately: a parent's replay_complete says nothing about its
children.
A session/resume without replayFrom synchronizes the session's state,
not its conversation. The agent sends the current state_update and a
current update for each terminal, tool call, and child session in its
background list. It does not send messages or foreground tool calls
again. Keep the entities you hold only when you missed no updates, and
request replay to have them resynchronized, for example after the
connection ended. You can rebuild the session's transcript from a full
replay. It carries the history the agent retained, which is not
necessarily everything you saw live, and it does not include past
usage_update, session_info_update, config_option_update, or
available_commands_update notifications. When the agent replays an
entity as chunks, it first sends that entity's update with the chunked
field emptied.
The session/new and session/resume responses carry the session's
configOptions and availableCommands. Each response replaces the lists
you hold, including lists from updates that arrived before it. An omitted
list means none. A new session is idle until a state_update reports
otherwise, and an agent whose new session is not idle sends that state
after the session/new response.
An agent announces a child session with subagent_update on its parent
and then sends the child's updates and requests with the child's
sessionId. A child is not an unknown session, although the client did
not create or resume it, and session/list does not return it. Send
nothing for a child except responses to its requests, session/cancel
while the child advertises capabilities.cancel, and tool_call/cancel
or terminal/cancel for an item that advertises its own. Agents answer
any other request that names a child with -32602. The capabilities
and state in a replayed subagent_update are historical. When you send
session/resume, discard the state and capabilities you hold for the
session's children and wait for current ones. A session's cost includes
the costs of its descendants. A child reports idle with
stopReason: "cancelled" also when its parent cancelled its work.
On session/cancel, the agent cancels each pending permission request and
elicitation that the cancelled work no longer needs with
$/cancel_request, and the agent decides which requests those are. A
client handler whose signal aborts should dismiss the prompt and return
the cancelled outcome or the cancel action. Clients do not answer every
pending permission request when they send session/cancel.
When session/cancel stops active foreground work, the agent sends that
work's final updates and then idle with stopReason: "cancelled",
before it starts new foreground work in the session. A prompt sent after
session/cancel is not rejected because the cancellation is in progress.
The agent inserts it, or holds it until the cancelled work reported
idle. Work in the latest background list keeps running, so keep
accepting tool call and terminal updates after that idle update. Stop a
listed tool call or terminal with tool_call/cancel or terminal/cancel
while it advertises capabilities.cancel.
A selected permission outcome is not approval by itself. The agent
matches its optionId against the options it offered in that request. A
reject_once or reject_always option, an optionId that was not
offered, an option kind or outcome the agent does not understand, an error
response, and a connection that ends before the answer all mean the
operation is not approved.
A plan_update replaces the whole plan with its planId, also when the
plan's type changed or is one you do not know. Plans are items or
markdown, and plan_removed removes one. No client capability is
needed. Ignore plan_removed for a planId you do not hold. Show a
markdown plan from its content, and do not read its path outside the
session's roots without user action.
When a response is lost, for example because the connection ended, the
request may still have taken effect. session/resume, session/list,
session/close, session/delete, session/set_config_option,
auth/login, auth/logout, tool_call/cancel, and terminal/cancel can
be sent again with the same parameters. Send session/set_config_option
again before you change that option further, because a late retry
overwrites the later change. A repeated session/new creates a second
session. A repeated session/prompt inserts a second user message unless
both attempts carry the same idempotencyKey and the agent still
recognizes it. A successful session/resume does not show which keys the
agent kept, so do not resend an unanswered prompt automatically when a
duplicate would matter. Tell the user that the prompt might already have
run and let them decide. Notifications are not sent again. A later copy of
session/cancel can cancel newer foreground work or a newly held prompt.
See
Retrying requests.
Top-level _meta on upsert updates, including usage_update, patches
stored metadata by key: omission leaves it unchanged, null clears it,
null-valued keys are removed, and other values replace their key whole
without nested merging. An empty object does nothing. Replay uses the same
rule. Metadata on chunks, content items, snapshots, and plan_update is
not an entity patch. status on compaction_update is a patch field too:
omitted leaves it unchanged, and null resets it to in_progress.
Experimental operations follow their advertised capabilities; local schema
selection does not establish peer support. Only send lifecycle
systemPrompt instructions when the agent advertises
session.systemPrompt, only use override when its mode.override
capability is advertised, and never send an empty content array.
Experimental TypeScript API for ACP v2, which is in Preview.
Remarks
ACP v2 is ready to build on, and it is not frozen. Its wire protocol and this API may change incompatibly in any SDK release. The stable package entry point remains ACP v1. The stable-feature set of v2 is available through
@agentclientprotocol/sdk/experimental/v2; additional unstable protocol features require@agentclientprotocol/sdk/experimental/v2/unstable. Both entrypoints remain experimental.Session state updates are aggregate snapshots, not per-prompt completions. Apply repeated snapshots idempotently; a repeated idle stop reason is not a new completion, cancellation, or usage report. Every successful
session/resumesends a current-state snapshot after replay and before its response, including when replay was not requested. The response does not imply idle. Agents may send live traffic after initialization even when no client request is pending.A
session/resumewith areplayFromcursor replays history assession/updatenotifications. The agent ends the replay with onereplay_completeupdate, after the last replayed update and before the current-state snapshot and the response, also when the replay is empty. From the time the agent receives the request until it sendsreplay_complete, every update it sends for the session is replayed history, and every update after it is not. Sending the request does not mark the start of the replay: when the session is already active on the connection, a live update that the agent sent before it received the request can still arrive first. A replay that ends withoutreplay_completeand without a successful response is truncated. Agents do not send it whenreplayFromis omitted ornull. Do not send a secondsession/resumewith areplayFromcursor for a session while the first one is pending. A replay can include child sessions. Each child that it announces gets its ownreplay_completeon its ownsessionId, and the rule applies to each session separately: a parent'sreplay_completesays nothing about its children.A
session/resumewithoutreplayFromsynchronizes the session's state, not its conversation. The agent sends the currentstate_updateand a current update for each terminal, tool call, and child session in itsbackgroundlist. It does not send messages or foreground tool calls again. Keep the entities you hold only when you missed no updates, and request replay to have them resynchronized, for example after the connection ended. You can rebuild the session's transcript from a full replay. It carries the history the agent retained, which is not necessarily everything you saw live, and it does not include pastusage_update,session_info_update,config_option_update, oravailable_commands_updatenotifications. When the agent replays an entity as chunks, it first sends that entity's update with the chunked field emptied.The
session/newandsession/resumeresponses carry the session'sconfigOptionsandavailableCommands. Each response replaces the lists you hold, including lists from updates that arrived before it. An omitted list means none. A new session isidleuntil astate_updatereports otherwise, and an agent whose new session is notidlesends that state after thesession/newresponse.An agent announces a child session with
subagent_updateon its parent and then sends the child's updates and requests with the child'ssessionId. A child is not an unknown session, although the client did not create or resume it, andsession/listdoes not return it. Send nothing for a child except responses to its requests,session/cancelwhile the child advertisescapabilities.cancel, andtool_call/cancelorterminal/cancelfor an item that advertises its own. Agents answer any other request that names a child with-32602. Thecapabilitiesandstatein a replayedsubagent_updateare historical. When you sendsession/resume, discard the state and capabilities you hold for the session's children and wait for current ones. A session'scostincludes the costs of its descendants. A child reportsidlewithstopReason: "cancelled"also when its parent cancelled its work.On
session/cancel, the agent cancels each pending permission request and elicitation that the cancelled work no longer needs with$/cancel_request, and the agent decides which requests those are. A client handler whosesignalaborts should dismiss the prompt and return thecancelledoutcome or thecancelaction. Clients do not answer every pending permission request when they sendsession/cancel.When
session/cancelstops active foreground work, the agent sends that work's final updates and thenidlewithstopReason: "cancelled", before it starts new foreground work in the session. A prompt sent aftersession/cancelis not rejected because the cancellation is in progress. The agent inserts it, or holds it until the cancelled work reportedidle. Work in the latestbackgroundlist keeps running, so keep accepting tool call and terminal updates after thatidleupdate. Stop a listed tool call or terminal withtool_call/cancelorterminal/cancelwhile it advertisescapabilities.cancel.A
selectedpermission outcome is not approval by itself. The agent matches itsoptionIdagainst the options it offered in that request. Areject_onceorreject_alwaysoption, anoptionIdthat was not offered, an option kind or outcome the agent does not understand, an error response, and a connection that ends before the answer all mean the operation is not approved.A
plan_updatereplaces the whole plan with itsplanId, also when the plan'stypechanged or is one you do not know. Plans areitemsormarkdown, andplan_removedremoves one. No client capability is needed. Ignoreplan_removedfor aplanIdyou do not hold. Show amarkdownplan from itscontent, and do not read itspathoutside the session's roots without user action.When a response is lost, for example because the connection ended, the request may still have taken effect.
session/resume,session/list,session/close,session/delete,session/set_config_option,auth/login,auth/logout,tool_call/cancel, andterminal/cancelcan be sent again with the same parameters. Sendsession/set_config_optionagain before you change that option further, because a late retry overwrites the later change. A repeatedsession/newcreates a second session. A repeatedsession/promptinserts a second user message unless both attempts carry the sameidempotencyKeyand the agent still recognizes it. A successfulsession/resumedoes not show which keys the agent kept, so do not resend an unanswered prompt automatically when a duplicate would matter. Tell the user that the prompt might already have run and let them decide. Notifications are not sent again. A later copy ofsession/cancelcan cancel newer foreground work or a newly held prompt. See Retrying requests.Top-level
_metaon upsert updates, includingusage_update, patches stored metadata by key: omission leaves it unchanged,nullclears it, null-valued keys are removed, and other values replace their key whole without nested merging. An empty object does nothing. Replay uses the same rule. Metadata on chunks, content items, snapshots, andplan_updateis not an entity patch.statusoncompaction_updateis a patch field too: omitted leaves it unchanged, andnullresets it toin_progress.Experimental operations follow their advertised capabilities; local schema selection does not establish peer support. Only send lifecycle
systemPromptinstructions when the agent advertisessession.systemPrompt, only useoverridewhen itsmode.overridecapability is advertised, and never send an emptycontentarray.