Mastery: 0 / 3

AG-UI Protocol Mastery

Module 01 · Core Architecture, Event Streams & Bidirectional State

Nuxt 4 + Nuxt UI
Module 01 · Architectural Primer

Why Agentic Apps Break Request–Response APIs

Classic REST and GraphQL endpoints assume a short, deterministic request–response cycle. AI agents violate those assumptions simultaneously, requiring an event-driven interaction layer: run(input: RunAgentInput) → Observable<BaseEvent> .

01 / TEMPORAL
Long-Running & Asynchronous
Multi-step reasoning and tool calls span seconds to minutes, requiring continuous incremental events rather than a single blocking HTTP response.
02 / STOCHASTIC
Nondeterministic Execution
Within one runId, an agent may stream prose, invoke tools, pause for human approval, or retry on error in an unpredictable sequence.
03 / MULTIMODAL IO
Mixed Structured & Unstructured
Agentic UIs interleave unstructured token streams (TEXT_MESSAGE_CONTENT) with typed state patches (STATE_DELTA) and tool calls concurrently.
04 / HIERARCHICAL
Recursive Sub-Agents
Orchestrator agents delegate sub-tasks to specialist sub-agents whose steps, state updates, and interrupts must bubble cleanly to the UI.

The 3-Protocol Agentic Stack

Each open protocol standardizes one distinct boundary so agent systems stay modular and interoperable.

ProtocolBoundaryPrimary Responsibility
AG-UIAgent ↔ User UIStreams typed lifecycle events, assistant text deltas, tool calls, interrupts, and bidirectional shared state between backend agents and frontend apps.
MCPAgent ↔ Tools & DataModel Context Protocol standardizes how an agent discovers and invokes backend databases, APIs, resources, and local or remote tool servers.
A2AAgent ↔ AgentAgent-to-Agent protocol enables discovery, task delegation, and peer-to-peer coordination across autonomous backend agents.
A2UI vs. AG-UI
AG-UI is the bidirectional event & state transport protocol between agent and frontend. A2UI is a declarative Generative UI specification carried over AG-UI streams so agents can render rich native widgets.

State Synchronization: STATE_SNAPSHOT vs. STATE_DELTA

AG-UI balances reliability and bandwidth by pairing full baselines with atomic RFC 6902 JSON Patches.

Full Baseline Replacement STATE_SNAPSHOT

Emitted on initial connection, after network reconnects, or as a recovery fallback whenever a patch fails.

{
  "type": "STATE_SNAPSHOT",
  "snapshot": {
    "status": "analyzing",
    "progress": 20,
    "pending_items": ["Verify invoice #882"],
    "completed_items": []
  }
}
Atomic Incremental Patch STATE_DELTA (RFC 6902)

Applies ordered ops (add, replace, remove, move, copy, test) atomically on an immutable clone.

{
  "type": "STATE_DELTA",
  "delta": [
    { "op": "replace", "path": "/status", "value": "review" },
    { "op": "move", "from": "/pending_items/0", "path": "/completed_items/-" }
  ]
}

Human-in-the-Loop (HITL) Shared State

Because state flows bidirectionally, an agent can write a proposed action (such as an invoice approval or email draft) into shared state via STATE_DELTA and pause. The user inspects, edits, or approves it directly in the UI, and the updated state returns inside RunAgentInput.state on the next turn.

Guardrail: Keep shared state flat and domain-focused; never store API secrets or credentials in shared state.

Primary Protocol Documentation

Explore the official AG-UI event schemas, transport specs, and framework SDK adapters:

RETRIEVAL PRACTICE

Module 01 Mastery Check

Score: 0 / 3

1. Which protocol boundary is AG-UI specifically designed to standardize in a multi-protocol agentic stack?

2. What must a client do when an RFC 6902 STATE_DELTA fails mid-array (for example, on an invalid path or failed test op)?

3. How does AG-UI enable a Human-in-the-Loop (HITL) approval workflow using shared state?

Delta ↔ StreamingHITL ↔ ToolsA2UI ↔ HandoffAG-UIArchitectureBidirectionalTransportSSEProtobufEventsLifecycleStreamingStateSnapshotDeltaRFC-6902AtomicToolsHITLHandoffStackMCPA2AA2UI
Click any node to inspect · Drag canvas to pan
Root Priority Concept

AG-UI

Agent–User Interaction Protocol: an open, lightweight, event-driven standard connecting backend AI agents to interactive frontends.

Protocol / Wire Signature
run(input: RunAgentInput) → Observable<BaseEvent>
Engineering Tip
Use AG-UI whenever an agent run streams partial outputs, exposes tool execution, or shares mutable UI state with a user.
Associative Cross-Links:
Wire: 0 B

1. RunAgentInput (Editable)

POST /agent

Edit initial JSON state, then click Step or Play Stream.

2. Event Stream (SSE)

0 events
Click "Play Stream" or "Step" to observe live AG-UI wire frames.

3. Live Shared State

Immutable
// State awaits STATE_SNAPSHOT…