Skip to content
Back to Agent systems and standards

Agent systems and standards · Chapter 3 of 8

Agents and interfaces: AG-UI and A2UI

Streaming an agent's work to an app with AG-UI, and letting an agent describe safe interface components with A2UI.

25 minutes0 of 4 goals done

Goals

  • Watch a run's AG-UI event stream to the end.To do
  • Confirm the refund through a front-end tool.To do
  • Inject a component outside the A2UI catalogue and see it refused.To do
  • Pass the check.To do

Step 1 of 4: The read

AG-UI: the agent's work as a stream

MCP connects an agent to tools and A2A to other agents. AG-UI (Agent–User Interaction protocol) connects it to the app a person uses. The app sends a RunAgentInput (thread id, run id, messages, state, and the tools the app offers) and reads back a stream of events, here as server-sent events.

A run starts with RUN_STARTED and ends with RUN_FINISHED or RUN_ERROR. Text arrives as TEXT_MESSAGE_START, then TEXT_MESSAGE_CONTENT fragments, then TEXT_MESSAGE_END. Tool calls arrive the same way: TOOL_CALL_START, TOOL_CALL_ARGS, TOOL_CALL_END, and TOOL_CALL_RESULT for tools the agent ran. Shared state moves as STATE_SNAPSHOT, the whole state, or STATE_DELTA, a list of JSON Patch operations. The official client, @ag-ui/client 1.0.2, checks each event's schema and order before it applies it.

Front-end tools

Some tools belong to the app: a confirm button, a date picker. The app lists them in RunAgentInput.tools. When the agent calls one, the run finishes with that call left pending; the app runs the tool, here by asking the customer, and starts the next run with the result as a tool message. The person's answer becomes part of the conversation, and the agent decides what to do with it.

A2UI: interfaces as data

A2UI (protocol v0.9) lets an agent describe a piece of interface without sending code. createSurface opens a surface and names the catalogue it uses; updateComponents sends a flat list of components that refer to each other by id; updateDataModel sends the values they bind to. The app renders only components from its own catalogue, here seven types: Card, Column, Row, List, Text, Button and Divider. With strict validation, @a2ui/web_core 0.12.0 refuses an unknown type and the surface stays as it was, so an agent, or a prompt that fooled it, cannot make the app run new code.

What you do here

A customer asks the support chat about the double charge. Over AG-UI, watch the events stream, then confirm the refund on the card the app draws. Then switch the lab to A2UI, where the agent builds a refund card from messages. Turn on Intercept, hold the updateComponents message and add a Script component: web_core refuses it.

Step 2 of 4: Try it: An agent builds a screen

An agent builds a screen

Four steps, one action each, then two optional ones. The lab under the steps draws every message as a row, from the top down. While an A2UI lab is open, a tree under the lab shows the components the agent sent, joined by id.

Mode:RealSimulatedReal: the AG-UI client and core (@ag-ui/client and @ag-ui/core 1.0.2) and the A2UI core library (@a2ui/web_core 0.12.0) run in this page, with the MCP and A2A SDKs in the two workflows. Simulated: the agent's decisions are scripted unless you connect a model, and the shop and the order are fictional.

Step 3 of 4: Check

Check

Question 1 of 4What is an AG-UI front-end tool?

Next: Question 2 of 4

Question 2 of 4Why does A2UI render from a catalogue instead of running the agent's markup?
Question 3 of 4What does an AG-UI STATE_DELTA event carry?
Question 4 of 4The client receives TEXT_MESSAGE_CONTENT for a messageId that never had a TEXT_MESSAGE_START. What happens?

Step 4 of 4: What you can do now

What you can do now

  • Read an AG-UI event stream and say what each event does.
  • Use a front-end tool to put a person inside an agent's run.
  • Describe an A2UI surface: createSurface, updateComponents and updateDataModel.
  • Explain how A2UI's catalogue keeps an app safe from agent-made UI.