Back to Thoughts

AG-UI and A2UI: The Contracts Agent Apps Actually Need

Mar 13, 20267 min readView raw

Most agent apps start with a chat box and a custom stream format.

That works until the agent stops behaving like chat. It calls tools, updates state, pauses for approval, emits partial output, recovers from errors, and sometimes needs the frontend to render something richer than text.

At that point, your "message" object becomes a junk drawer.

AG-UI and A2UI matter because they separate two contracts that agent apps usually blur together: how the agent communicates with the app, and how the agent asks the app to render UI.

Link to this sectionAgent apps break normal request-response APIs

Traditional web APIs assume a short loop:

  1. The client sends a request.
  2. The server returns a response.
  3. The client renders.
  4. The interaction ends.

That model is fine for CRUD screens. It is a poor fit for agents.

An agent run is long-lived. It may stream tokens, call tools, update shared state, emit structured data, ask for human approval, and continue after the user responds. The frontend needs to observe the run while it is happening.

Teams usually solve this with custom WebSocket payloads, Server-Sent Events, and frontend conditionals. That works for the first version.

Then every backend invents its own event shape. Every frontend invents its own parser. Tool calls become rendering hacks. State updates get hidden inside text messages. Swapping frameworks becomes painful because the protocol only exists as tribal knowledge inside the app.

That is the problem these protocols are trying to make explicit.

Link to this sectionAG-UI standardizes agent-user interaction events

AG-UI stands for Agent-User Interaction protocol.

It is an open, event-based protocol between an agentic backend and a user-facing application. Instead of forcing every team to invent a stream format, AG-UI defines typed events for the lifecycle of an agent run.

The basic contract is:

  • the backend emits events
  • the frontend consumes events in real time
  • both sides agree on what each event means

That contract covers the behavior normal APIs do badly:

  • text streaming
  • tool call lifecycle
  • state updates
  • frontend actions
  • interrupts
  • custom events
  • multimodal attachments

AG-UI does not replace HTTP, WebSockets, or Server-Sent Events. It gives the bytes moving over those transports a shared vocabulary.

That distinction is useful. The frontend should not need to know every internal detail of LangGraph, CrewAI, or a custom backend. It needs to know what is happening in the run and what the user can do next.

Link to this sectionA2UI standardizes safe agent-driven UI

A2UI solves a different problem.

Sometimes text is not the right output. The agent may need to present:

  • a search results panel
  • a form
  • a dashboard card
  • a chart
  • an approval surface
  • a comparison table

The dangerous version is letting the model generate raw frontend code and execute it in the client.

A2UI takes a safer approach. The agent sends declarative UI descriptions. The client renders those descriptions using an approved component catalog.

The model describes intent. The application decides what components are allowed. The renderer stays in control.

That means the agent can ask for an interface without crossing the trust boundary into arbitrary code execution.

AG-UI standardizes interaction. A2UI standardizes presentation.

Those are related problems, but they are not the same problem.

Link to this sectionUse AG-UI as the event pipe and A2UI as the UI payload

The clean mental model is:

  • AG-UI is the event pipe.
  • A2UI is the UI description format.

AG-UI answers: how do the frontend and backend communicate during an agent run?

A2UI answers: how does an agent safely ask the app to render an interface?

In practice, agent apps often need both.

The backend streams run progress, tool activity, state changes, and interrupts through AG-UI. When the agent needs richer interaction than plain text, it emits a declarative UI payload that the frontend renders through an A2UI-style component system.

That separation prevents teams from overloading one mechanism:

  • text messages carrying JSON blobs
  • tool outputs pretending to be UI
  • backend responses full of frontend-only flags
  • custom event names that only one screen understands

All of those can work in a demo. They do not age well.

Link to this sectionHow this maps to LangGraph and assistant-ui

This clicked for me while using assistant-ui on the frontend and LangGraph Deep Agents on the backend.

LangGraph already has strong streaming primitives. Its streaming model distinguishes state updates, token-level messages, and custom application signals. That is exactly the kind of behavior a frontend needs to observe during a long-running agent task.

ag-ui-langgraph gives that backend a concrete AG-UI integration. Instead of inventing a custom adapter, the backend can expose a standardized event protocol.

On the frontend, assistant-ui provides runtime abstractions for agent backends, including AG-UI support. That means the UI does not need to couple itself directly to every LangGraph implementation detail.

The layers become clearer:

  • LangGraph handles execution.
  • AG-UI describes runtime interaction events.
  • assistant-ui handles conversation rendering and user interaction.
  • A2UI-style payloads can describe richer UI when text is not enough.

The practical benefit is not novelty. It is fewer arguments about what a "message" means.

Text is text. Tool calls are tool calls. State updates are state updates. UI descriptions get their own contract.

Link to this sectionWhere these protocols help most

AG-UI helps when the frontend needs a reliable view of a run in progress.

That includes agent apps with tool calls, streaming output, interrupts, approvals, resumable tasks, or visible intermediate steps.

A2UI helps when the agent needs to influence layout or interaction without owning the client runtime.

That includes dashboards, review screens, generated forms, product copilots, and internal tools where the model should assemble approved components rather than write code.

Both protocols are most valuable once your app has moved beyond chat.

If your product is just streaming text, a simple stream may be enough. Do not add standards before the problem exists.

But once the frontend-backend boundary starts filling with custom event names and JSON blobs in text fields, you are already designing a protocol. You may as well make the contract explicit.

Link to this sectionThe trade-off is another layer to own

Protocols reduce ambiguity, but they are not free.

You still need to map your backend events into the protocol. You still need to decide which UI components the agent can request. You still need validation, versioning, fallbacks, and debugging tools.

A bad abstraction can be worse than no abstraction. If the protocol layer just hides your real data flow, it will make the system harder to reason about.

The test is whether the boundary becomes clearer.

If AG-UI makes run lifecycle events explicit, it is helping. If A2UI keeps agent-generated UI inside approved components, it is helping. If either one becomes a pile of adapters nobody understands, simplify.

Link to this sectionThe practical takeaway

Do not treat the frontend of an agent app as a dumb chat shell.

Agent products need contracts for:

  • execution state
  • event transport
  • tool lifecycle
  • user interrupts
  • rendering
  • approval and interaction

AG-UI gives you a contract for the runtime interaction layer.

A2UI gives you a contract for safe agent-driven UI.

Used together, they make the frontend-backend boundary less ambiguous. That is the real value: clearer data flow, clearer UI flow, and less custom glue pretending to be architecture.

Link to this sectionReferences

Keep reading

All thoughts
Gopal Khadka