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
RunFinished
Signals successful completion of an agent run.
RunError
Indicates an error occurred during the run.
StepStarted
Marks the beginning of a step within a run.
StepFinished
Marks the completion of a step.
TextMessageStart
Indicates the beginning of a text message stream.
Fields
TextMessageContent
Contains incremental text content.
TextMessageEnd
Indicates the end of a text message stream.
TextMessageChunk
Combined chunk event for text messages (alternative to Start/Content/End).
ReasoningStart
Marks the start of a reasoning phase for a message.
ReasoningMessageStart
Marks the start of a streamed reasoning message.
ReasoningMessageContent
Contains incremental reasoning text.
ReasoningMessageEnd
Marks the end of a streamed reasoning message.
ReasoningMessageChunk
Combined reasoning chunk event (alternative to Start/Content/End).
ReasoningEnd
Marks the end of a reasoning phase for a message.
ReasoningEncryptedValue
Attaches an encrypted reasoning value to a message or tool call.
Fields
subtype: ReasoningEncryptedValueSubtypeToolCallStart
Signals the start of a tool call.
Fields
ToolCallArgs
Contains incremental tool arguments.
ToolCallEnd
Signals the end of tool argument streaming.
ToolCallResult
Contains the result of a tool execution.
ToolCallChunk
Combined chunk event for tool calls (alternative to Start/Args/End).
Fields
StateSnapshot
Provides a complete state snapshot.
StateDelta
Contains incremental state changes (RFC 6902 JSON Patch).
MessagesSnapshot
Provides a complete message history snapshot.
ActivitySnapshot
Provides an activity snapshot.
Fields
ActivityDelta
Contains incremental activity changes (RFC 6902 JSON Patch).
Fields
Raw
Wraps events from external systems.
Custom
Custom application-defined event.
Implementations§
Source§impl Event
impl Event
Sourcepub fn run_started(
thread_id: impl Into<String>,
run_id: impl Into<String>,
parent_run_id: Option<String>,
) -> Self
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.
Sourcepub fn run_started_with_input(
thread_id: impl Into<String>,
run_id: impl Into<String>,
parent_run_id: Option<String>,
input: Value,
) -> Self
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.
Sourcepub fn run_finished(
thread_id: impl Into<String>,
run_id: impl Into<String>,
result: Option<Value>,
) -> Self
pub fn run_finished( thread_id: impl Into<String>, run_id: impl Into<String>, result: Option<Value>, ) -> Self
Create a run-finished event.
Sourcepub fn run_error(message: impl Into<String>, code: Option<String>) -> Self
pub fn run_error(message: impl Into<String>, code: Option<String>) -> Self
Create a run-error event.
Sourcepub fn step_started(step_name: impl Into<String>) -> Self
pub fn step_started(step_name: impl Into<String>) -> Self
Create a step-started event.
Sourcepub fn step_finished(step_name: impl Into<String>) -> Self
pub fn step_finished(step_name: impl Into<String>) -> Self
Create a step-finished event.
Sourcepub fn text_message_start(message_id: impl Into<String>) -> Self
pub fn text_message_start(message_id: impl Into<String>) -> Self
Create a text-message-start event.
Sourcepub fn text_message_content(
message_id: impl Into<String>,
delta: impl Into<String>,
) -> Self
pub fn text_message_content( message_id: impl Into<String>, delta: impl Into<String>, ) -> Self
Create a text-message-content event.
Sourcepub fn text_message_end(message_id: impl Into<String>) -> Self
pub fn text_message_end(message_id: impl Into<String>) -> Self
Create a text-message-end event.
Sourcepub fn text_message_chunk(
message_id: Option<String>,
role: Option<Role>,
delta: Option<String>,
) -> Self
pub fn text_message_chunk( message_id: Option<String>, role: Option<Role>, delta: Option<String>, ) -> Self
Create a text-message-chunk event.
Sourcepub fn reasoning_start(message_id: impl Into<String>) -> Self
pub fn reasoning_start(message_id: impl Into<String>) -> Self
Create a reasoning-start event.
Sourcepub fn reasoning_message_start(message_id: impl Into<String>) -> Self
pub fn reasoning_message_start(message_id: impl Into<String>) -> Self
Create a reasoning-message-start event.
Sourcepub fn reasoning_message_content(
message_id: impl Into<String>,
delta: impl Into<String>,
) -> Self
pub fn reasoning_message_content( message_id: impl Into<String>, delta: impl Into<String>, ) -> Self
Create a reasoning-message-content event.
Sourcepub fn reasoning_message_end(message_id: impl Into<String>) -> Self
pub fn reasoning_message_end(message_id: impl Into<String>) -> Self
Create a reasoning-message-end event.
Sourcepub fn reasoning_message_chunk(
message_id: Option<String>,
delta: Option<String>,
) -> Self
pub fn reasoning_message_chunk( message_id: Option<String>, delta: Option<String>, ) -> Self
Create a reasoning-message-chunk event.
Sourcepub fn reasoning_end(message_id: impl Into<String>) -> Self
pub fn reasoning_end(message_id: impl Into<String>) -> Self
Create a reasoning-end event.
Sourcepub fn reasoning_encrypted_value(
subtype: ReasoningEncryptedValueSubtype,
entity_id: impl Into<String>,
encrypted_value: impl Into<String>,
) -> Self
pub fn reasoning_encrypted_value( subtype: ReasoningEncryptedValueSubtype, entity_id: impl Into<String>, encrypted_value: impl Into<String>, ) -> Self
Create a reasoning-encrypted-value event.
Sourcepub fn tool_call_start(
tool_call_id: impl Into<String>,
tool_call_name: impl Into<String>,
parent_message_id: Option<String>,
) -> Self
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.
Sourcepub fn tool_call_args(
tool_call_id: impl Into<String>,
delta: impl Into<String>,
) -> Self
pub fn tool_call_args( tool_call_id: impl Into<String>, delta: impl Into<String>, ) -> Self
Create a tool-call-args event.
Sourcepub fn tool_call_end(tool_call_id: impl Into<String>) -> Self
pub fn tool_call_end(tool_call_id: impl Into<String>) -> Self
Create a tool-call-end event.
Sourcepub fn tool_call_result(
message_id: impl Into<String>,
tool_call_id: impl Into<String>,
content: impl Into<String>,
) -> Self
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.
Sourcepub fn tool_call_chunk(
tool_call_id: Option<String>,
tool_call_name: Option<String>,
parent_message_id: Option<String>,
delta: Option<String>,
) -> Self
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.
Sourcepub fn state_snapshot(snapshot: Value) -> Self
pub fn state_snapshot(snapshot: Value) -> Self
Create a state-snapshot event.
Sourcepub fn state_delta(delta: Vec<Value>) -> Self
pub fn state_delta(delta: Vec<Value>) -> Self
Create a state-delta event.
Sourcepub fn messages_snapshot(messages: Vec<Value>) -> Self
pub fn messages_snapshot(messages: Vec<Value>) -> Self
Create a messages-snapshot event.
Sourcepub fn activity_snapshot(
message_id: impl Into<String>,
activity_type: impl Into<String>,
content: HashMap<String, Value>,
replace: Option<bool>,
) -> Self
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.
Sourcepub fn activity_delta(
message_id: impl Into<String>,
activity_type: impl Into<String>,
patch: Vec<Value>,
) -> Self
pub fn activity_delta( message_id: impl Into<String>, activity_type: impl Into<String>, patch: Vec<Value>, ) -> Self
Create an activity-delta event.
Sourcepub fn with_timestamp(self, timestamp: u64) -> Self
pub fn with_timestamp(self, timestamp: u64) -> Self
Set timestamp on the event.
Sourcepub fn now_millis() -> u64
pub fn now_millis() -> u64
Get current timestamp in milliseconds.