AG-UI: The Missing Protocol Between AI Agents and Your Frontend
AG-UI (Agent User Interaction Protocol) is an open, event-based protocol that standardizes how AI agents communicate with user-facing applications. Created by CopilotKit and adopted by Microsoft, Google, AWS, LangChain, and CrewAI, it fills the gap between MCP (agent↔tools) and A2A (agent↔agent) by defining the agent↔UI layer. It's MIT licensed with 14.4k GitHub stars and 50+ framework integrations.
The Problem
Traditional REST and GraphQL APIs assume request-response cycles with deterministic outputs. AI agents break all of those assumptions:
- Long-running — agents stream intermediate work over seconds or minutes, not milliseconds.
- Non-deterministic — an agent may produce different UI artifacts on each run, making static schemas fragile.
- Mixed output — a single agent turn can emit plain text, structured tool calls, state mutations, and reasoning traces.
- Human-in-the-loop — agents need to pause, ask for confirmation, and resume based on user decisions.
You can hack around these with ad-hoc WebSocket messages, but then every agent framework invents its own wire format and every frontend rebuilds the same parsing logic. AG-UI standardizes that layer.
How It Works: Events All the Way Down
The protocol models all agent→client communication as a typed event stream. The core abstraction is minimal:
type RunAgent = (input: RunAgentInput) => Observable<BaseEvent>
About 16 event types are organized into categories:
- Lifecycle —
RUN_STARTED,RUN_FINISHED,RUN_ERROR - Text Messages —
TEXT_MESSAGE_START,TEXT_MESSAGE_CONTENT,TEXT_MESSAGE_END - Tool Calls —
TOOL_CALL_START,TOOL_CALL_ARGS,TOOL_CALL_END - State —
STATE_SNAPSHOT,STATE_DELTA - Activity —
STEP_STARTED,STEP_FINISHED - Reasoning —
CUSTOMevents for chain-of-thought traces
Two patterns recur throughout:
- Start-Content-End — text and tool calls arrive in streaming chunks, bracketed by lifecycle events. Clients can render progressively.
- Snapshot-Delta — state is initialized with a full snapshot, then updated incrementally via JSON Patch (RFC 6902). This keeps bandwidth low while maintaining consistency.
The protocol is transport-agnostic — SSE, WebSockets, binary frames, or webhooks all work. The events are the contract, not the transport.
Where AG-UI Fits in the Protocol Stack
AG-UI doesn't replace MCP or A2A — it's the missing third layer:
┌─────────────────────────────────────────────────┐
│ A2A (Google) Agent ↔ Agent coordination │
├─────────────────────────────────────────────────┤
│ MCP (Anthropic) Agent ↔ Tools & Data │
├─────────────────────────────────────────────────┤
│ AG-UI (CopilotKit) Agent ↔ User Interface │
