Module 01 · Core Architecture, Event Streams & Bidirectional State
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> .
Each open protocol standardizes one distinct boundary so agent systems stay modular and interoperable.
| Protocol | Boundary | Primary Responsibility |
|---|---|---|
| AG-UI | Agent ↔ User UI | Streams typed lifecycle events, assistant text deltas, tool calls, interrupts, and bidirectional shared state between backend agents and frontend apps. |
| MCP | Agent ↔ Tools & Data | Model Context Protocol standardizes how an agent discovers and invokes backend databases, APIs, resources, and local or remote tool servers. |
| A2A | Agent ↔ Agent | Agent-to-Agent protocol enables discovery, task delegation, and peer-to-peer coordination across autonomous backend agents. |
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_SNAPSHOT vs. STATE_DELTAAG-UI balances reliability and bandwidth by pairing full baselines with atomic RFC 6902 JSON Patches.
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": []
}
} 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/-" }
]
} 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.
Explore the official AG-UI event schemas, transport specs, and framework SDK adapters:
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?