Skip to main content

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.

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.

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.

Special Events

RawEvent

Used to pass through events from external systems.

CustomEvent

Used for application-specific custom events.

Event Schemas

The SDK uses Zod schemas to validate events:
This allows for runtime validation of events and provides TypeScript type inference.