pub enum AgentEvent {
SessionInit {
session_id: String,
model: String,
},
Text(String),
ToolUse {
name: String,
input: Value,
},
QuestionPending {
request_id: String,
questions: Value,
},
TurnComplete {
result: Option<String>,
subtype: String,
num_turns: u32,
duration_ms: u64,
is_error: bool,
session_id: String,
},
ToolApprovalPending {
request_id: String,
tool_name: String,
tool_input: Value,
},
ToolProgress {
tool_name: String,
},
ProcessExited {
code: Option<i32>,
},
}Expand description
Events emitted by an agent during a session.
Agents communicate asynchronously via events. Handlers receive these
events through the AgentHandle.receiver channel and respond by:
- Displaying text to the user
- Posting tool activity notifications
- Waiting for user input (questions)
- Finalizing the turn when complete
§Event Flow
SessionInit- Session starts (provides session_id)Text,ToolUse,ToolProgress- Activity during the turn (may repeat)QuestionPending- If Claude asks a question (blocks until answered)TurnComplete- Turn finishes successfully
Alternatively, ProcessExited can occur at any time if the agent crashes.
Variants§
SessionInit
Session initialized (carries session_id, model).
Text(String)
Text content from Claude.
ToolUse
Claude is using a tool.
QuestionPending
Claude is asking the user a question via control_request (AskUserQuestion tool).
TurnComplete
A turn completed.
Fields
ToolApprovalPending
Claude wants to use a tool that requires user approval.
ToolProgress
Tool progress heartbeat.
ProcessExited
Agent process exited unexpectedly.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AgentEvent
impl RefUnwindSafe for AgentEvent
impl Send for AgentEvent
impl Sync for AgentEvent
impl Unpin for AgentEvent
impl UnsafeUnpin for AgentEvent
impl UnwindSafe for AgentEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more