Skip to main content

AgentEvent

Enum AgentEvent 

Source
#[non_exhaustive]
pub enum AgentEvent {
Show 32 variants AgentStart { prompts: Vec<Message>, session_id: Option<String>, }, AgentEnd { messages: Vec<Message>, stop_reason: Option<String>, session_id: Option<String>, }, TurnStart { turn_number: u32, }, TurnEnd { turn_number: u32, assistant_message: Message, tool_results: Vec<ToolResultMessage>, }, MessageStart { message: Message, }, MessageUpdate { message: Message, delta: Option<String>, }, MessageEnd { message: Message, }, ToolExecutionStart { tool_call_id: String, tool_name: String, args: Value, }, ToolExecutionUpdate { tool_call_id: String, tool_name: String, partial_result: String, }, ToolExecutionEnd { tool_call_id: String, tool_name: String, result: ToolResult, is_error: bool, }, Start { prompt: String, }, Thinking, ThinkingDelta { text: String, }, TextChunk { text: String, }, ToolCall { tool_call: ToolCall, }, ToolStart { tool_call_id: String, tool_name: String, arguments: Value, }, ToolProgress { tool_call_id: String, message: String, }, ToolComplete { result: ToolResult, }, ToolError { tool_call_id: String, error: String, }, Complete { content: String, stop_reason: String, }, Error { message: String, session_id: Option<String>, }, Iteration { number: usize, }, Usage { input_tokens: usize, output_tokens: usize, }, Compaction { event: CompactionEvent, }, Retry { attempt: usize, max_retries: usize, retry_after_secs: u64, reason: String, session_id: Option<String>, }, Fallback { from_model: String, to_model: String, }, Cancelled, PartialResponse { content: String, }, AutoRetryStart { attempt: usize, max_attempts: usize, delay_ms: u64, error_message: String, }, AutoRetryEnd { success: bool, attempt: usize, final_error: Option<String>, }, SteeringMessage { message: Message, }, FollowUpMessage { message: Message, },
}
Expand description

Events emitted during agent execution.

Events are tagged with type and serialized as camelCase for JSON consumers. This enum is #[non_exhaustive] — new variants may be added in future releases.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

AgentStart

Emitted when the agent begins processing a batch of prompts.

Fields

§prompts: Vec<Message>

The initial prompt messages sent to the agent.

§session_id: Option<String>

Optional session identifier for correlation.

§

AgentEnd

Emitted when the agent finishes all processing.

Fields

§messages: Vec<Message>

Final conversation messages.

§stop_reason: Option<String>

Why the agent stopped (e.g. "end_turn", "tool_use").

§session_id: Option<String>

Optional session identifier for correlation.

§

TurnStart

Emitted at the start of each agent loop turn.

Fields

§turn_number: u32

Zero-based turn index.

§

TurnEnd

Emitted when a turn completes, including the assistant reply and tool results.

Fields

§turn_number: u32

Turn index that just completed.

§assistant_message: Message

The assistant message produced this turn.

§tool_results: Vec<ToolResultMessage>

Tool results collected during this turn.

§

MessageStart

A new message has been created in the conversation.

Fields

§message: Message

The message that started.

§

MessageUpdate

A message has been updated with new content.

Fields

§message: Message

The message in its current state.

§delta: Option<String>

Incremental text delta since the last update, if available.

§

MessageEnd

A message has been finalized.

Fields

§message: Message

The completed message.

§

ToolExecutionStart

A tool is about to be executed.

Fields

§tool_call_id: String

Unique identifier for this tool call.

§tool_name: String

Name of the tool being invoked.

§args: Value

JSON arguments passed to the tool.

§

ToolExecutionUpdate

Partial progress from a running tool execution.

Fields

§tool_call_id: String

Identifier of the tool call producing the update.

§tool_name: String

Name of the tool.

§partial_result: String

Partial result text so far.

§

ToolExecutionEnd

A tool execution has finished.

Fields

§tool_call_id: String

Identifier of the completed tool call.

§tool_name: String

Name of the tool.

§result: ToolResult

The tool result payload.

§is_error: bool

Whether the tool execution resulted in an error.

§

Start

Legacy: agent started processing a prompt.

