Skip to main content

Events

The Agent User Interaction Protocol Python 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

from ag_ui.core import EventType The EventType enum defines all possible event types in the system:

BaseEvent

from ag_ui.core import BaseEvent All events inherit from the BaseEvent class, which provides common properties shared across all event types.

Lifecycle Events

These events represent the lifecycle of an agent run.

RunStartedEvent

from ag_ui.core import RunStartedEvent Signals the start of an agent run.

RunFinishedEvent

from ag_ui.core import RunFinishedEvent Signals the successful completion of an agent run.

RunErrorEvent

from ag_ui.core import RunErrorEvent Signals an error during an agent run.

StepStartedEvent

from ag_ui.core import StepStartedEvent Signals the start of a step within an agent run.

StepFinishedEvent

from ag_ui.core import 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

from ag_ui.core import TextMessageStartEvent Signals the start of a text message.

TextMessageContentEvent

from ag_ui.core import TextMessageContentEvent Represents a chunk of content in a streaming text message.

TextMessageEndEvent

from ag_ui.core import TextMessageEndEvent Signals the end of a text message.

Tool Call Events

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

ToolCallStartEvent

from ag_ui.core import ToolCallStartEvent Signals the start of a tool call.

ToolCallArgsEvent

from ag_ui.core import ToolCallArgsEvent Represents a chunk of argument data for a tool call.

ToolCallEndEvent

from ag_ui.core import ToolCallEndEvent Signals the end of a tool call.

State Management Events

These events are used to manage agent state.

StateSnapshotEvent

from ag_ui.core import StateSnapshotEvent Provides a complete snapshot of an agent’s state.

StateDeltaEvent

from ag_ui.core import StateDeltaEvent Provides a partial update to an agent’s state using JSON Patch.

MessagesSnapshotEvent

from ag_ui.core import MessagesSnapshotEvent Provides a snapshot of all messages in a conversation.

Special Events

RawEvent

from ag_ui.core import RawEvent Used to pass through events from external systems.

CustomEvent

from ag_ui.core import CustomEvent Used for application-specific custom events.

Event Discrimination

from ag_ui.core import Event The SDK uses Pydantic’s discriminated unions for event validation:
This allows for runtime validation of events and type checking at development time.