pub struct V2Session<Link>{ /* private fields */ }unstable_protocol_v2 only.Expand description
Cloneable command handle for a draft protocol v2 session.
Inbound protocol traffic is intentionally not owned by this value. Receive
authoritative v2::UpdateSessionNotification values and interactive
requests such as v2::RequestPermissionRequest through typed handlers
installed on crate::Builder.
Implementations§
Source§impl<Link> V2Session<Link>
impl<Link> V2Session<Link>
Sourcepub fn session_id(&self) -> &SessionId
pub fn session_id(&self) -> &SessionId
Access the session ID.
Sourcepub fn connection(&self) -> &V2ConnectionTo<Link>
pub fn connection(&self) -> &V2ConnectionTo<Link>
Access the underlying connection.
Sourcepub fn send_prompt(&self, prompt: impl ToString) -> SentRequest<PromptResponse>
pub fn send_prompt(&self, prompt: impl ToString) -> SentRequest<PromptResponse>
Submit a text prompt and return its independent acceptance request.
A successful response only acknowledges that the agent accepted the
prompt. The accepted user message, output, state changes, and completion
arrive independently through v2::UpdateSessionNotification.
Sourcepub fn send_prompt_blocks(
&self,
prompt: Vec<ContentBlock>,
) -> SentRequest<PromptResponse>
pub fn send_prompt_blocks( &self, prompt: Vec<ContentBlock>, ) -> SentRequest<PromptResponse>
Submit arbitrary prompt content and return its acceptance request.
The SDK does not track foreground state or gate prompt submission
locally. Wait for an idle state update before another ordinary prompt
unless using a separately defined admission mechanism.
Sourcepub fn cancel_active_work(&self) -> Result<(), Error>
pub fn cancel_active_work(&self) -> Result<(), Error>
Ask the agent to cancel the session’s current foreground work.
This is independent from cancelling a prompt’s SentRequest.
Cancellation completes when the agent reports an idle state update
with v2::StopReason::Cancelled. The client should immediately mark
unfinished tool calls for the active work as cancelled and remains
responsible for resolving every pending v2::RequestPermissionRequest
with the cancelled outcome.
Sourcepub fn set_config_option(
&self,
config_id: impl Into<SessionConfigId>,
value: impl Into<SessionConfigOptionValue>,
) -> SentRequest<SetSessionConfigOptionResponse>
pub fn set_config_option( &self, config_id: impl Into<SessionConfigId>, value: impl Into<SessionConfigOptionValue>, ) -> SentRequest<SetSessionConfigOptionResponse>
Set a session configuration option.
The response contains the full current option set. It is not cached on this command handle.
Sourcepub fn close(&self) -> SentRequest<CloseSessionResponse>
pub fn close(&self) -> SentRequest<CloseSessionResponse>
Close the remote session and release its resources.
Existing clones of this local command handle are not invalidated, but the agent should reject subsequent commands for the closed session.