Skip to main content

AgentEvent

Enum AgentEvent 

Source
pub enum AgentEvent {
Show 13 variants Connected { session_id: String, cwd: String, current_model: CurrentModel, available_models: Vec<AvailableModel>, mode: Option<ModeState>, history_updates: Option<Vec<Message>>, compaction_count: u32, }, ConnectionFailed { message: String, kind: SpawnFailureKind, }, TurnError { session_id: String, message: String, class: TurnErrorClass, }, PermissionRequest { session_id: String, request: PermissionRequest, }, QuestionRequest { session_id: String, request: QuestionRequest, }, PromptCancelResolved { uuid: String, cancelled: bool, }, McpOperationError { session_id: String, error: McpOperationError, }, SetModeFailed { session_id: String, mode: PermissionMode, message: String, }, SetModelFailed { session_id: String, model: String, message: String, }, ContextUsage { session_id: String, percentage: Option<u8>, max_tokens: Option<u64>, total_tokens: Option<u64>, effective_max_tokens: Option<u64>, }, McpSnapshot { session_id: String, servers: Vec<McpServerStatus>, error: Option<String>, }, SdkMessage { session_id: String, msg: Message, }, HookObservation { session_id: String, tool_use_id: Option<String>, permission_mode: Option<String>, effort: Option<String>, agent_id: Option<String>, agent_type: Option<String>, },
}

Variants§

§

Connected

Fields

§session_id: String
§current_model: CurrentModel
§available_models: Vec<AvailableModel>
§history_updates: Option<Vec<Message>>
§compaction_count: u32

Compactions the resumed transcript records, seeding the per-session count. 0 for a fresh session.

§

ConnectionFailed

A spawn failure the bridge could name, carried beside the message so a consumer reads the variant rather than searching rendered prose for a word that a path can also contain.

Fields

§message: String
§

TurnError

A user-facing turn never reached the CLI (or was never acknowledged): a view committed to Thinking before the dispatch, so without this event the spinner never tears down.

Fields

§session_id: String
§message: String
§class: TurnErrorClass

The class of the failure, derived from message where the event is built so no reader has to search the prose again.

§

PermissionRequest

Fields

§session_id: String
§

QuestionRequest

Fields

§session_id: String
§

PromptCancelResolved

The CLI answered a cancel_async_message. cancelled: false means the prompt was already dequeued for execution - it is on its way to the model, and a reader has to say so rather than pretend it was dropped.

Fields

§uuid: String
§cancelled: bool
§

McpOperationError

Fields

§session_id: String
§

SetModeFailed

The CLI refused (or failed) a set_permission_mode control request. message carries the underlying error text so the consumer can roll back the optimistic mode change and surface the reason.

Fields

§session_id: String
§message: String
§

SetModelFailed

The CLI refused (or failed) a set_model control request. message carries the underlying error text so the consumer can roll back the optimistic model change and surface the reason.

Fields

§session_id: String
§model: String
§message: String
§

ContextUsage

Fields

§session_id: String
§percentage: Option<u8>

The share the CLI itself reports, against its effective window.

§max_tokens: Option<u64>

Raw model context-window size in tokens (e.g. 200_000 for Sonnet’s default cap, 1_000_000 for the 1M-context variant). None when the upstream probe hasn’t reported it yet. Sourced from ContextUsageResponse.raw_max_tokens.

§total_tokens: Option<u64>

The tokens the model actually read on its last request.

§effective_max_tokens: Option<u64>

The effective window after any lowered auto-compact window, which is the denominator a fill trigger has to use.

§

McpSnapshot

Fields

§session_id: String
§

SdkMessage

Raw forge_primitives::Message envelope from the underlying SDK Client, forwarded to the consumer (e.g. a view’s app) for per-variant dispatch and state mutation.

Fields

§session_id: String
§

HookObservation

Observation of CLI runtime state captured from a hook input payload as it passes through the SDK’s hook-callback dispatch. Hooks fire on every tool use, prompt submit, etc., so this is a high-fidelity signal compared to the lower-frequency system/status events. Fields are Option because the CLI only populates the relevant subset on each hook event (e.g. agent_id / agent_type are absent for main-agent tool calls).

Fields

§session_id: String

Session id the hook fired in.

§tool_use_id: Option<String>

tool_use_id when the hook event is tool-lifecycle scoped. None for events that aren’t bound to a specific tool call (UserPromptSubmit, Stop, etc.).

§permission_mode: Option<String>

Permission mode active at the moment the hook fired. Wire value as a string (e.g. "acceptEdits", "plan"); the consumer types it with forge_primitives::PermissionMode.

§effort: Option<String>

Effort level active at the moment the hook fired (CLI 2.1.133+, absent for older CLIs). Wire value as a string ("low" / "medium" / "high" / "xhigh" / "max"); the consumer maps to forge_primitives::EffortLevel.

§agent_id: Option<String>

Sub-agent identifier when the hook fired inside a Task-spawned worker. Matches the agent_id from the subagent’s SubagentStart / SubagentStop hooks.

§agent_type: Option<String>

Sub-agent type name (e.g. "general-purpose", "code-reviewer").

Trait Implementations§

Source§

impl Clone for AgentEvent

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AgentEvent

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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