#[non_exhaustive]pub enum StepEvent {
AssistantText {
text: String,
step: usize,
},
ToolCall {
call: ToolCall,
step: usize,
},
Latency {
step: usize,
llm_ms: u64,
},
ToolResult {
id: String,
name: String,
output: String,
step: usize,
},
Usage {
usage: TokenUsage,
step: usize,
},
PartialToken {
text: String,
step: usize,
},
Compacted {
removed: usize,
kept: usize,
summary_chars: usize,
step: usize,
},
Finished {
reason: FinishReason,
steps: usize,
},
PlanProposed {
plan_text: String,
tool_calls: Vec<ToolCall>,
},
PlanConfirmed,
PlanRejected {
reason: String,
},
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
AssistantText
Model generated text without tool calls.
Emitted when the LLM produces a response. This is typically the final
answer or intermediate reasoning. The text field contains the complete
model response, and step indicates which iteration this occurred on.
ToolCall
Model requested to execute a tool.
Emitted when the LLM calls a tool. Contains the tool name, ID, and arguments
that will be executed. The call is dispatched to the registry after this event.
Tool errors are reported via ToolResult events, not ToolCall failures.
Latency
Time taken for the LLM request (excluding tool execution).
Emitted after the model responds. Useful for measuring provider latency
and diagnosing slow responses. llm_ms is in milliseconds.
ToolResult
Result of executing a tool call.
Emitted after a tool finishes executing. Contains the tool name, call ID, the output string (or error message), and the step number. This result is added to the transcript and sent back to the model for the next iteration. In case of tool error, the output will be the error message prefixed with “ERROR: “.
Usage
Token usage statistics from the LLM provider.
Emitted if the provider returns usage information (input tokens, output tokens). Accumulated across all steps for total usage. Useful for cost tracking and monitoring resource consumption.
PartialToken
Partial token from streaming response (if streaming enabled).
Only emitted if streaming is enabled. Contains a single token or partial chunk of the model’s response text. Allows UI layers to display real-time incremental updates to the model’s output without waiting for the entire response.
Compacted
Transcript was compacted to fit size constraints.
Emitted when the transcript exceeds the max size and is automatically compacted.
The removed field shows how many messages were summarized, kept shows how many
remain, and summary_chars shows the size of the compaction summary added.
This allows UI layers to notify users that older context has been summarized.
Compaction only occurs if a Compactor is configured on the Agent.
Finished
Agent run completed.
Emitted as the final event. Indicates the run is done and why it stopped.
reason explains the termination (no more tool calls, budget exceeded, stuck
detection, etc.). steps shows how many iterations were executed.
After this event, no more events will be emitted for this run.
PlanProposed
Agent has produced a plan and is waiting for confirmation.
Fields
PlanConfirmed
Plan was confirmed, execution will proceed.
PlanRejected
Plan was rejected with a reason.