Events
AG-UI uses a streaming event-based architecture. Events are the units of communication from an agent backend to a frontend UI. In .NET, every protocol event derives fromBaseEvent and has a type discriminator.
Event Type Constants
AGUIEventTypes defines the SCREAMING_SNAKE_CASE wire discriminators:
BaseEvent
All events inherit fromBaseEvent.
| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | string | Event discriminator |
Timestamp | timestamp | long? | Optional event timestamp |
RawEvent | rawEvent | JsonElement? | Optional original event data |
Lifecycle Events
Lifecycle events represent the run and step lifecycle.RunStartedEvent
Signals the start of an agent run.| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "RUN_STARTED" | Event discriminator |
ThreadId | threadId | string | Conversation thread ID |
RunId | runId | string | Agent run ID |
ParentRunId | parentRunId | string? | Optional parent run ID |
Input | input | RunAgentInput? | Optional input payload for the run |
RunFinishedEvent
Signals the completion of an agent run.| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "RUN_FINISHED" | Event discriminator |
ThreadId | threadId | string | Conversation thread ID |
RunId | runId | string | Agent run ID |
Result | result | JsonElement? | Optional run result |
Outcome | outcome | RunFinishedOutcome? | Optional typed outcome |
RunFinishedOutcome is a polymorphic value with type: "success" or
type: "interrupt". RunFinishedInterruptOutcome carries interrupts, an
IList<AGUIInterrupt>.
RunErrorEvent
Signals an error during an agent run.| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "RUN_ERROR" | Event discriminator |
Message | message | string | Error message |
Code | code | string? | Optional error code |
StepStartedEvent
Signals the start of a named step.| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "STEP_STARTED" | Event discriminator |
StepName | stepName | string | Step name |
StepFinishedEvent
Signals the completion of a named step.| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "STEP_FINISHED" | Event discriminator |
StepName | stepName | string | Step name |
Text Message Events
Text message events stream assistant text as a start/content/end sequence.TextMessageStartEvent
| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "TEXT_MESSAGE_START" | Event discriminator |
MessageId | messageId | string | Message ID |
Role | role | string | Message role, typically "assistant" |
Name | name | string? | Optional sender name |
TextMessageContentEvent
| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "TEXT_MESSAGE_CONTENT" | Event discriminator |
MessageId | messageId | string | Message ID from the start event |
Delta | delta | string | Text delta |
TextMessageEndEvent
| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "TEXT_MESSAGE_END" | Event discriminator |
MessageId | messageId | string | Message ID from the start event |
Tool Call Events
Tool call events stream tool invocation arguments and optional server-side results.ToolCallStartEvent
| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "TOOL_CALL_START" | Event discriminator |
ParentMessageId | parentMessageId | string? | Optional parent assistant message ID |
ToolCallId | toolCallId | string | Tool call ID |
ToolCallName | toolCallName | string | Tool name |
ToolCallArgsEvent
| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "TOOL_CALL_ARGS" | Event discriminator |
ToolCallId | toolCallId | string | Tool call ID |
Delta | delta | string | Argument JSON chunk |
ToolCallEndEvent
| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "TOOL_CALL_END" | Event discriminator |
ToolCallId | toolCallId | string | Tool call ID |
ToolCallResultEvent
| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "TOOL_CALL_RESULT" | Event discriminator |
MessageId | messageId | string | Tool result message ID |
ToolCallId | toolCallId | string | Tool call ID |
Content | content | string | Tool result content |
Role | role | string? | Optional role, typically "tool" |
State Management Events
State events synchronize frontend state and message history.StateSnapshotEvent
Provides a complete state snapshot.| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "STATE_SNAPSHOT" | Event discriminator |
Snapshot | snapshot | JsonElement | Complete state value |
StateDeltaEvent
Provides incremental state changes, commonly as JSON Patch operations.| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "STATE_DELTA" | Event discriminator |
Delta | delta | JsonElement | State delta payload |
MessagesSnapshotEvent
Replaces the frontend conversation history with the server’s view.| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "MESSAGES_SNAPSHOT" | Event discriminator |
Messages | messages | IList<AGUIMessage> | Complete message list |
Reasoning Events
Reasoning events expose a model or agent reasoning stream. They can create and updateAGUIReasoningMessage entries in message history.
ReasoningStartEvent
| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "REASONING_START" | Event discriminator |
MessageId | messageId | string | Reasoning phase ID |
ReasoningMessageStartEvent
| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "REASONING_MESSAGE_START" | Event discriminator |
MessageId | messageId | string | Reasoning message ID |
Role | role | string | Defaults to "reasoning" |
ReasoningMessageContentEvent
| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "REASONING_MESSAGE_CONTENT" | Event discriminator |
MessageId | messageId | string | Reasoning message ID |
Delta | delta | string | Reasoning content delta |
ReasoningMessageEndEvent
| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "REASONING_MESSAGE_END" | Event discriminator |
MessageId | messageId | string | Reasoning message ID |
ReasoningMessageChunkEvent
Compact reasoning message chunk event with optional fields.| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "REASONING_MESSAGE_CHUNK" | Event discriminator |
MessageId | messageId | string? | Optional reasoning message ID |
Delta | delta | string? | Optional reasoning content delta |
ReasoningEndEvent
| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "REASONING_END" | Event discriminator |
MessageId | messageId | string | Reasoning phase ID |
ReasoningEncryptedValueEvent
Attaches an encrypted value to a message or tool call.| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "REASONING_ENCRYPTED_VALUE" | Event discriminator |
Subtype | subtype | string | Entity subtype, such as "message" or "tool-call" |
EntityId | entityId | string | Message or tool call ID |
EncryptedValue | encryptedValue | string | Opaque encrypted value |
Activity Events
Activity events carry structured progress state for UI renderers.ActivitySnapshotEvent
| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "ACTIVITY_SNAPSHOT" | Event discriminator |
MessageId | messageId | string | Activity message ID |
ActivityType | activityType | string | Activity discriminator |
Content | content | JsonElement | Structured activity content |
Replace | replace | bool? | Optional replace/merge hint |
ActivityDeltaEvent
| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "ACTIVITY_DELTA" | Event discriminator |
MessageId | messageId | string | Activity message ID |
ActivityType | activityType | string | Activity discriminator |
Patch | patch | JsonElement | Activity JSON Patch payload |
Special Events
RawEvent
Passes through unprocessed external data.| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "RAW" | Event discriminator |
Event | event | JsonElement | Raw payload |
Source | source | string? | Optional source identifier |
CustomEvent
Carries application-specific data.| C# property | JSON field | Type | Description |
|---|---|---|---|
Type | type | "CUSTOM" | Event discriminator |
Name | name | string | Custom event name |
Value | value | JsonElement? | Optional custom payload |
Serialization
BaseEvent uses a discriminator-based JSON converter keyed on the type field.
All concrete event types are registered in AGUIJsonSerializerContext.