Skip to main content

Event

Enum Event 

Source
pub enum Event<StateT: AgentState = JsonValue> {
Show 26 variants TextMessageStart(TextMessageStartEvent), TextMessageContent(TextMessageContentEvent), TextMessageEnd(TextMessageEndEvent), TextMessageChunk(TextMessageChunkEvent), ThinkingTextMessageStart(ThinkingTextMessageStartEvent), ThinkingTextMessageContent(ThinkingTextMessageContentEvent), ThinkingTextMessageEnd(ThinkingTextMessageEndEvent), ToolCallStart(ToolCallStartEvent), ToolCallArgs(ToolCallArgsEvent), ToolCallEnd(ToolCallEndEvent), ToolCallChunk(ToolCallChunkEvent), ToolCallResult(ToolCallResultEvent), ThinkingStart(ThinkingStartEvent), ThinkingEnd(ThinkingEndEvent), StateSnapshot(StateSnapshotEvent<StateT>), StateDelta(StateDeltaEvent), MessagesSnapshot(MessagesSnapshotEvent), ActivitySnapshot(ActivitySnapshotEvent), ActivityDelta(ActivityDeltaEvent), Raw(RawEvent), Custom(CustomEvent), RunStarted(RunStartedEvent), RunFinished(RunFinishedEvent), RunError(RunErrorEvent), StepStarted(StepStartedEvent), StepFinished(StepFinishedEvent),
}
Expand description

Union of all possible events in the Agent User Interaction Protocol.

This enum represents any event that can be sent or received in the AG-UI protocol. Events are serialized with a type discriminant in SCREAMING_SNAKE_CASE format.

§Type Parameter

  • StateT: The type of state for StateSnapshot events, defaults to JsonValue.

§Serialization

Events are serialized as JSON objects with a type field indicating the variant:

{"type": "TEXT_MESSAGE_START", "messageId": "...", "role": "assistant"}

Variants§

§

TextMessageStart(TextMessageStartEvent)

Start of a text message from the assistant.

§

TextMessageContent(TextMessageContentEvent)

Content chunk of a text message (streaming delta).

§

TextMessageEnd(TextMessageEndEvent)

End of a text message.

§

TextMessageChunk(TextMessageChunkEvent)

Complete text message chunk (non-streaming alternative).

§

ThinkingTextMessageStart(ThinkingTextMessageStartEvent)

Start of a thinking text message (extended thinking).

§

ThinkingTextMessageContent(ThinkingTextMessageContentEvent)

Content chunk of a thinking text message.

§

ThinkingTextMessageEnd(ThinkingTextMessageEndEvent)

End of a thinking text message.

§

ToolCallStart(ToolCallStartEvent)

Start of a tool call.

§

ToolCallArgs(ToolCallArgsEvent)

Arguments chunk for a tool call (streaming).

§

ToolCallEnd(ToolCallEndEvent)

End of a tool call.

§

ToolCallChunk(ToolCallChunkEvent)

Complete tool call chunk (non-streaming alternative).

§

ToolCallResult(ToolCallResultEvent)

Result of a tool call execution.

§

ThinkingStart(ThinkingStartEvent)

Start of a thinking step (chain-of-thought boundary).

§

ThinkingEnd(ThinkingEndEvent)

End of a thinking step.

§

StateSnapshot(StateSnapshotEvent<StateT>)

Complete state snapshot.

§

StateDelta(StateDeltaEvent)

Incremental state update (JSON Patch).

§

MessagesSnapshot(MessagesSnapshotEvent)

Complete messages snapshot.

§

ActivitySnapshot(ActivitySnapshotEvent)

Complete activity snapshot.

§

ActivityDelta(ActivityDeltaEvent)

Incremental activity update (JSON Patch).

§

Raw(RawEvent)

Raw event from the underlying provider.

§

Custom(CustomEvent)

Custom application-specific event.

§

RunStarted(RunStartedEvent)

Agent run has started.

§

RunFinished(RunFinishedEvent)

Agent run has finished successfully.

§

RunError(RunErrorEvent)

Agent run encountered an error.

§

StepStarted(StepStartedEvent)

A step within a run has started.

§

StepFinished(StepFinishedEvent)

A step within a run has finished.

Implementations§

Source§

impl<StateT: AgentState> Event<StateT>

Source

pub fn event_type(&self) -> EventType

Returns the event type for this event.

Source

pub fn timestamp(&self) -> Option<f64>

Returns the timestamp of this event if available.

Trait Implementations§

Source§

impl<StateT: Clone + AgentState> Clone for Event<StateT>

Source§

fn clone(&self) -> Event<StateT>

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<StateT: Debug + AgentState> Debug for Event<StateT>

Source§

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

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

impl<'de, StateT: AgentState> Deserialize<'de> for Event<StateT>

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<StateT: PartialEq + AgentState> PartialEq for Event<StateT>

Source§

fn eq(&self, other: &Event<StateT>) -> 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<StateT> Serialize for Event<StateT>
where StateT: Serialize + AgentState,

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<StateT: AgentState> StructuralPartialEq for Event<StateT>

Auto Trait Implementations§

§

impl<StateT> Freeze for Event<StateT>
where StateT: Freeze,

§

impl<StateT> RefUnwindSafe for Event<StateT>
where StateT: RefUnwindSafe,

§

impl<StateT> Send for Event<StateT>

§

impl<StateT> Sync for Event<StateT>

§

impl<StateT> Unpin for Event<StateT>
where StateT: Unpin,

§

impl<StateT> UnsafeUnpin for Event<StateT>
where StateT: UnsafeUnpin,

§

impl<StateT> UnwindSafe for Event<StateT>
where StateT: UnwindSafe,

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, 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> 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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,