Skip to main content

EngineEvent

Enum EngineEvent 

Source
pub enum EngineEvent {
Show 26 variants TextDelta { text: String, }, TextDone, ThinkingStart, ThinkingDelta { text: String, }, ThinkingDone, ResponseStart, ToolCallStart { id: String, name: String, args: Value, is_sub_agent: bool, }, ToolCallResult { id: String, name: String, output: String, }, ToolOutputLine { id: String, line: String, is_stderr: bool, }, SubAgentStart { agent_name: String, }, TodoUpdate { items: Vec<TodoItem>, diff: TodoDiff, }, BgTaskUpdate { task_id: u32, spawner: Option<u32>, status: AgentStatus, }, ApprovalRequest { id: String, tool_name: String, detail: String, preview: Option<DiffPreview>, effect: ToolEffect, }, AskUserRequest { id: String, question: String, options: Vec<String>, }, ActionBlocked { tool_name: String, detail: String, preview: Option<DiffPreview>, }, ContextUsage { used: usize, max: usize, }, StatusUpdate { model: String, provider: String, context_pct: f64, approval_mode: String, active_tools: usize, }, Footer { prompt_tokens: i64, completion_tokens: i64, cache_read_tokens: i64, thinking_tokens: i64, total_chars: usize, elapsed_ms: u64, rate: f64, context: String, }, SpinnerStart { message: String, }, SpinnerStop, TurnStart { turn_id: String, }, TurnEnd { turn_id: String, reason: TurnEndReason, }, LoopCapReached { cap: u32, recent_tools: Vec<String>, }, Info { message: String, }, Warn { message: String, }, Error { message: String, },
}
Expand description

Events emitted by the engine to the client.

The client is responsible for rendering these events appropriately for its medium (terminal, GUI, JSON stream, etc.).

Variants§

§

TextDelta

A chunk of streaming text from the LLM response.

Fields

§text: String

The text chunk.

§

TextDone

The LLM finished streaming text. Flush any buffered output.

§

ThinkingStart

The LLM started a thinking/reasoning block.

§

ThinkingDelta

A chunk of thinking/reasoning content.

Fields

§text: String

The thinking text chunk.

§

ThinkingDone

The thinking/reasoning block finished.

§

ResponseStart

The LLM response section is starting (shown after thinking ends).

§

ToolCallStart

A tool call is about to be executed.

Fields

§id: String

Unique ID for this tool call (from the LLM).

§name: String

Tool name (e.g., “Bash”, “Read”, “Edit”).

§args: Value

Tool arguments as JSON.

§is_sub_agent: bool

Whether this is a sub-agent’s tool call.

§

ToolCallResult

A tool call completed with output.

Fields

§id: String

Matches the id from ToolCallStart.

§name: String

Tool name.

§output: String

The tool’s output text.

§

ToolOutputLine

A line of streaming output from a tool (currently Bash only).

Emitted as each line arrives from stdout/stderr, before ToolCallResult. Clients can render these in real-time for a “live terminal” feel.

Fields

§id: String

Matches the id from ToolCallStart.

§line: String

The output line (no trailing newline).

§is_stderr: bool

Whether this line came from stderr.

§

SubAgentStart

A sub-agent is being invoked.

Fields

§agent_name: String

Name of the sub-agent being invoked.

§

TodoUpdate

A sub-agent finished. The model called TodoWrite and the engine accepted the new list. Emitted exactly once per accepted call (skipped when the new list is byte-identical to the previous one — the dedup-nudge path returns the “unchanged” message to the model without surfacing a transition to clients).

Carries the full new list AND a server-computed diff against the previously persisted list so every client renders the same animation primitives (added / changed / removed) without having to maintain its own previous-list snapshot.

Establishes the principle from DESIGN.md § Progress Tracking: Model-Owned, History-Persisted, Engine-Surfaced — the engine surfaces transitions, the conversation history persists the list, the system prompt does not re-inject it.

Fields

§items: Vec<TodoItem>

The full todo list as written by the model on this call.

§diff: TodoDiff

Server-computed diff against the previously persisted list (matched by content string). On the first write of a session, every item shows up in added.

§

BgTaskUpdate

A background sub-agent’s status changed.