Fields

§prompt: String

The user prompt that triggered the run.

§

Thinking

Agent is waiting for the first response token.

§

ThinkingDelta

Incremental thinking / reasoning text from the model.

Fields

§text: String

The reasoning text delta.

§

TextChunk

A chunk of generated text from the model.

Fields

§text: String

The text delta to append.

§

ToolCall

The model requested a tool call.

Fields

§tool_call: ToolCall

The tool call descriptor from the provider.

§

ToolStart

A tool execution has started.

Fields

§tool_call_id: String

Identifier of the tool call.

§tool_name: String

Name of the tool being invoked.

§arguments: Value

JSON arguments for the tool call.

§

ToolProgress

Progress update from a running tool.

Fields

§tool_call_id: String

Identifier of the tool call.

§message: String

Human-readable progress message.

§

ToolComplete

A tool execution has completed.

Fields

§result: ToolResult

The tool result payload.

§

ToolError

A tool execution failed.

Fields

§tool_call_id: String

Identifier of the failed tool call.

§error: String

Error description.

§

Complete

The agent produced a final response.

Fields

§content: String

Full response text.

§stop_reason: String

Stop reason string (e.g. "EndTurn").

§

Error

An error occurred during agent execution.

Fields

§message: String

Human-readable error message.

§session_id: Option<String>

Optional session identifier.

§

Iteration

Agent loop iteration counter update.

Fields

§number: usize

Current iteration number.

§

Usage

Token usage report for a completed turn.

Fields

§input_tokens: usize

Number of prompt / input tokens consumed.

§output_tokens: usize

Number of completion / output tokens produced.

§

Compaction

Context compaction lifecycle event.

Fields

§event: CompactionEvent

The underlying compaction event detail.

§

Retry

The agent is retrying after a transient error.

Fields

§attempt: usize

Current retry attempt (1-based).

§max_retries: usize

Maximum number of retries allowed.

§retry_after_secs: u64

Seconds until the next attempt.

§reason: String

Why the previous attempt failed.

§session_id: Option<String>

Optional session identifier.

§

Fallback

The agent switched to a fallback model.

Fields

§from_model: String

Model that was being used before the failure.

§to_model: String

Fallback model that will be used instead.

§

Cancelled

The agent run was cancelled by the caller.

§

PartialResponse

A partial response delivered mid-stream (useful for UI rendering).

Fields

§content: String

Accumulated response content so far.

§

AutoRetryStart

An automatic retry attempt is starting.

Fields

§attempt: usize

Current retry attempt (1-based).

§max_attempts: usize

Total retry attempts that will be made.

§delay_ms: u64

Milliseconds before this attempt is sent.

§error_message: String

The error that triggered the retry.

§

AutoRetryEnd

An automatic retry attempt has concluded.

Fields

§success: bool

Whether the retry succeeded.

§attempt: usize

Which attempt this was (1-based).

§final_error: Option<String>

Final error if the retry failed, None on success.

§

SteeringMessage

A system-level steering message injected into the conversation.

Fields

§message: Message

The steering message to add to the context.

§

FollowUpMessage

A follow-up message appended to continue the conversation.

Fields

§message: Message

The follow-up message.

Implementations§

Source§

impl AgentEvent

Source

pub fn is_terminal(&self) -> bool

Returns true if this event represents the end of the agent lifecycle.

Source

pub fn type_name(&self) -> &'static str

Returns the snake_case variant name of this event (useful for logging / serialization).

Trait Implementations§

Source§

impl Clone for AgentEvent

Source§

fn clone(&self) -> AgentEvent

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<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for AgentEvent

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<AgentEvent, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for AgentEvent

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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<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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> GetSetFdFlags for T

Source§

fn get_fd_flags(&self) -> Result<FdFlags, Error>
where T: AsFilelike,

Query the “status” flags for the self file descriptor.
Source§

fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>
where T: AsFilelike,

Create a new SetFdFlags value for use with set_fd_flags. Read more
Source§

fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>
where T: AsFilelike,

Set the “status” flags for the self file descriptor. Read more
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> Pointee for T

Source§

type Pointer = u32

Source§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_>, ) -> Result<(), Error>

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,