Skip to main content
Upgrading from 0.0.x? See the 0.1.0 migration guide — schemas moved to a new subpath and zod is now an optional peer dependency.

Events

The Agent User Interaction Protocol SDK uses a streaming event-based architecture. Events are the fundamental units of communication between agents and the frontend. This section documents the event types and their properties.

EventType Enum

The EventType enum defines all possible event types in the system:

BaseEvent

All events inherit from the BaseEvent type, which provides common properties shared across all event types.

Lifecycle Events

These events represent the lifecycle of an agent run.

RunStartedEvent

Signals the start of an agent run.

RunFinishedEvent

Signals the successful completion of an agent run.

RunErrorEvent

Signals an error during an agent run.

StepStartedEvent

Signals the start of a step within an agent run.

StepFinishedEvent

Signals the completion of a step within an agent run.

Text Message Events

These events represent the lifecycle of text messages in a conversation.

TextMessageStartEvent

Signals the start of a text message.

TextMessageContentEvent

Represents a chunk of content in a streaming text message.

TextMessageEndEvent

Signals the end of a text message.

TextMessageChunkEvent

Convenience event that expands to TextMessageStartTextMessageContentTextMessageEnd automatically in the JS/TS client.
Behavior
  • Omit start/end: The client transforms chunk sequences into the standard start/content/end triad, so you don’t need to emit them manually.
  • First chunk requirements: The first chunk for a message must include messageId. When role is omitted, it defaults to assistant.
  • Streaming: Subsequent chunks with the same messageId emit TextMessageContent events. TextMessageEnd is emitted automatically when a different message starts or when the stream completes.

Tool Call Events

These events represent the lifecycle of tool calls made by agents.

ToolCallStartEvent

Signals the start of a tool call.

ToolCallArgsEvent

Represents a chunk of argument data for a tool call.

ToolCallEndEvent

Signals the end of a tool call.

ToolCallResultEvent

Provides the result of a tool call execution.

State Management Events

These events are used to manage agent state.

StateSnapshotEvent

Provides a complete snapshot of an agent’s state.

StateDeltaEvent

Provides a partial update to an agent’s state using JSON Patch.

MessagesSnapshotEvent

Provides a snapshot of all messages in a conversation.

ActivitySnapshotEvent

Delivers a complete snapshot of an activity message.

ActivityDeltaEvent

Provides incremental updates to an activity snapshot using JSON Patch.

Reasoning Events

These events represent the lifecycle of reasoning/thinking processes within an agent. Reasoning events allow agents to expose their internal thought process to the frontend, creating ReasoningMessage objects that persist in the message history with the role "reasoning".

ReasoningStartEvent

Signals the start of a reasoning phase. This is a pass-through event that notifies subscribers but does not create messages.

ReasoningMessageStartEvent

Signals the start of a reasoning message. Creates a new ReasoningMessage in the message history.

ReasoningMessageContentEvent

Represents a chunk of content in a streaming reasoning message.

ReasoningMessageEndEvent

Signals the end of a reasoning message.

ReasoningMessageChunkEvent

Convenience event that expands to ReasoningMessageStartReasoningMessageContentReasoningMessageEnd automatically in the JS/TS client.
Behavior
  • Omit start/end: The client transforms chunk sequences into the standard start/content/end triad.
  • First chunk requirements: The first chunk for a message must include messageId.
  • Streaming: Subsequent chunks with the same messageId emit ReasoningMessageContent events. ReasoningMessageEnd is emitted automatically when a different message starts or when the stream completes.

ReasoningEndEvent

Signals the end of a reasoning phase. This is a pass-through event that notifies subscribers but does not modify messages.

ReasoningEncryptedValueEvent

Attaches an encrypted value to a message or tool call. When this event is emitted, it finds the referenced entity by entityId and sets its encryptedValue field.

Special Events

RawEvent

Used to pass through events from external systems.

CustomEvent

Used for application-specific custom events.

Deprecated Events

The THINKING_* events are deprecated and will be removed in version 1.0.0. New implementations should use REASONING_* events instead.

Thinking Events (Deprecated)

The following event types are deprecated: See Reasoning Migration for detailed migration guidance.

Event validation

@ag-ui/core ships TypeScript types for every event but does not bundle a runtime schema validator in its main entry. The zod schemas live on an opt-in subpath:
zod is an optional peer dependency of @ag-ui/core/schemas. Install it explicitly if you import from this module:
If you’d rather use a different validation library, define your own schemas locally using your library of choice. The TypeScript types from @ag-ui/core are the contract.

ToolCallChunkEvent

Convenience event that expands to ToolCallStartToolCallArgsToolCallEnd automatically in the JS/TS client.
Behavior
  • Omit start/end: The client transforms chunk sequences into the standard start/args/end triad.
  • First chunk requirements: The first chunk must include both toolCallId and toolCallName; parentMessageId is propagated to ToolCallStart if given.
  • Streaming: Subsequent chunks with the same toolCallId emit ToolCallArgs. ToolCallEnd is emitted automatically when the tool call changes or when the stream completes.