pub enum TurnEvent {
Show 14 variants
TextDelta(String),
ReasoningDelta(String),
ToolCallStreaming {
name: String,
hint: String,
},
ToolCallStarted {
id: String,
name: String,
arguments: String,
},
ToolBatchStarted {
batch_id: String,
calls: Vec<ToolBatchCall>,
},
ToolBatchCompleted {
batch_id: String,
ok: usize,
total: usize,
elapsed_ms: u64,
},
ToolOutputChunk {
call_id: String,
chunk: String,
},
ToolCallResult {
call_id: String,
name: String,
output: String,
success: bool,
duration: Duration,
},
Error(String),
Warning(String),
TokenUsage {
prompt_tokens: usize,
completion_tokens: usize,
total_tokens: usize,
cached_tokens: usize,
},
ContextStats {
system_tokens: usize,
sent_tokens: usize,
dropped_tokens: usize,
working_set_tokens: usize,
total_messages: usize,
},
WorkingDirChanged(PathBuf),
ApprovalRequested {
tool_name: String,
reason: String,
call: ToolCall,
messages: Vec<Message>,
},
}Expand description
Low-level events emitted by TurnRunner during execution. Does not contain approval events — approval is handled internally via PermissionDecider.
Variants§
TextDelta(String)
LLM streaming text output
ReasoningDelta(String)
LLM reasoning/thinking content (e.g., DeepSeek-R1, MiniMax-M2.7, o1-series). Emitted when the model produces thinking content separately from the final response. UI can optionally display this in verbose mode (Ctrl+O).
ToolCallStreaming
LLM has started emitting a tool call — name is known, arguments still streaming. Fires once per tool call, BEFORE the full args have arrived. Lets the UI surface the tool name immediately so users see “⠋ Write File…” instead of an opaque “Generating…” while the model spends seconds streaming args.
ToolCallStarted
Tool call fully assembled, about to execute.
id is the provider-supplied call id — pairs with the matching ToolCallResult.call_id.
ToolBatchStarted
Multiple tool calls fan out from one assistant message. Emitted
BEFORE the per-call ToolCallStarted events, only when the
runner is about to dispatch ≥ 2 non-duplicate calls. Lets the
UI render a single grouped block instead of N independent rows.
Per-call ToolCallStarted events STILL fire — UIs that don’t
care about batches can ignore the batch events and render each
call as today.
ToolBatchCompleted
Closes the batch opened by ToolBatchStarted. UI uses it to
finalize the group header with ok / total / elapsed summary.
ToolOutputChunk
Real-time output chunk from a running tool (e.g., bash command). Sent during tool execution before ToolCallResult.
ToolCallResult
Tool call completed.
call_id must equal the id emitted with the corresponding ToolCallStarted.
Error(String)
Non-fatal error during execution
Warning(String)
Non-fatal advisory surfaced from a provider or other subsystem. TUI renders this as a one-line yellow banner; no turn failure. Currently used for “provider may be truncating input” detection.
TokenUsage
Token usage update
ContextStats
Context budget stats for logging
Fields
WorkingDirChanged(PathBuf)
Emitted when a tool mutated ctx.working_dir (e.g. change_dir
or a bash call starting with cd). Lets the TUI footer track
the current cwd without polling the shared Arc<RwLock<PathBuf>>.
ApprovalRequested
A tool requires user approval. Carries a snapshot of
conversation.messages so the TUI can persist mid-turn
session state (e.g. for /bg). The approval itself is
handled by PermissionDecider; this event is purely
informational.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TurnEvent
impl RefUnwindSafe for TurnEvent
impl Send for TurnEvent
impl Sync for TurnEvent
impl Unpin for TurnEvent
impl UnsafeUnpin for TurnEvent
impl UnwindSafe for TurnEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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