Event

Enum Event 

Source
pub enum Event {
Show 28 variants RunStarted { thread_id: String, run_id: String, parent_run_id: Option<String>, input: Option<Value>, base: BaseEvent, }, RunFinished { thread_id: String, run_id: String, result: Option<Value>, base: BaseEvent, }, RunError { message: String, code: Option<String>, base: BaseEvent, }, StepStarted { step_name: String, base: BaseEvent, }, StepFinished { step_name: String, base: BaseEvent, }, TextMessageStart { message_id: String, role: Role, base: BaseEvent, }, TextMessageContent { message_id: String, delta: String, base: BaseEvent, }, TextMessageEnd { message_id: String, base: BaseEvent, }, TextMessageChunk { message_id: Option<String>, role: Option<Role>, delta: Option<String>, base: BaseEvent, }, ReasoningStart { message_id: String, base: BaseEvent, }, ReasoningMessageStart { message_id: String, role: Role, base: BaseEvent, }, ReasoningMessageContent { message_id: String, delta: String, base: BaseEvent, }, ReasoningMessageEnd { message_id: String, base: BaseEvent, }, ReasoningMessageChunk { message_id: Option<String>, delta: Option<String>, base: BaseEvent, }, ReasoningEnd { message_id: String, base: BaseEvent, }, ReasoningEncryptedValue { subtype: ReasoningEncryptedValueSubtype, entity_id: String, encrypted_value: String, base: BaseEvent, }, ToolCallStart { tool_call_id: String, tool_call_name: String, parent_message_id: Option<String>, base: BaseEvent, }, ToolCallArgs { tool_call_id: String, delta: String, base: BaseEvent, }, ToolCallEnd { tool_call_id: String, base: BaseEvent, }, ToolCallResult { message_id: String, tool_call_id: String, content: String, role: Option<Role>, base: BaseEvent, }, ToolCallChunk { tool_call_id: Option<String>, tool_call_name: Option<String>, parent_message_id: Option<String>, delta: Option<String>, base: BaseEvent, }, StateSnapshot { snapshot: Value, base: BaseEvent, }, StateDelta { delta: Vec<Value>, base: BaseEvent, }, MessagesSnapshot { messages: Vec<Value>, base: BaseEvent, }, ActivitySnapshot { message_id: String, activity_type: String, content: HashMap<String, Value>, replace: Option<bool>, base: BaseEvent, }, ActivityDelta { message_id: String, activity_type: String, patch: Vec<Value>, base: BaseEvent, }, Raw { event: Value, source: Option<String>, base: BaseEvent, }, Custom { name: String, value: Value, base: BaseEvent, },
}
Expand description

AG-UI Protocol Event Types.

These events follow the AG-UI specification for agent-to-frontend communication. See: https://docs.ag-ui.com/concepts/events

Variants§

§

RunStarted

Signals the start of an agent run.

Fields

§thread_id: String
§run_id: String
§parent_run_id: Option<String>
§input: Option<Value>
§

RunFinished

Signals successful completion of an agent run.

Fields

§thread_id: String
§run_id: String
§result: Option<Value>
§

RunError

Indicates an error occurred during the run.

Fields

§message: String
§

StepStarted

Marks the beginning of a step within a run.

Fields

§step_name: String
§

StepFinished

Marks the completion of a step.

Fields

§step_name: String
§

TextMessageStart

Indicates the beginning of a text message stream.

Fields

§message_id: String
§role: Role

Role is always “assistant” for TEXT_MESSAGE_START.

§

TextMessageContent

Contains incremental text content.

Fields

§message_id: String
§delta: String
§

TextMessageEnd

Indicates the end of a text message stream.

Fields

§message_id: String
§

TextMessageChunk

Combined chunk event for text messages (alternative to Start/Content/End).

Fields

§message_id: Option<String>
§role: Option<Role>
§

ReasoningStart

Marks the start of a reasoning phase for a message.

Fields

§message_id: String
§

ReasoningMessageStart

Marks the start of a streamed reasoning message.

Fields

§message_id: String
§role: Role
§

ReasoningMessageContent

Contains incremental reasoning text.

Fields

§message_id: String
§delta: String
§

ReasoningMessageEnd

Marks the end of a streamed reasoning message.

Fields

§message_id: String
§

ReasoningMessageChunk

Combined reasoning chunk event (alternative to Start/Content/End).

Fields

§message_id: Option<String>
§

ReasoningEnd

Marks the end of a reasoning phase for a message.

Fields

§message_id: String
§

ReasoningEncryptedValue

Attaches an encrypted reasoning value to a message or tool call.

Fields

§entity_id: String
§encrypted_value: String
§

ToolCallStart

Signals the start of a tool call.

Fields

§tool_call_id: String
§tool_call_name: String
§parent_message_id: Option<String>
§

ToolCallArgs

Contains incremental tool arguments.

Fields

§tool_call_id: String
§delta: String
§

ToolCallEnd

Signals the end of tool argument streaming.

Fields

§tool_call_id: String
§

ToolCallResult

Contains the result of a tool execution.

Fields

§message_id: String
§tool_call_id: String
§content: String
§role: Option<Role>
§

ToolCallChunk

Combined chunk event for tool calls (alternative to Start/Args/End).

Fields

§tool_call_id: Option<String>
§tool_call_name: Option<String>
§parent_message_id: Option<String>
§

StateSnapshot

Provides a complete state snapshot.

Fields

§snapshot: Value
§

StateDelta

Contains incremental state changes (RFC 6902 JSON Patch).

