Skip to main content

HandlerEvent

Enum HandlerEvent 

Source
#[non_exhaustive]
pub enum HandlerEvent { SessionEvent { session_id: SessionId, event: SessionEvent, }, PermissionRequest { session_id: SessionId, request_id: RequestId, data: PermissionRequestData, }, UserInput { session_id: SessionId, question: String, choices: Option<Vec<String>>, allow_freeform: Option<bool>, }, ExternalTool { invocation: ToolInvocation, }, ElicitationRequest { session_id: SessionId, request_id: RequestId, request: ElicitationRequest, }, ExitPlanMode { session_id: SessionId, data: ExitPlanModeData, }, AutoModeSwitch { session_id: SessionId, error_code: Option<String>, retry_after_seconds: Option<f64>, }, }
Expand description

Events dispatched by the SDK session event loop to the handler.

The handler returns a HandlerResponse indicating how the SDK should respond to the CLI. For fire-and-forget events (SessionEvent), the response is ignored.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

SessionEvent

Informational session event from the timeline (e.g. assistant.message_delta, session.idle, tool.execution_start). Fire-and-forget — return HandlerResponse::Ok.

Fields

§session_id: SessionId

The session that emitted this event.

§event: SessionEvent

The event payload.

§

PermissionRequest

The CLI requests permission for an action. Return HandlerResponse::Permission(..).

Fields

§session_id: SessionId

The requesting session.

§request_id: RequestId

Unique ID to correlate the response.

§data: PermissionRequestData

Permission request payload.

§

UserInput

The CLI requests user input. Return HandlerResponse::UserInput(..). The handler may block (e.g. awaiting a UI dialog) — this is expected.

Fields

§session_id: SessionId

The requesting session.

§question: String

The question text to present.

§choices: Option<Vec<String>>

Optional multiple-choice options.

§allow_freeform: Option<bool>

Whether free-form text input is allowed.

§

ExternalTool

The CLI requests execution of a client-defined tool. Return HandlerResponse::ToolResult(..).

Fields

§invocation: ToolInvocation

The tool call to execute.

§

ElicitationRequest

The CLI broadcasts an elicitation request for the provider to handle. Return HandlerResponse::Elicitation(..).

Fields

§session_id: SessionId

The requesting session.

§request_id: RequestId

Unique ID to correlate the response.

§request: ElicitationRequest

The elicitation request payload.

§

ExitPlanMode

The CLI requests exiting plan mode. Return HandlerResponse::ExitPlanMode(..).

Fields

§session_id: SessionId

The requesting session.

§data: ExitPlanModeData

Plan mode exit payload.

§

AutoModeSwitch

The CLI asks whether to switch to auto model when an eligible rate limit is hit. Return HandlerResponse::AutoModeSwitch.

Fields

§session_id: SessionId

The requesting session.

§error_code: Option<String>

The specific rate-limit error code that triggered the request, if known (e.g. user_weekly_rate_limited, user_global_rate_limited).

§retry_after_seconds: Option<f64>

Seconds until the rate limit resets, when known.

Trait Implementations§

Source§

impl Debug for HandlerEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more