pub enum Event {
Init {
model: String,
tools: Vec<String>,
working_directory: Option<String>,
metadata: HashMap<String, Value>,
},
UserMessage {
content: Vec<ContentBlock>,
},
AssistantMessage {
content: Vec<ContentBlock>,
usage: Option<Usage>,
parent_tool_use_id: Option<String>,
},
ToolExecution {
tool_name: String,
tool_id: String,
input: Value,
result: ToolResult,
parent_tool_use_id: Option<String>,
},
TurnComplete {
stop_reason: Option<String>,
turn_index: u32,
usage: Option<Usage>,
},
Result {
success: bool,
message: Option<String>,
duration_ms: Option<u64>,
num_turns: Option<u32>,
},
Error {
message: String,
details: Option<Value>,
},
PermissionRequest {
tool_name: String,
description: String,
granted: bool,
},
}Expand description
A single event in an agent session.
Events represent discrete steps in the conversation flow, such as initialization, messages, tool calls, and results.
Variants§
Init
Session initialization event
Fields
UserMessage
Message from the user (replayed via –replay-user-messages)
Fields
content: Vec<ContentBlock>AssistantMessage
Message from the assistant
Fields
content: Vec<ContentBlock>ToolExecution
Tool execution event
Fields
result: ToolResultTurnComplete
End of a single assistant turn.
In bidirectional streaming mode, this fires exactly once per turn,
after the final Event::AssistantMessage / Event::ToolExecution
of the turn and immediately before the per-turn Event::Result.
Prefer this over Result as the turn-boundary signal in new code.
For providers that don’t expose a bidirectional streaming session (currently everything except Claude), this event is not emitted.
Fields
Result
Session-final or per-turn result summary from the provider.
In bidirectional streaming mode this fires after
Event::TurnComplete at the end of every turn. In batch mode it
fires once when the provider reports the session-final result.
Error
An error occurred
PermissionRequest
Permission was requested