Fields

§delta: Vec<Value>

Array of JSON Patch operations.

§

MessagesSnapshot

Provides a complete message history snapshot.

Fields

§messages: Vec<Value>
§

ActivitySnapshot

Provides an activity snapshot.

Fields

§message_id: String
§activity_type: String
§replace: Option<bool>
§

ActivityDelta

Contains incremental activity changes (RFC 6902 JSON Patch).

Fields

§message_id: String
§activity_type: String
§patch: Vec<Value>

Array of JSON Patch operations.

§

Raw

Wraps events from external systems.

Fields

§event: Value
§source: Option<String>
§

Custom

Custom application-defined event.

Fields

§name: String
§value: Value

Implementations§

Source§

impl Event

Source

pub fn run_started( thread_id: impl Into<String>, run_id: impl Into<String>, parent_run_id: Option<String>, ) -> Self

Create a run-started event.

Source

pub fn run_started_with_input( thread_id: impl Into<String>, run_id: impl Into<String>, parent_run_id: Option<String>, input: Value, ) -> Self

Create a run-started event with input.

Source

pub fn run_finished( thread_id: impl Into<String>, run_id: impl Into<String>, result: Option<Value>, ) -> Self

Create a run-finished event.

Source

pub fn run_error(message: impl Into<String>, code: Option<String>) -> Self

Create a run-error event.

Source

pub fn step_started(step_name: impl Into<String>) -> Self

Create a step-started event.

Source

pub fn step_finished(step_name: impl Into<String>) -> Self

Create a step-finished event.

Source

pub fn text_message_start(message_id: impl Into<String>) -> Self

Create a text-message-start event.

Source

pub fn text_message_content( message_id: impl Into<String>, delta: impl Into<String>, ) -> Self

Create a text-message-content event.

Source

pub fn text_message_end(message_id: impl Into<String>) -> Self

Create a text-message-end event.

Source

pub fn text_message_chunk( message_id: Option<String>, role: Option<Role>, delta: Option<String>, ) -> Self

Create a text-message-chunk event.

Source

pub fn reasoning_start(message_id: impl Into<String>) -> Self

Create a reasoning-start event.

Source

pub fn reasoning_message_start(message_id: impl Into<String>) -> Self

Create a reasoning-message-start event.

Source

pub fn reasoning_message_content( message_id: impl Into<String>, delta: impl Into<String>, ) -> Self

Create a reasoning-message-content event.

Source

pub fn reasoning_message_end(message_id: impl Into<String>) -> Self

Create a reasoning-message-end event.

Source

pub fn reasoning_message_chunk( message_id: Option<String>, delta: Option<String>, ) -> Self

Create a reasoning-message-chunk event.

Source

pub fn reasoning_end(message_id: impl Into<String>) -> Self

Create a reasoning-end event.

Source

pub fn reasoning_encrypted_value( subtype: ReasoningEncryptedValueSubtype, entity_id: impl Into<String>, encrypted_value: impl Into<String>, ) -> Self

Create a reasoning-encrypted-value event.

Source

pub fn tool_call_start( tool_call_id: impl Into<String>, tool_call_name: impl Into<String>, parent_message_id: Option<String>, ) -> Self

Create a tool-call-start event.

Source

pub fn tool_call_args( tool_call_id: impl Into<String>, delta: impl Into<String>, ) -> Self

Create a tool-call-args event.

Source

pub fn tool_call_end(tool_call_id: impl Into<String>) -> Self

Create a tool-call-end event.

Source

pub fn tool_call_result( message_id: impl Into<String>, tool_call_id: impl Into<String>, content: impl Into<String>, ) -> Self

Create a tool-call-result event.

Source

pub fn tool_call_chunk( tool_call_id: Option<String>, tool_call_name: Option<String>, parent_message_id: Option<String>, delta: Option<String>, ) -> Self

Create a tool-call-chunk event.

Source

pub fn state_snapshot(snapshot: Value) -> Self

Create a state-snapshot event.

Source

pub fn state_delta(delta: Vec<Value>) -> Self

Create a state-delta event.

Source

pub fn messages_snapshot(messages: Vec<Value>) -> Self

Create a messages-snapshot event.

Source

pub fn activity_snapshot( message_id: impl Into<String>, activity_type: impl Into<String>, content: HashMap<String, Value>, replace: Option<bool>, ) -> Self

Create an activity-snapshot event.

Source

pub fn activity_delta( message_id: impl Into<String>, activity_type: impl Into<String>, patch: Vec<Value>, ) -> Self

Create an activity-delta event.

Source

pub fn raw(event: Value, source: Option<String>) -> Self

Create a raw event.

Source

pub fn custom(name: impl Into<String>, value: Value) -> Self

Create a custom event.

Source

pub fn with_timestamp(self, timestamp: u64) -> Self

Set timestamp on the event.

Source

pub fn now_millis() -> u64

Get current timestamp in milliseconds.

Trait Implementations§

Source§

impl Clone for Event

Source§

fn clone(&self) -> Event

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Event

Source§

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

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

impl<'de> Deserialize<'de> for Event

Source§

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

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

impl PartialEq for Event

Source§

fn eq(&self, other: &Event) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Event

Source§

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

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Event

Auto Trait Implementations§

§

impl Freeze for Event

§

impl RefUnwindSafe for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnwindSafe for Event

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> 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.

§

impl<T> Instrument for T

§

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

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

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.

§

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

§

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
§

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

impl<T> WithSubscriber for T

§

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
§

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>,