Skip to main content

AgentEvent

Enum AgentEvent 

Source
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

§run_id: String

Unique identifier for this run invocation.

§max_iterations: usize

Maximum number of iterations configured for this run.

§

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

§id: String

Tool call identifier.

§name: String

Tool name (may be empty in very early deltas for some providers).

§arguments_fragment: String

Partial JSON arguments accumulated so far.

§

ToolCallStart

Tool is about to be called.

Fields

§id: String

Unique identifier for this tool call.

§name: String

Name of the tool being called.

§arguments: String

JSON-encoded arguments.

§

ToolCallEnd

Tool execution completed.

Fields

§id: String

Unique identifier matching the start event.

§name: String

Name of the tool that was called.

§result: ToolResult

Structured result of the tool execution.

§

TurnComplete

Agent turn completed (may have more turns if tools were called).

Fields

§turn: usize

The turn number (0-indexed).

§has_tool_calls: bool

Whether this turn included tool calls.

§

Checkpoint

Runtime checkpoint emitted after mutating agent state.

Fields

§run_id: String

Unique identifier for this run invocation.

§reason: CheckpointReason

Why the checkpoint was emitted.

§turn: usize

Current turn number (1-indexed within the agent loop).

§phase: ContextWindowPhase

Current lifecycle phase of the assembled context window.

§message_count: usize

Number of recent conversation messages currently in memory.

§

BackgroundTaskStarted

A terminal command was promoted to a background task.

Fields

§task_id: String

Background task identifier.

§output_preview: String

Inline preview of current output.

§output_file: String

File path or URL where full output can be recovered.

§reason: BackgroundReason

Why the command was moved to the background.

§

BackgroundTaskCompleted

A background task completed and its result was reinjected into context.

Fields

§task_id: String

Background task identifier.

§result: String

Structured XML/text payload injected back into context.

§

TerminalInputNeeded

A terminal task is waiting for stdin from the user or host runtime.

Fields

§task_id: Option<String>

Optional task identifier for the waiting terminal.

§notice: String

Human-readable notice explaining why input is needed.

§

RunPaused

The run is now paused waiting for external input.

Fields

§reason: RunPauseReason

Why the run paused.

§tool_call_id: String

Tool call identifier responsible for the pause.

§

RunResumed

The run resumed after an external input arrived.

Fields

§reason: RunPauseReason

Why the run had paused.

§tool_call_id: String

Tool call identifier responsible for the pause.

§

SkillActivated

A skill was activated for the current run.

Fields

§name: String

Skill name.

§allowed_tools: Option<Vec<String>>

Explicitly allowed tools declared by the skill.

§resource_paths: Option<Vec<String>>

Resource files made available by the skill.

§

Complete

Agent finished processing successfully.

Fields

§final_text: String

The final response text.

§turns: usize

Total number of turns taken.

§

Usage(Usage)

Token usage information from LLM.

§

Error(AgentError)

Error occurred during execution.

Implementations§

Source§

impl AgentEvent

Source

pub fn run_start(run_id: impl Into<String>, max_iterations: usize) -> Self

Creates a new run-start event.

Source

pub fn text(content: impl Into<String>) -> Self

Creates a new text event.

Source

pub fn reasoning(content: impl Into<String>) -> Self

Creates a new reasoning event.

Source

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.

Source

pub fn tool_start( id: impl Into<String>, name: impl Into<String>, arguments: impl Into<String>, ) -> Self

Creates a new tool call start event.

Source

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.

Source

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.

Source

pub const fn turn_complete(turn: usize, has_tool_calls: bool) -> Self

Creates a new turn complete event.

Source

pub fn checkpoint( run_id: impl Into<String>, reason: CheckpointReason, turn: usize, phase: ContextWindowPhase, message_count: usize, ) -> Self

Creates a new checkpoint event.

Source

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.

Source

pub fn background_task_completed( task_id: impl Into<String>, result: impl Into<String>, ) -> Self

Creates a background-task-completed event.

Source

pub fn terminal_input_needed( task_id: Option<String>, notice: impl Into<String>, ) -> Self

Creates a terminal-input-needed event.

Source

pub fn run_paused( reason: RunPauseReason, tool_call_id: impl Into<String>, ) -> Self

Creates a run-paused event.

Source

pub fn run_resumed( reason: RunPauseReason, tool_call_id: impl Into<String>, ) -> Self

Creates a run-resumed event.

Source

pub fn skill_activated( name: impl Into<String>, allowed_tools: Option<Vec<String>>, resource_paths: Option<Vec<String>>, ) -> Self

Creates a skill-activated event.

Source

pub fn complete(final_text: impl Into<String>, turns: usize) -> Self

Creates a new completion event.

Source

pub const fn error(error: AgentError) -> Self

Creates a new error event.

Source

pub const fn is_complete(&self) -> bool

Returns true if this is a completion event.

Source

pub const fn is_error(&self) -> bool

Returns true if this is an error event.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AgentEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> TryClone for T
where T: Clone,

Source§

fn try_clone(&self) -> Result<T, Error>

Clones self, possibly returning an error.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more