AG-UI Protocol Architecture Diagram: Connecting AI Agents to Frontends (2026)
How to draw an AG-UI (Agent-User Interaction Protocol) architecture diagram. Learn the core components — frontend clients, agent backends, event streams, state sync, and human-in-the-loop — and generate accurate AG-UI diagrams from plain English in seconds.
An AG-UI architecture diagram visualizes how an AI agent's backend logic connects to the user-facing application that people actually interact with. AG-UI (the Agent-User Interaction Protocol) is an open, lightweight, event-based protocol — originated by the CopilotKit team and now maintained as an independent open-source project — that standardizes how an agent backend streams its work to a frontend: token-by-token text, tool-call progress, state updates, and requests for human approval, all delivered as a typed event stream over a standard transport like Server-Sent Events (SSE) or WebSockets.
Before AG-UI, every team building an agentic product had to invent its own way of wiring an agent framework (LangGraph, CrewAI, a custom Python service) to a React or Next.js frontend — usually a bespoke mix of polling, ad hoc SSE payloads, and manual state reconciliation. AG-UI gives that wiring a name and a shape. Diagramming your AG-UI setup matters for the same reasons diagramming MCP or A2A matters: it makes the run-time contract between backend and frontend explicit for design reviews, onboarding, and debugging why the UI fell out of sync with the agent. This guide covers the core components of an AG-UI architecture, the most common integration patterns, and ready-to-use prompt templates for generating accurate AG-UI diagrams in seconds.
What is AG-UI and why diagram it?
Most discussions of the AI agent protocol stack focus on how agents reach outward — to tools (MCP) or to other agents (A2A). AG-UI covers the other direction: how an agent reaches a human. It answers a deceptively hard question — once an agent is doing multi-step, long-running, possibly asynchronous work, how does a web or mobile frontend show that work happening in real time, let the user interrupt or approve it, and stay in sync with whatever state the agent is building up — without the frontend team reverse-engineering the backend's internals?
AG-UI answers this with a single convention: the frontend sends the agent backend an HTTP request carrying the user's message and any relevant state, then keeps a connection open and reads a stream of small, typed JSON events describing what the agent does next. Because the event vocabulary is standardized rather than framework-specific, the same frontend code can render output from a LangGraph agent today and a CrewAI crew tomorrow. That decoupling — and the fact that a single product can combine several agent backends behind one interface — is exactly why an AG-UI setup deserves its own diagram rather than being treated as a footnote on a generic "API call" arrow.
The core components of an AG-UI architecture
Frontend client
The frontend client is the user-facing application — a web app, admin dashboard, or embedded chat widget. It holds an AG-UI client library (CopilotKit's React SDK is the most common implementation, though the protocol itself is framework-agnostic) that knows how to open a connection to an agent's run endpoint, parse the incoming event stream, and update the UI as events arrive. The client is also responsible for sending events back upstream: user messages, approvals or rejections during a human-in-the-loop pause, and any local state the agent needs to see.
Agent backend (the run endpoint)
The agent backend is wherever the actual agent logic lives — a LangGraph graph, a CrewAI crew, a custom agent loop, or a managed agent runtime such as AWS Bedrock AgentCore. It exposes a single HTTP endpoint (often called a "run" endpoint) that accepts the frontend's request and, instead of returning one JSON blob, keeps the connection open and emits a sequence of events as the agent thinks, calls tools, and produces output. Most agent frameworks reach AG-UI compliance through a thin adapter layer that translates the framework's internal callbacks into the standard AG-UI event vocabulary, which is what lets a dozen different frameworks all speak the same protocol to the frontend.
Event stream and transport
AG-UI is transport-agnostic in principle, but the reference implementation and most production deployments use HTTP POST + Server-Sent Events: the frontend issues a single POST request with the user's prompt and current state, and the response body is a long-lived SSE stream of events rather than a single payload. WebSockets are also supported where bidirectional, lower- latency delivery is preferred. SSE is the more common default because it rides on plain HTTP and passes through existing firewalls, proxies, and CDNs without special-casing — an important property for teams deploying agent backends behind the same infrastructure as the rest of their API surface.
Event categories
Rather than one generic "update" message, AG-UI defines a vocabulary of typed events grouped into a handful of categories. Your diagram doesn't need to enumerate every event type, but it should show which categories flow across the connection:
- Lifecycle events: Mark the start and end of an agent run, so the frontend knows when to show a "thinking" state and when the turn is complete.
- Text message events: Stream the agent's natural-language response incrementally, token by token, so text appears in the UI as it's generated rather than all at once.
- Tool call events: Signal that the agent is invoking a tool, stream the arguments as they're constructed, and report when the call completes — letting the frontend show live "calling search_flights…" style progress indicators.
- State events: Carry updates to a shared state object (full snapshots or incremental patches) that both the agent and the frontend read from, which is what keeps a rendered dashboard or form in sync with what the agent believes is true.
- Generative UI / custom events: Carry structured, application-specific payloads that tell the frontend which UI component to render and with what data, rather than just text.
State synchronization
Many agent workflows involve state that outlives a single message — a multi-step form, a shopping cart, a document being edited collaboratively by the user and the agent. AG-UI keeps this in sync by letting the backend emit a state snapshot up front and incremental patch-style updates afterward, so the frontend never has to guess what changed. A good diagram should show this shared state as its own node or store, with the agent backend and the frontend both reading from and writing to it, rather than implying that state only lives inside chat messages.
Human-in-the-loop interrupts
For actions with real consequences — sending an email, executing a trade, deleting a record — the agent backend can pause mid-run and emit an event asking the human to approve, reject, or modify the proposed action before execution continues. The frontend renders this as a confirmation UI and sends the human's decision back over the same connection, at which point the agent resumes. This pause-and-resume boundary is one of the most important things to make explicit in an AG-UI diagram, since it's the control point where a human, not the model, has final authority.
Generative UI
Instead of only returning text, an AG-UI-connected agent can direct the frontend to render a specific interactive component — a chart, a booking form, an approval card — based on what it decides the user needs. The frontend maintains a registry of components it knows how to render for a given event payload; the agent picks which one to invoke and with what data. On a diagram, this shows up as a distinct arrow from the agent backend into a "component registry" or "UI renderer" inside the frontend, separate from the plain-text message path.
Common AG-UI patterns
Embedded copilot
The most common pattern: an existing SaaS product adds a chat sidebar or popup backed by an AG-UI-compliant agent. The frontend embeds a copilot component (frequently via CopilotKit) that opens an AG-UI connection to a single agent backend scoped to that product's domain — for example, a project-management app wiring a copilot that can read and update the current project's tasks through shared state.
Generative UI dashboard
An analytics or ops product lets an agent decide which visualization best answers a user's question — a table, a trend chart, a summary card — and renders it live via generative UI events rather than pre-building every possible view. The diagram should show the frontend's component registry as a first-class node, since it's what turns agent output into pixels.
Human-in-the-loop approval workflow
A support-automation or finance agent drafts an action — a refund, an email reply, a ledger adjustment — and the AG-UI connection pauses on an interrupt event until a human reviewer approves it in the frontend. The diagram should mark this as a synchronous checkpoint, distinct from the otherwise continuous streaming flow.
Multi-backend fan-in
Because AG-UI is a protocol rather than a specific framework's SDK, one frontend can consume event streams from several different agent backends built on different frameworks — a LangGraph pipeline handling retrieval, a CrewAI crew handling a delegated subtask — and render them through the same UI, since both emit the same AG-UI event vocabulary. The diagram should show the frontend as a single consumer fanning in from multiple, independently-deployed agent backends.
Full agentic protocol stack
In a mature deployment, all three major agent protocols show up together: the agent backend uses MCP to call external tools, uses A2A to delegate part of the task to a separate agent service, and uses AG-UI to stream all of that activity — including the sub-agent's progress — back to the human through the frontend. A complete diagram of such a system should show all three protocol boundaries distinctly rather than collapsing them into a single generic "backend" box.
Prompt templates for AG-UI diagrams
Basic embedded copilot
Human-in-the-loop support agent
Generative UI analytics dashboard
Full protocol stack: AG-UI + MCP + A2A
AG-UI event category reference
| Event category | Purpose | What the frontend does with it |
|---|---|---|
| Lifecycle | Marks the start and end of an agent run | Shows/hides loading state, marks the turn complete |
| Text message | Streams natural-language response content incrementally | Appends streamed tokens to the visible chat message |
| Tool call | Signals a tool invocation, its arguments, and its result | Renders a live "calling X…" progress indicator |
| State (snapshot / delta) | Carries a full or incremental update to shared agent state | Applies the update to the local state store the UI reads from |
| Generative UI / custom | Carries an application-specific payload naming a UI component | Looks up the component in its registry and renders it with the given data |
| Human-in-the-loop / interrupt | Pauses the run to request human approval, rejection, or edits | Renders an approval UI and sends the human's decision back upstream |
What a good AG-UI architecture diagram must show
An AG-UI diagram is more than a "frontend talks to backend" arrow. To be useful for engineering reviews and incident debugging, it must make the following explicit:
- Frontend / agent backend boundary: Show the client application and the agent backend as distinct nodes, with the run endpoint clearly marked as the entry point between them.
- Transport: Label the connection with its transport — HTTP+SSE or WebSocket — since that determines infrastructure requirements like proxy timeouts and connection-keepalive settings.
- Event categories in play: Show which categories of events actually flow on the connection (text, tool call, state, generative UI, interrupts) rather than a single unlabeled "events" arrow — this is what tells a reviewer what the UI is capable of reacting to.
- Shared state store: If the agent and frontend synchronize state, show that state as its own node that both sides read from and write to, rather than implying it only lives inside chat history.
- Human-in-the-loop checkpoints: Mark any point where the agent pauses for human approval as an explicit synchronous checkpoint, since this is the primary place a human retains control over consequential actions.
- Relationship to MCP and A2A: If the agent backend also calls tools via MCP or delegates to other agents via A2A, show those as separate protocol boundaries feeding into the same backend, so the diagram communicates the full agentic stack rather than just the human-facing slice.
Common mistakes in AG-UI architecture design
- Treating the event stream as a black box in the diagram — labeling it just "streaming response" hides the state-sync and interrupt behavior that actually determines how the UI behaves
- Skipping the shared-state node — teams that only diagram chat messages miss the fact that generative UI and dashboard patterns depend on state that outlives any single message
- No timeout or reconnect handling shown for long-lived SSE connections — proxies and load balancers often have default idle timeouts shorter than a long agent run
- Missing the human-in-the-loop checkpoint entirely — for any agent that can take consequential actions, the approval boundary is a security and compliance detail, not an implementation footnote
- Assuming one frontend maps to one agent backend — multi-backend fan-in (different frameworks emitting the same AG-UI events) is increasingly common and should be shown explicitly if it applies
Frequently asked questions about AG-UI architecture diagrams
What is the AG-UI protocol?
AG-UI (the Agent-User Interaction Protocol) is an open, event-based protocol that standardizes how an AI agent's backend streams its work to a user-facing frontend. Instead of returning a single response, the agent backend emits a sequence of typed JSON events — streaming text, tool-call progress, state updates, and human-in-the-loop pause requests — typically over HTTP with Server-Sent Events. It originated from CopilotKit's work connecting agent frameworks to React frontends and has since been adopted as a framework-agnostic open standard.
How is AG-UI different from MCP and A2A?
The three protocols solve different connection problems in the agent stack. MCP connects an agent to tools and data sources — it's how the agent reads a file or calls an API. A2A connects an agent to other agents — it's how one agent delegates a task to another and gets results back. AG-UI connects an agent to the human using it — it's how the agent's progress, output, and requests for approval reach a user-facing application. A single production system can use all three simultaneously: MCP for tool access, A2A for delegating to specialist agents, and AG-UI for streaming the whole thing to the frontend the user actually sees.
How do I diagram AG-UI event streaming?
Show the frontend and the agent backend as separate nodes connected by a single labeled transport (HTTP+SSE or WebSocket). On that connection, annotate which categories of events actually flow — text message, tool call, state, generative UI, human-in-the-loop — rather than drawing one generic arrow. If state is synchronized between the two sides, add a shared state node that both the agent and frontend read from and write to. If the workflow includes an approval step, mark it as a distinct checkpoint on the connection. For systems that also use MCP or A2A, show those as separate protocol boundaries feeding into the agent backend so a reviewer can see the complete picture in one diagram.
Do I need CopilotKit to use AG-UI?
No. CopilotKit is the project that originated AG-UI and remains its most mature client implementation, but AG-UI itself is an open protocol with its own specification, and multiple agent frameworks (LangGraph, CrewAI, Mastra, AG2, and others) have built adapters that emit AG-UI-compliant events independent of any particular frontend library. A frontend team could, in principle, implement its own client that parses the AG-UI event stream directly, though most teams use an existing SDK to avoid re-implementing event parsing and state reconciliation from scratch.
Related guides: MCP architecture diagrams, A2A protocol architecture diagrams, AI agent architecture diagrams, WebSocket architecture diagrams, and multi-agent orchestration patterns.
Ready to try it yourself?
Start Creating - Free