ExperimentalExperimental
Session ID returned by session/new.
Experimental
Current configuration options for this session, if the agent provided any.
Starts with the configOptions from session/new. It is replaced with the
full list from each config_option_update routed to this session (applied
when the notification arrives, before it is read with nextUpdate()) and
from each setConfigOption(...) response. Updates stop after dispose().
newSessionResponse.configOptions keeps the original session/new value.
Experimental
Metadata returned when the session was created.
Experimental
The background list from the latest state_update routed to this
session, or undefined while background work is not reported.
Each state_update replaces it, applied when the notification arrives,
before it is read with nextUpdate(). [] means no background work is
running. A snapshot that omits the list, carries null or a malformed
list, or reports a state this SDK does not know resets it to undefined:
background work is unknown until a list arrives, and nothing should be
treated as abandoned. Updates stop after dispose().
Experimental
Whether request is for work in the latest background list of this
session. For a request of this session, that is a listed tool call (by
the subject's toolCall.toolCallId, or a command subject's toolCallId)
or a listed terminal (by a command subject's terminalId). A request of
another session is for listed work when that session is a listed
subagent: tool call and terminal IDs are scoped to the session that
reports them, so its subject is not compared with this session's items.
session/cancel does not cover listed work, so permission requests for
it stay open. For the cancelled foreground work, the Agent stops waiting
on its permission requests and cancels them with $/cancel_request, and
the Client dismisses each cancelled request and answers it with the
cancelled outcome. A Client may also answer a request with cancelled
right after sending session/cancel, without waiting for
$/cancel_request, but only when it knows the request belongs to the
cancelled work. A false result alone does not establish that: it is
also returned for requests without a subject, custom subjects, a
request of a child session that is not listed, such as a listed child's
own child, and any request while background is not reported. On
session/close, the Agent
cancels every pending permission request in the session with
$/cancel_request. When an Agent sends a permission request with
cancellationSignal and stopWaitingOnCancel: true, aborting the signal
sends $/cancel_request and stops waiting for the answer.
Experimental
Whether the tool call currently advertises capabilities.cancel, from
the tool_call_update patches routed to this session.
Experimental
Whether the terminal currently advertises capabilities.cancel, from the
terminal_update patches routed to this session.
Experimental
Cancels one tool call with tool_call/cancel.
Rejects with a TypeError, without sending the request, unless the tool
call currently advertises capabilities.cancel (see
canCancelToolCall). The response means the Agent accepted the
cancellation, not that the work stopped. The Agent confirms it with a
tool_call_update to a final status.
This only covers tool calls reported in this session. A subagent's tool
call is reported in its child session, so send
methods.agent.toolCall.cancel through ClientContext.request with the
child's sessionId. The tool call's own capabilities.cancel enables
that even when the child session doesn't advertise cancel.
The Agent answers -32602 once the tool call has a final status. This
includes a request sent again after the first one was accepted. The
tool_call_update with that status reports the outcome.
Optionaloptions: SendRequestOptionsExperimental
Stops a terminal's process with terminal/cancel.
Rejects with a TypeError, without sending the request, unless the
terminal currently advertises capabilities.cancel (see
canCancelTerminal). The response means the Agent accepted the
cancellation, not that the process stopped. The Agent confirms it with a
terminal_update that sets exitStatus. The terminal is not released.
This only covers terminals reported in this session. A subagent's
terminal is reported in its child session, so send
methods.agent.terminal.cancel through ClientContext.request with the
child's sessionId. The terminal's own capabilities.cancel enables
that even when the child session doesn't advertise cancel.
The Agent answers -32602 once the process has exited. This includes a
request sent again after the first one was accepted. The
terminal_update that sets exitStatus reports the outcome.
Optionaloptions: SendRequestOptionsExperimental
Sends a prompt to this session.
Strings are converted to one text content block. A single content block is wrapped in an array. A prompt must contain at least one block. The returned promise resolves with the inserted user message's ID once the agent inserts it into the ACP conversation, not when processing finishes.
A prompt may be sent while the agent is working. The agent inserts it
right away or holds it and inserts it later, in the order received; the
promise stays pending until then. session/cancel and session/close
drop the prompts the agent has received but not inserted, and the agent
answers each with -32800. session/cancel does not affect a prompt
sent after it: the agent does not reject that prompt because a
cancellation is in progress, and starts its work only after it reported
idle with stopReason: "cancelled" for the cancelled work.
Aborting options.cancellationSignal sends $/cancel_request for the
prompt, which is best effort. An agent that honors it answers -32800
and does not insert the message. Otherwise the prompt is inserted and the
promise resolves with its messageId. An inserted prompt cannot be
withdrawn. Stop the work it started with session/cancel.
If the response is lost, for example because the connection ended, the
session does not show whether the message was inserted. Pass
options.idempotencyKey to identify retries of the same submission:
while the agent recognizes the key, a retry resolves with the original
messageId and inserts no second message. A retry with a key the agent
has forgotten is a new submission. See ActiveSessionPromptOptions.
Session updates remain independent of this request and have no fixed
order relative to its response; an idle state_update does not establish
that this message was processed. Rejection is reported only by this
promise, not by the session update queue. The agent reports the inserted
message with a user_message update that carries the same messageId.
The agent owns that message, so its content can differ from the prompt
you sent.
Optionaloptions: ActiveSessionPromptOptionsExperimental
Sets a configuration option for this session with
session/set_config_option.
The response carries the agent's complete configOptions list, which
replaces configOptions on this session. For example,
session.setConfigOption({ configId: "model", type: "id", value: "fast" }).
The value ID.
The ID of the configuration option to set.
Optional_meta?: { [key: string]: unknown } | nullThe _meta property is reserved by ACP to allow Clients and Agents to attach additional
metadata to their interactions. Omitted and null are equivalent and mean no metadata.
Implementations MUST NOT assign meaning to keys they do not recognize.
See protocol docs: Extensibility
The boolean value.
The ID of the configuration option to set.
Optional_meta?: { [key: string]: unknown } | nullThe _meta property is reserved by ACP to allow Clients and Agents to attach additional
metadata to their interactions. Omitted and null are equivalent and mean no metadata.
Implementations MUST NOT assign meaning to keys they do not recognize.
See protocol docs: Extensibility
Custom or future session configuration option value type.
Values beginning with _ are reserved for implementation-specific
extensions. Unknown values that do not begin with _ are reserved for
future ACP variants.
Raw value payload for the custom or future value type.
The ID of the configuration option to set.
Optional_meta?: { [key: string]: unknown } | nullThe _meta property is reserved by ACP to allow Clients and Agents to attach additional
metadata to their interactions. Omitted and null are equivalent and mean no metadata.
Implementations MUST NOT assign meaning to keys they do not recognize.
See protocol docs: Extensibility
Readonly[unknownVariant]: trueCustom or future session configuration option value type.
Values beginning with _ are reserved for implementation-specific
extensions. Unknown values that do not begin with _ are reserved for
future ACP variants.
Raw value payload for the custom or future value type.
The ID of the configuration option to set.
Optional_meta?: { [key: string]: unknown } | nullThe _meta property is reserved by ACP to allow Clients and Agents to attach additional
metadata to their interactions. Omitted and null are equivalent and mean no metadata.
Implementations MUST NOT assign meaning to keys they do not recognize.
See protocol docs: Extensibility
Optionaloptions: SendRequestOptionsExperimental
Reads the next update or stop message for this session.
Idle updates are always returned as stop messages, whether or not a prompt
is pending. Queued updates are consumed in arrival order. An abort signal
cancels this read without cancelling session work or discarding updates.
Optionalsignal: AbortSignalExperimental
Collects agent text from the session queue until the next idle update.
This consumes the same queue as nextUpdate(), including already queued
updates. It does not associate output or idle with any submitted prompt,
skip updates when a prompt is sent, or wait for a prompt to be inserted.
Use one reader at a time to avoid splitting the session's updates.
An abort signal cancels the read without cancelling session work.
Full agent_message updates replace content for their messageId, while
agent_message_chunk updates append to it. Non-text content and other
update types are ignored; use nextUpdate() when you need them.
Optionalsignal: AbortSignalExperimental
Stops routing updates to this active-session helper.
This does not close the ACP session on the agent. Use ClientContext
session lifecycle methods when the protocol session itself should be closed
or deleted.
Experimental
Supports explicit resource management with using.
Experimental draft ACP v2 convenience wrapper for an active session.
An active session routes
session/updatenotifications for one session ID into an async queue. Useprompt(...)to submit user content andnextUpdate()to observe the session independently of prompt requests. Astopmessage reports idle foreground work, not per-prompt completion.