pub enum AgentEvent {
Show 17 variants
RunStart {
run_id: String,
max_iterations: usize,
},
Text(String),
Reasoning(String),
ToolCallDelta {
id: String,
name: String,
arguments_fragment: String,
},
ToolCallStart {
id: String,
name: String,
arguments: String,
},
ToolCallEnd {
id: String,
name: String,
result: ToolResult,
},
TurnComplete {
turn: usize,
has_tool_calls: bool,
},
Checkpoint {
run_id: String,
reason: CheckpointReason,
turn: usize,
phase: ContextWindowPhase,
message_count: usize,
},
BackgroundTaskStarted {
task_id: String,
output_preview: String,
output_file: String,
reason: BackgroundReason,
},
BackgroundTaskCompleted {
task_id: String,
result: String,
},
TerminalInputNeeded {
task_id: Option<String>,
notice: String,
},
RunPaused {
reason: RunPauseReason,
tool_call_id: String,
},
RunResumed {
reason: RunPauseReason,
tool_call_id: String,
},
SkillActivated {
name: String,
allowed_tools: Option<Vec<String>>,
resource_paths: Option<Vec<String>>,
},
Complete {
final_text: String,
turns: usize,
},
Usage(Usage),
Error(AgentError),
}Expand description
Events emitted during agent execution.
Variants§
RunStart
Agent run started with a stable run identifier.
Fields
Text(String)
Text chunk from the LLM response.
Reasoning(String)
Reasoning step (for models with extended thinking).
ToolCallDelta
Incremental tool call assembly progress from the model stream.
Emitted as the model streams tool call name and arguments, before the full call is assembled. UI layers can use this to show early feedback.
Fields
ToolCallStart
Tool is about to be called.
Fields
ToolCallEnd
Tool execution completed.
Fields
result: ToolResultStructured result of the tool execution.
TurnComplete
Agent turn completed (may have more turns if tools were called).
Fields
Checkpoint
Runtime checkpoint emitted after mutating agent state.
Fields
reason: CheckpointReasonWhy the checkpoint was emitted.
phase: ContextWindowPhaseCurrent lifecycle phase of the assembled context window.
BackgroundTaskStarted
A terminal command was promoted to a background task.
Fields
reason: BackgroundReasonWhy the command was moved to the background.
BackgroundTaskCompleted
A background task completed and its result was reinjected into context.
Fields
TerminalInputNeeded
A terminal task is waiting for stdin from the user or host runtime.
Fields
RunPaused
The run is now paused waiting for external input.
Fields
reason: RunPauseReasonWhy the run paused.
RunResumed
The run resumed after an external input arrived.
Fields
reason: RunPauseReasonWhy the run had paused.
SkillActivated
A skill was activated for the current run.
Fields
Complete
Agent finished processing successfully.
Usage(Usage)
Token usage information from LLM.
Error(AgentError)
Error occurred during execution.
Implementations§
Source§impl AgentEvent
impl AgentEvent
Sourcepub fn run_start(run_id: impl Into<String>, max_iterations: usize) -> Self
pub fn run_start(run_id: impl Into<String>, max_iterations: usize) -> Self
Creates a new run-start event.
Sourcepub fn tool_delta(
id: impl Into<String>,
name: impl Into<String>,
arguments_fragment: impl Into<String>,
) -> Self
pub fn tool_delta( id: impl Into<String>, name: impl Into<String>, arguments_fragment: impl Into<String>, ) -> Self
Creates a new tool call delta event.
Sourcepub fn tool_start(
id: impl Into<String>,
name: impl Into<String>,
arguments: impl Into<String>,
) -> Self
pub fn tool_start( id: impl Into<String>, name: impl Into<String>, arguments: impl Into<String>, ) -> Self
Creates a new tool call start event.
Sourcepub fn tool_success(
id: impl Into<String>,
name: impl Into<String>,
result: impl Into<String>,
) -> Self
pub fn tool_success( id: impl Into<String>, name: impl Into<String>, result: impl Into<String>, ) -> Self
Creates a new tool call end event with success.
Sourcepub fn tool_failure(
id: impl Into<String>,
name: impl Into<String>,
error: impl Into<String>,
) -> Self
pub fn tool_failure( id: impl Into<String>, name: impl Into<String>, error: impl Into<String>, ) -> Self
Creates a new tool call end event with failure.
Sourcepub const fn turn_complete(turn: usize, has_tool_calls: bool) -> Self
pub const fn turn_complete(turn: usize, has_tool_calls: bool) -> Self
Creates a new turn complete event.
Sourcepub fn checkpoint(
run_id: impl Into<String>,
reason: CheckpointReason,
turn: usize,
phase: ContextWindowPhase,
message_count: usize,
) -> Self
pub fn checkpoint( run_id: impl Into<String>, reason: CheckpointReason, turn: usize, phase: ContextWindowPhase, message_count: usize, ) -> Self
Creates a new checkpoint event.
Sourcepub fn background_task_started(
task_id: impl Into<String>,
output_preview: impl Into<String>,
output_file: impl Into<String>,
reason: BackgroundReason,
) -> Self
pub fn background_task_started( task_id: impl Into<String>, output_preview: impl Into<String>, output_file: impl Into<String>, reason: BackgroundReason, ) -> Self
Creates a background-task-started event.
Sourcepub fn background_task_completed(
task_id: impl Into<String>,
result: impl Into<String>,
) -> Self
pub fn background_task_completed( task_id: impl Into<String>, result: impl Into<String>, ) -> Self
Creates a background-task-completed event.
Sourcepub fn terminal_input_needed(
task_id: Option<String>,
notice: impl Into<String>,
) -> Self
pub fn terminal_input_needed( task_id: Option<String>, notice: impl Into<String>, ) -> Self
Creates a terminal-input-needed event.
Sourcepub fn run_paused(
reason: RunPauseReason,
tool_call_id: impl Into<String>,
) -> Self
pub fn run_paused( reason: RunPauseReason, tool_call_id: impl Into<String>, ) -> Self
Creates a run-paused event.
Sourcepub fn run_resumed(
reason: RunPauseReason,
tool_call_id: impl Into<String>,
) -> Self
pub fn run_resumed( reason: RunPauseReason, tool_call_id: impl Into<String>, ) -> Self
Creates a run-resumed event.
Sourcepub fn skill_activated(
name: impl Into<String>,
allowed_tools: Option<Vec<String>>,
resource_paths: Option<Vec<String>>,
) -> Self
pub fn skill_activated( name: impl Into<String>, allowed_tools: Option<Vec<String>>, resource_paths: Option<Vec<String>>, ) -> Self
Creates a skill-activated event.
Sourcepub fn complete(final_text: impl Into<String>, turns: usize) -> Self
pub fn complete(final_text: impl Into<String>, turns: usize) -> Self
Creates a new completion event.
Sourcepub const fn error(error: AgentError) -> Self
pub const fn error(error: AgentError) -> Self
Creates a new error event.
Sourcepub const fn is_complete(&self) -> bool
pub const fn is_complete(&self) -> bool
Returns true if this is a completion event.
Sourcepub const fn is_terminal(&self) -> bool
pub const fn is_terminal(&self) -> bool
Returns true if this is a terminal event (complete or error).
Trait Implementations§
Source§impl Clone for AgentEvent
impl Clone for AgentEvent
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more