#[non_exhaustive]pub enum AgentEvent {
Show 25 variants
AgentStart,
AgentEnd {
messages: Arc<Vec<AgentMessage>>,
},
TurnStart,
TurnEnd {
assistant_message: AssistantMessage,
tool_results: Vec<ToolResultMessage>,
reason: TurnEndReason,
snapshot: TurnSnapshot,
},
BeforeLlmCall {
system_prompt: String,
messages: Vec<LlmMessage>,
model: ModelSpec,
},
MessageStart,
MessageUpdate {
delta: AssistantMessageDelta,
},
MessageEnd {
message: AssistantMessage,
},
ToolExecutionStart {
id: String,
name: String,
arguments: Value,
},
ToolExecutionUpdate {
id: String,
name: String,
partial: AgentToolResult,
},
ToolApprovalRequested {
id: String,
name: String,
arguments: Value,
},
ToolApprovalResolved {
id: String,
name: String,
approved: bool,
},
ToolExecutionEnd {
id: String,
name: String,
result: AgentToolResult,
is_error: bool,
},
ContextCompacted {
report: CompactionReport,
},
ModelFallback {
from_model: ModelSpec,
to_model: ModelSpec,
},
ModelCycled {
old: ModelSpec,
new: ModelSpec,
reason: String,
},
StateChanged {
delta: StateDelta,
},
CacheAction {
hint: CacheHint,
prefix_tokens: usize,
},
McpServerConnected {
server_name: String,
},
McpServerDisconnected {
server_name: String,
reason: String,
},
McpToolsDiscovered {
server_name: String,
tool_count: usize,
},
McpToolCallStarted {
server_name: String,
tool_name: String,
},
McpToolCallCompleted {
server_name: String,
tool_name: String,
is_error: bool,
},
TransferInitiated {
signal: TransferSignal,
},
Custom(Emission),
}Expand description
Fine-grained lifecycle event emitted by the agent loop.
Consumers subscribe to these events for observability, UI updates, and logging. The harness never calls back into application logic for display concerns.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
AgentStart
Emitted once when the loop begins.
AgentEnd
Emitted once when the loop exits, carrying the final message context.
Fields
messages: Arc<Vec<AgentMessage>>TurnStart
Emitted at the beginning of each assistant turn.
TurnEnd
Emitted at the end of each turn with the assistant message and tool results.
Fields
assistant_message: AssistantMessagetool_results: Vec<ToolResultMessage>reason: TurnEndReasonsnapshot: TurnSnapshotFull context snapshot at the turn boundary for replay/auditing.
BeforeLlmCall
Emitted after context transform, before the LLM streaming call. Allows plugins to observe/log the final prompt.
MessageStart
Emitted when a message begins streaming.
MessageUpdate
Emitted for each incremental delta during assistant streaming.
Fields
delta: AssistantMessageDeltaMessageEnd
Emitted when a message is complete.
Fields
message: AssistantMessageToolExecutionStart
Emitted when a tool call begins execution.
ToolExecutionUpdate
Emitted for intermediate partial results from a streaming tool.
Fields
name: StringThe tool name (matches ToolExecutionStart.name, including any
plugin namespace prefix) so observers can attribute concurrent
updates without inspecting tool output content.
partial: AgentToolResultThe partial tool result payload.
ToolApprovalRequested
Emitted when a tool call is pending approval.
ToolApprovalResolved
Emitted when a tool call approval decision is made.
ToolExecutionEnd
Emitted when a tool call completes.
Fields
name: StringThe tool name (matches ToolExecutionStart.name, including any
plugin namespace prefix) so observers can correlate end events
with the tool that produced them.
result: AgentToolResultContextCompacted
Emitted when context compaction drops messages.
Fields
report: CompactionReportModelFallback
Emitted when the agent falls back to a different model after exhausting retries on the current one.
ModelCycled
Emitted when the agent switches to a different model during a retry cycle.
StateChanged
Emitted when session state delta is flushed (non-empty only).
Fired immediately before TurnEnd.
Fields
delta: StateDeltaCacheAction
Emitted when context caching acts on a turn (write or read).
McpServerConnected
Emitted when an MCP server connects successfully.
McpServerDisconnected
Emitted when an MCP server disconnects.
McpToolsDiscovered
Emitted when tools are discovered from an MCP server.
McpToolCallStarted
Emitted when an MCP tool call begins execution.
McpToolCallCompleted
Emitted when an MCP tool call completes.
TransferInitiated
Emitted when a tool signals a transfer to another agent.
Contains the enriched TransferSignal
with conversation history. Emitted immediately before the TurnEnd event
with TurnEndReason::Transfer.
Fields
signal: TransferSignalCustom(Emission)
A custom event emitted via Agent::emit.
Trait Implementations§
Source§impl Clone for AgentEvent
impl Clone for AgentEvent
Source§fn clone(&self) -> AgentEvent
fn clone(&self) -> AgentEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more