AG-UI Protocol Events Reference
Quick-reference for the AG-UI (Agent-User Interaction) protocol streaming events.
When to Use This Skill
- Building a frontend that consumes streaming agent responses
- Implementing a backend endpoint that serves AG-UI events
- Debugging event ordering or missing events in streaming flows
- Understanding the event lifecycle for tool calls, text messages, or reasoning
Dependencies
| Package |
Role |
Required |
ag-ui-protocol (PyPI) |
Python event classes (Pydantic v2) — backend emission |
Yes, for a Python backend |
pydantic>=2.11.2 |
Required by ag-ui-protocol for model validation/serialization |
Yes (transitive) |
@ag-ui/core (npm) |
TypeScript event types/enums — canonical type source for frontend |
Yes, for a TS/JS frontend |
@ag-ui/client |
SSE consumer / agent runner, depends on @ag-ui/core |
Recommended |
@ag-ui/react |
React hooks (useAgentStream, useAgentState) |
Optional |
sse-starlette |
Alternative FastAPI SSE response wrapper (see backend-guide.md) |
Optional |
fast-json-patch (npm) |
Applying STATE_DELTA/ACTIVITY_DELTA RFC 6902 patches on the frontend |
Optional |
See "Verified against" below for exact versions this skill was checked against.
Official References
Verified against: ag-ui-protocol (Python) v0.1.19 — latest on PyPI as of 2026-08-02, released 2026-06-02, requires-python >=3.9, pydantic>=2.11.2 — and @ag-ui/core (TS) v0.0.57, latest on npm as of 2026-08-02. (Newer GitHub releases exist but are for adjacent framework-integration packages — CrewAI, Mastra, Strands, .NET clients — not the core protocol packages this skill documents.)
Note on "protocol version": AG-UI has no independently versioned spec — the repo's own contributor docs state "each package has independent versioning." The event names/fields are defined by whatever the reference SDKs currently implement, so the package versions above are the closest thing to a protocol version. Both are pre-1.0 — field names and event shapes can still change between minor releases; re-check sdks/python/ag_ui/core/events.py and types.py in the GitHub repo if something here looks stale.
Event Categories (28 Total)
1. Lifecycle Events (5)
Control the run boundary. RUN_STARTED/RUN_FINISHED/RUN_ERROR bound the whole agent run; STEP_STARTED/STEP_FINISHED bound each inner iteration (e.g. one LLM call). The spec doesn't mandate a specific "layer" emits each — this is the typical nesting shown in the flow diagrams below, not a protocol rule.
| Event |
Key Fields |
Typical Emitter |
When |
RUN_STARTED |
threadId, runId |
Agent |
First event of agent.stream() |
RUN_FINISHED |
threadId, runId, result, outcome? |
Agent |
Last event on success |
RUN_ERROR |
message, code |
Agent/LLM |
On unrecoverable error |
STEP_STARTED |
stepName |
LLM |
Before each LLM API call |
STEP_FINISHED |
stepName, rawEvent.usage |
LLM |
After each LLM API call (contains token usage) |
2. Text Message Events (4)
Streaming text content from the assistant.
| Event |
Key Fields |
Description |
TEXT_MESSAGE_START |
messageId, role, name? |
Opens a new text message |
TEXT_MESSAGE_CONTENT |
messageId, delta |
Incremental text chunk |
TEXT_MESSAGE_END |
messageId |
Closes the text message |
TEXT_MESSAGE_CHUNK |
messageId?, role?, delta? |
Convenience: auto-expands to Start→Content→End |
3. Tool Call Events (5)
Tool invocation lifecycle.
| Event |
Key Fields |
Description |
TOOL_CALL_START |
toolCallId, toolCallName, parentMessageId? |
Tool invocation begins |
TOOL_CALL_ARGS |
toolCallId, delta |
Streamed argument JSON fragment |
TOOL_CALL_END |
toolCallId |
Tool invocation request complete |
TOOL_CALL_CHUNK |
toolCallId?, toolCallName?, parentMessageId?, delta? |
Convenience: auto-expands to Start→Args→End |
TOOL_CALL_RESULT |
messageId, toolCallId, content, role? |
Tool execution result — no isError field; failure is reported via ToolMessage.error on the message, not this event |
4. Reasoning Events (7)
Chain-of-thought / thinking visibility.
| Event |
Key Fields |
Description |
REASONING_START |
messageId |
Reasoning phase begins |
REASONING_MESSAGE_START |
messageId, role |
Individual reasoning message starts |
REASONING_MESSAGE_CONTENT |
messageId, delta |
Reasoning text chunk |
REASONING_MESSAGE_END |
messageId |
Individual reasoning message ends |
REASONING_MESSAGE_CHUNK |
messageId?, delta? |
Convenience auto-expand |
REASONING_END |
messageId |
Reasoning phase ends |
REASONING_ENCRYPTED_VALUE |
subtype, entityId, encryptedValue |
Encrypted CoT (e.g. OpenAI o-series) |
5. State Events (3)
Synchronize agent state with the UI.
| Event |
Key Fields |
Description |
STATE_SNAPSHOT |
snapshot |
Full state object |
STATE_DELTA |
delta |
JSON Patch (RFC 6902) operations |
MESSAGES_SNAPSHOT |
messages |
Full conversation snapshot |
6. Activity Events (2)
Progress indicators for long-running operations.
| Event |
Key Fields |
Description |
ACTIVITY_SNAPSHOT |
messageId, activityType, content, replace |
Full activity state |
ACTIVITY_DELTA |
messageId, activityType, patch |
JSON Patch update |
7. Special Events (2)
| Event |
Key Fields |
Description |
RAW |
event, source? |
Pass-through from external systems |
CUSTOM |
name, value |
Application-specific events |
Event Flow Diagrams
Simple Text Response
RUN_STARTED
└── STEP_STARTED (iteration-0)
├── TEXT_MESSAGE_START
├── TEXT_MESSAGE_CONTENT (×N chunks)
├── TEXT_MESSAGE_END
└── STEP_FINISHED (iteration-0, usage in rawEvent)
RUN_FINISHED
Tool Call + Response
RUN_STARTED
└── STEP_STARTED (iteration-0)
├── TOOL_CALL_START (toolCallId, toolCallName)
├── TOOL_CALL_ARGS (delta: JSON fragments ×N)
├── TOOL_CALL_END
├── TOOL_CALL_RESULT (content)
└── STEP_FINISHED (iteration-0)
└── STEP_STARTED (iteration-1)
├── TEXT_MESSAGE_START
├── TEXT_MESSAGE_CONTENT (×N)
├── TEXT_MESSAGE_END
└── STEP_FINISHED (iteration-1)
RUN_FINISHED
With Reasoning/Thinking
RUN_STARTED
└── STEP_STARTED (iteration-0)
├── REASONING_START
├── REASONING_MESSAGE_START
├── REASONING_MESSAGE_CONTENT (×N)
├── REASONING_MESSAGE_END
├── REASONING_END
├── TEXT_MESSAGE_START
├── TEXT_MESSAGE_CONTENT (×N)
├── TEXT_MESSAGE_END
└── STEP_FINISHED (iteration-0)
RUN_FINISHED
Detailed Guides
- Event Structures Reference — JSON shapes, field types, serialization rules →
references/event-structures.md
- Frontend Integration Guide — React/TypeScript patterns, SSE consumption, state management →
references/frontend-guide.md
- Backend Integration Guide — Python emission patterns, SSE endpoints, custom events →
references/backend-guide.md
1---2name: agui-development3description: AG-UI protocol event structures, types, and integration guide for streaming agent responses. Use when implementing streaming UI, consuming AG-UI events from a backend agent, understanding event flow, building SSE endpoints that emit AG-UI events, handling tool call events, rendering reasoning/thinking events, or debugging event flow/ordering. Do NOT use for generic SSE endpoints that don't carry AG-UI events, or for MCP (tool-calling) or A2A (agent-to-agent) protocol integration — AG-UI is the agent-to-user layer only.4license: Personal use only — not for redistribution.5---67# AG-UI Protocol Events Reference89Quick-reference for the AG-UI (Agent-User Interaction) protocol streaming events.1011## When to Use This Skill1213* Building a frontend that consumes streaming agent responses14* Implementing a backend endpoint that serves AG-UI events15* Debugging event ordering or missing events in streaming flows16* Understanding the event lifecycle for tool calls, text messages, or reasoning1718## Dependencies1920| Package | Role | Required |21| --- | --- | --- |22| `ag-ui-protocol` (PyPI) | Python event classes (Pydantic v2) — backend emission | Yes, for a Python backend |23| `pydantic>=2.11.2` | Required by `ag-ui-protocol` for model validation/serialization | Yes (transitive) |24| `@ag-ui/core` (npm) | TypeScript event types/enums — canonical type source for frontend | Yes, for a TS/JS frontend |25| `@ag-ui/client` | SSE consumer / agent runner, depends on `@ag-ui/core` | Recommended |26| `@ag-ui/react` | React hooks (`useAgentStream`, `useAgentState`) | Optional |27| `sse-starlette` | Alternative FastAPI SSE response wrapper (see backend-guide.md) | Optional |28| `fast-json-patch` (npm) | Applying `STATE_DELTA`/`ACTIVITY_DELTA` RFC 6902 patches on the frontend | Optional |2930See "Verified against" below for exact versions this skill was checked against.3132## Official References3334| Resource | Link |35| :--- | :--- |36| **AG-UI Protocol (GitHub)** | https://github.com/ag-ui-protocol/ag-ui |37| **AG-UI Documentation** | https://docs.ag-ui.com |38| **AG-UI Python SDK** | https://pypi.org/project/ag-ui-protocol |39| **AG-UI Core Types (TS)** | https://www.npmjs.com/package/@ag-ui/core |40| **AG-UI TypeScript SDK** | https://www.npmjs.com/package/@ag-ui/client |4142**Verified against:** `ag-ui-protocol` (Python) v0.1.19 — latest on PyPI as of 2026-08-02, released 2026-06-02, `requires-python >=3.9`, `pydantic>=2.11.2` — and `@ag-ui/core` (TS) v0.0.57, latest on npm as of 2026-08-02. (Newer GitHub releases exist but are for adjacent framework-integration packages — CrewAI, Mastra, Strands, .NET clients — not the core protocol packages this skill documents.)4344**Note on "protocol version":** AG-UI has no independently versioned spec — the repo's own contributor docs state "each package has independent versioning." The event names/fields are defined by whatever the reference SDKs currently implement, so the package versions above *are* the closest thing to a protocol version. Both are pre-1.0 — field names and event shapes can still change between minor releases; re-check `sdks/python/ag_ui/core/events.py` and `types.py` in the GitHub repo if something here looks stale.4546---4748## Event Categories (28 Total)4950### 1. Lifecycle Events (5)5152Control the run boundary. `RUN_STARTED`/`RUN_FINISHED`/`RUN_ERROR` bound the whole agent run; `STEP_STARTED`/`STEP_FINISHED` bound each inner iteration (e.g. one LLM call). The spec doesn't mandate a specific "layer" emits each — this is the typical nesting shown in the flow diagrams below, not a protocol rule.5354| Event | Key Fields | Typical Emitter | When |55| :--- | :--- | :--- | :--- |56| `RUN_STARTED` | `threadId`, `runId` | Agent | First event of `agent.stream()` |57| `RUN_FINISHED` | `threadId`, `runId`, `result`, `outcome?` | Agent | Last event on success |58| `RUN_ERROR` | `message`, `code` | Agent/LLM | On unrecoverable error |59| `STEP_STARTED` | `stepName` | LLM | Before each LLM API call |60| `STEP_FINISHED` | `stepName`, `rawEvent.usage` | LLM | After each LLM API call (contains token usage) |6162### 2. Text Message Events (4)6364Streaming text content from the assistant.6566| Event | Key Fields | Description |67| :--- | :--- | :--- |68| `TEXT_MESSAGE_START` | `messageId`, `role`, `name?` | Opens a new text message |69| `TEXT_MESSAGE_CONTENT` | `messageId`, `delta` | Incremental text chunk |70| `TEXT_MESSAGE_END` | `messageId` | Closes the text message |71| `TEXT_MESSAGE_CHUNK` | `messageId?`, `role?`, `delta?` | Convenience: auto-expands to Start→Content→End |7273### 3. Tool Call Events (5)7475Tool invocation lifecycle.7677| Event | Key Fields | Description |78| :--- | :--- | :--- |79| `TOOL_CALL_START` | `toolCallId`, `toolCallName`, `parentMessageId?` | Tool invocation begins |80| `TOOL_CALL_ARGS` | `toolCallId`, `delta` | Streamed argument JSON fragment |81| `TOOL_CALL_END` | `toolCallId` | Tool invocation request complete |82| `TOOL_CALL_CHUNK` | `toolCallId?`, `toolCallName?`, `parentMessageId?`, `delta?` | Convenience: auto-expands to Start→Args→End |83| `TOOL_CALL_RESULT` | `messageId`, `toolCallId`, `content`, `role?` | Tool execution result — **no `isError` field**; failure is reported via `ToolMessage.error` on the message, not this event |8485### 4. Reasoning Events (7)8687Chain-of-thought / thinking visibility.8889| Event | Key Fields | Description |90| :--- | :--- | :--- |91| `REASONING_START` | `messageId` | Reasoning phase begins |92| `REASONING_MESSAGE_START` | `messageId`, `role` | Individual reasoning message starts |93| `REASONING_MESSAGE_CONTENT` | `messageId`, `delta` | Reasoning text chunk |94| `REASONING_MESSAGE_END` | `messageId` | Individual reasoning message ends |95| `REASONING_MESSAGE_CHUNK` | `messageId?`, `delta?` | Convenience auto-expand |96| `REASONING_END` | `messageId` | Reasoning phase ends |97| `REASONING_ENCRYPTED_VALUE` | `subtype`, `entityId`, `encryptedValue` | Encrypted CoT (e.g. OpenAI o-series) |9899### 5. State Events (3)100101Synchronize agent state with the UI.102103| Event | Key Fields | Description |104| :--- | :--- | :--- |105| `STATE_SNAPSHOT` | `snapshot` | Full state object |106| `STATE_DELTA` | `delta` | JSON Patch (RFC 6902) operations |107| `MESSAGES_SNAPSHOT` | `messages` | Full conversation snapshot |108109### 6. Activity Events (2)110111Progress indicators for long-running operations.112113| Event | Key Fields | Description |114| :--- | :--- | :--- |115| `ACTIVITY_SNAPSHOT` | `messageId`, `activityType`, `content`, `replace` | Full activity state |116| `ACTIVITY_DELTA` | `messageId`, `activityType`, `patch` | JSON Patch update |117118### 7. Special Events (2)119120| Event | Key Fields | Description |121| :--- | :--- | :--- |122| `RAW` | `event`, `source?` | Pass-through from external systems |123| `CUSTOM` | `name`, `value` | Application-specific events |124125---126127## Event Flow Diagrams128129### Simple Text Response130131```text132RUN_STARTED133└── STEP_STARTED (iteration-0)134 ├── TEXT_MESSAGE_START135 ├── TEXT_MESSAGE_CONTENT (×N chunks)136 ├── TEXT_MESSAGE_END137 └── STEP_FINISHED (iteration-0, usage in rawEvent)138RUN_FINISHED139140```141142### Tool Call + Response143144```text145RUN_STARTED146└── STEP_STARTED (iteration-0)147 ├── TOOL_CALL_START (toolCallId, toolCallName)148 ├── TOOL_CALL_ARGS (delta: JSON fragments ×N)149 ├── TOOL_CALL_END150 ├── TOOL_CALL_RESULT (content)151 └── STEP_FINISHED (iteration-0)152└── STEP_STARTED (iteration-1)153 ├── TEXT_MESSAGE_START154 ├── TEXT_MESSAGE_CONTENT (×N)155 ├── TEXT_MESSAGE_END156 └── STEP_FINISHED (iteration-1)157RUN_FINISHED158159```160161### With Reasoning/Thinking162163```text164RUN_STARTED165└── STEP_STARTED (iteration-0)166 ├── REASONING_START167 ├── REASONING_MESSAGE_START168 ├── REASONING_MESSAGE_CONTENT (×N)169 ├── REASONING_MESSAGE_END170 ├── REASONING_END171 ├── TEXT_MESSAGE_START172 ├── TEXT_MESSAGE_CONTENT (×N)173 ├── TEXT_MESSAGE_END174 └── STEP_FINISHED (iteration-0)175RUN_FINISHED176177```178179---180181## Detailed Guides182183* **Event Structures Reference** — JSON shapes, field types, serialization rules → `references/event-structures.md`184* **Frontend Integration Guide** — React/TypeScript patterns, SSE consumption, state management → `references/frontend-guide.md`185* **Backend Integration Guide** — Python emission patterns, SSE endpoints, custom events → `references/backend-guide.md`