Emitted on every transition through crate::bg_agent::AgentStatus (PendingRunning { iter } → terminal). Drained from the registry’s status queue inside the inference loop alongside crate::bg_agent::BgAgentRegistry::drain_completed, so any sink (CLI / TUI / headless / ACP) sees the same event stream without having to poll the registry directly.

Closes the engine/UI boundary leak documented in #1076 — prior to this variant the TUI was the only client that could see live bg status because it shared the process and grabbed Arc<BgAgentRegistry> straight out of KodaSession.

Fields

§task_id: u32

Monotonic id assigned at reserve() time, stable for the lifetime of the task.

§spawner: Option<u32>

Sub-agent invocation id of the spawner, or None if the task was launched from the top-level loop. See crate::bg_agent::BgTaskSnapshot::spawner.

§status: AgentStatus

New status. Includes Running { iter } heartbeats so clients can render iteration progress without polling.

§

ApprovalRequest

The engine needs user approval before executing a tool.

The client must respond with EngineCommand::ApprovalResponse matching the same id.

Fields

§id: String

Unique ID for this approval request.

§tool_name: String

Tool name requiring approval.

§detail: String

Human-readable description of the action.

§preview: Option<DiffPreview>

Structured diff preview (rendered by the client).

§effect: ToolEffect

The classified effect that triggered confirmation.

§

AskUserRequest

The model needs a clarifying answer from the user before proceeding.

The client must respond with EngineCommand::AskUserResponse matching the same id. The answer is returned to the model as the tool result, so inference can continue.

Fields

§id: String

Unique ID for this request.

§question: String

The question to ask.

§options: Vec<String>

Optional answer choices (empty = freeform).

§

ActionBlocked

An action was blocked by safe mode (shown but not executed).

Fields

§tool_name: String

Tool name that was blocked.

§detail: String

Description of the blocked action.

§preview: Option<DiffPreview>

Diff preview (if applicable).

§

ContextUsage

Context window usage updated after assembling messages.

Emitted once per inference turn so the client can display context percentage and trigger auto-compaction without reading engine-internal global state.

Fields

§used: usize

Tokens used in the current context window.

§max: usize

Maximum context window size.

§

StatusUpdate

Progress/status update for the persistent status bar.

Fields

§model: String

Current model identifier.

§provider: String

Current provider name.

§context_pct: f64

Context window usage (0.0–1.0).

§approval_mode: String

Current approval mode label.

§active_tools: usize

Number of in-flight tool calls.

§

Footer

Inference completion footer with timing and token stats.

Fields

§prompt_tokens: i64

Input tokens used.

§completion_tokens: i64

Output tokens generated.

§cache_read_tokens: i64

Tokens read from cache.

§thinking_tokens: i64

Tokens used for reasoning.

§total_chars: usize

Total response characters.

§elapsed_ms: u64

Wall-clock time in milliseconds.

§rate: f64

Characters per second.

§context: String

Human-readable context usage string.

§

SpinnerStart

Spinner/progress indicator (presentational hint).

Clients may render this as a terminal spinner, a status bar update, or ignore it entirely. The ratatui TUI uses the status bar instead.

Fields

§message: String

Status message to display.

§

SpinnerStop

Stop the spinner (presentational hint).

See SpinnerStart — clients may ignore this.

§

TurnStart

An inference turn is starting.

Emitted at the beginning of inference_loop(). Clients can use this to lock input, start timers, or update status indicators.

Fields

§turn_id: String

Unique identifier for this turn.

§

TurnEnd

An inference turn has ended.

Emitted when inference_loop() completes. Clients can use this to unlock input, drain type-ahead queues, or update status.

Fields

§turn_id: String

Matches the turn_id from TurnStart.

§reason: TurnEndReason

Why the turn ended.

§

LoopCapReached

The engine’s iteration hard cap was reached.

The client must respond with EngineCommand::LoopDecision. Until the client responds, the inference loop is paused.

Fields

§cap: u32

The iteration cap that was hit.

§recent_tools: Vec<String>

Recent tool names for context.

§

Info

Informational message (not from the LLM).

Fields

§message: String

The informational message.

§

Warn

Warning message.

Fields

§message: String

The warning message.

§

Error

Error message.

Fields

§message: String

The error message.

Trait Implementations§

Source§

impl Clone for EngineEvent

Source§

fn clone(&self) -> EngineEvent

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for EngineEvent

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for EngineEvent

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for EngineEvent

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: 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 = 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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,