#[non_exhaustive]pub enum AgentEvent {
Show 14 variants
AgentStart,
AgentEnd {
messages: Vec<Message>,
},
TurnStart,
TurnEnd {
message: Message,
tool_results: Vec<ToolResult>,
},
MessageStart {
message: Message,
},
MessageDelta {
delta: String,
tokens_generated: u32,
tokens_per_sec: f64,
},
MessageEnd {
message: Message,
},
GenerationStats {
tokens_generated: u32,
prompt_tokens: u32,
tokens_per_sec: f64,
time_to_first_token_ms: f64,
generation_time_ms: f64,
},
ToolExecStart {
tool_call_id: String,
tool_name: String,
args: Value,
},
ToolExecUpdate {
tool_call_id: String,
tool_name: String,
partial: String,
},
ToolExecEnd {
tool_call_id: String,
tool_name: String,
result: ToolResult,
},
ContextBudget {
used_tokens: u32,
max_tokens: u32,
messages_in_context: u32,
messages_pruned: u32,
},
Warning {
message: String,
},
Error {
message: String,
},
}Expand description
Events emitted by the agent loop. Mirrors pi-agent-core’s event system for UI reactivity.
This enum is #[non_exhaustive]: match it with a wildcard arm, as new
event variants may be added in a minor release.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
AgentStart
Agent begins processing a prompt.
AgentEnd
Agent finished all processing.
TurnStart
A new turn begins (one LLM call + any tool executions).
TurnEnd
A turn completed.
Fields
tool_results: Vec<ToolResult>Results of any tools the turn executed.
MessageStart
A message was added (user, assistant, or tool_result).
MessageDelta
Streaming delta for the current assistant message.
Fields
MessageEnd
A message is complete.
GenerationStats
Final timing statistics for a completed generation. Emitted once per successful response so the UI / observability layer can record the real time-to-first-token and generation time (not approximated from tps).
Fields
ToolExecStart
A tool execution started.
Fields
ToolExecUpdate
Streaming progress from a tool execution.
Fields
ToolExecEnd
A tool execution completed.
Fields
result: ToolResultThe tool’s result.
ContextBudget
Context budget info after formatting.
Fields
Warning
Non-fatal warning during processing.
Error
Fatal error that stopped processing.
Trait Implementations§
Source§impl Clone for AgentEvent
impl Clone for AgentEvent
Source§fn clone(&self) -> AgentEvent
fn clone(&self) -> AgentEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more