#[non_exhaustive]pub enum Event {
Started {
session: String,
model: Option<String>,
},
Thinking(String),
Text(String),
ToolCall {
id: Option<String>,
name: String,
input: Value,
},
ToolResult {
id: Option<String>,
ok: Option<bool>,
output: String,
},
Usage(Usage),
ApprovalRequest(Approval),
RateLimit(RateLimit),
}Expand description
One normalized thing an agent did, agent-agnostic so a single renderer works across all three.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Started
The session is live. Emitted once, as early as the agent reveals it.
Fields
Thinking(String)
Reasoning text, where the agent exposes it.
Text(String)
Assistant text as it arrives.
ToolCall
The agent invoked a tool.
Fields
id: Option<String>Correlates with the matching Event::ToolResult, when the agent
provides an id.
ToolResult
A tool returned.
Fields
id: Option<String>Correlates with the originating Event::ToolCall.
Usage(Usage)
Token usage so far, reported while the turn is still running.
For a live counter in a UI. Emitted once per model call, so a host can
fold each into a running total with crate::Usage::accumulate, whose
per-field rules were written for exactly this.
output_tokens is deliberately absent here. Mid-turn the agent
reports the count as it stood when the message began, which understates
the finished figure badly: a run whose per-call reports summed to 9 had
generated 497 by the end. The context figures are exact, so a counter
built on crate::Usage::context_tokens is honest and one built on
output would not be. The true output count arrives with the
crate::Outcome.
Claude reports this throughout a turn. Copilot reports once, near the end. Codex reports nothing until the turn completes, so it never emits this.
ApprovalRequest(Approval)
The agent is waiting for permission to make a tool call.
Only emitted when the request asked for it via
crate::Request::approvals. The run is blocked until
crate::Run::respond answers it, so a consumer that ignores this
stalls until the run’s timeout.
RateLimit(RateLimit)
A quota signal. Reported, never acted on.