Deep Dive · Agent Interfaces

Writing A2UI by Hand: What the Protocol Actually Asks of a Renderer

Before you let a model produce interface JSON, write the JSON yourself. A one-hour Angular walkthrough does exactly that — and in the process shows why the component tree is flat, why an action arrives as an input rather than an event, and where the protocol is quietly designed around what models are bad at.

A2UI in Angular — video thumbnail
Video: Rainer Hahnekamp 59:07 10 November 2026
A2UI Angular AG-UI CopilotKit

✍️ Why write it by hand 3:48

"The easiest way to understand it is that we just take a look at this JSON format that we can also write on our own. We don't need to use an agent in the beginning."
PhaseWho produces the JSONWhat you learn
FirstYou, by handEvery message type and where each one goes wrong
ThenThe modelWhich of your assumptions the model cannot be trusted with
This is the right pedagogy for a protocol and almost nobody does it. Wiring the agent first hides the protocol behind a framework — when output looks wrong you cannot tell whether the model, the SDK, the renderer or your catalog is at fault. Writing three messages by hand first costs an hour and gives you a reference surface: any later failure can be bisected against a known-good message.

🧱 Three artefacts, one catalog 1:44

ArtefactWhat it isWho sees it
Catalog definitionNames, descriptions and property schemas — a specification, not an implementationThe agent, eventually
Component implementationsReal framework components fulfilling those schemasThe app
The catalogThe function that binds definition to implementationThe renderer
The rendererUnderstands the JSON, looks up components in the catalog, draws them into a surfaceProvided by the framework

The definition is written with a schema library — Zod in this case, version three — and the description field is not decoration. It is the text the model reads when deciding whether a component fits the request, which makes it prompt engineering with a type system attached.

The two-part split is the durability trick: the definition can travel to the model while the implementation stays yours. A catalog is therefore a contract you can version, and the same catalog regenerates the prompt that teaches the model — which is what the project's SDK skill generator does. Your design system becomes the schema, and the schema becomes the instructions.

🪟 Surface and operations 11:21

MessagePurpose
createSurfaceOpens a named region on the client — always the first message, and in v1.0 a single message rather than three
updateComponentsSends the component list; can be sent repeatedly, which is what streaming looks like on the wire
updateDataModelSets values at a path, separately from layout
Plus, in v1.0deleteSurface, and bidirectional function calls in both directions
The operations array is deliberately a log, not a state snapshot. He describes it as conversation history, and the consequence is important: because updateComponents can arrive many times, a renderer that re-renders from scratch on each message will flicker, while one that patches will feel live. That is a renderer design decision the protocol hands to you, not one it makes.
Honest cost, said out loud in the video: "we have now made a lot of steps just in order to print out one button." A button needs a surface, an operation array, a root component and a label child. The payoff is not that this is convenient — it is that you now have a dynamic rendering engine inside your framework that an agent can drive with data.

📐 Why the tree is flat 21:31

"This is JSON that needs to be generated by the agent, and we know that agents don't have the easiest time when it comes to nested data structures. That's why we are flattening it here by using IDs to reference the children."
Nested treeFlat list with ID references
Deeply indented JSON the model must close correctlyA list of siblings, each naming its children by ID
A single missing brace invalidates everything after itA malformed component fails alone
More tokens spent on structure than contentStructure costs one string per edge
This is the most important design decision in the protocol, and it is a concession, not an elegance. A pure interface protocol would let a container hold its children inline because that is how humans write component trees. A2UI flattens them because the author is a language model and nesting is where models fail. That is a protocol shaped around the weakness of its producer — and recognising it explains most of the rest of the spec: paths instead of copies, macros instead of generation, a catalog instead of free composition.
The consequence for your own renderer: resolving a flat list into a visible tree requires an ID map and a resolution order, and a dangling child ID is possible in a way it is not in nested JSON. Validation must catch it, because the failure mode is an empty pane with no error — the same silence that makes malformed tool arguments so hard to debug.

🔗 Data binding, and a for loop 23:25

StepWhat changes
Static stringThe button's label property is a plain string: one button, one dish
Dynamic stringThe property schema becomes a dynamic type that can accept a path into the data model
Data model updateValues arrive at a path — /meals — independently of the layout
Templated childrenThe container declares one child template plus a path; the renderer instantiates it per item
"I want to have a for loop and I want to have a dynamic for loop, if the data model changes, that I don't have to care about these things."
The for loop is the moment the protocol stops being JSON and becomes a rendering engine. A container's children can be a static array of IDs or an object with a template ID and a path; the renderer iterates the data model and instantiates the template per item. That single feature is what makes a card list with a hundred meals cost the same in tokens as a card list with two — and in the specification, the path in that template is a plain JSON pointer, not the dynamic-binding form used elsewhere.
The subtlety he runs into live: a label bound to /meals renders an object, not a dish. Binding has to point at the field, not the collection, and within a template the current item is addressed relative to the iteration. Getting that wrong is the most common class of generative-UI bug, and it fails by rendering something ugly rather than by erroring — so validation cannot save you.

🎯 Actions arrive as inputs 30:03

"In Angular, when we have events, we have an output — not so in A2UI. The renderer is giving us this action like as an input element, and we call it."
Conventional framework modelA2UI's inversion
The component emits an event upwardThe renderer passes a callable down as an input
The parent subscribes and reactsThe component calls the function it was given
Wiring is per-component, in the parentWiring is uniform: every action carries a name and a context object
This inversion is what makes one renderer work for components it has never seen. An event with an output binding needs a parent that knows the child's event vocabulary; a callable passed in as an input only needs the child to invoke it. That is why a generic renderer can host your catalog at all: the contract is one function, and the payload is a name plus a context — never a bespoke callback signature.
And the context is untyped at the boundary: it arrives as a plain record, so the receiver validates it against its own schema before acting. His fix is exactly right — parse the context with the same schema the data model uses, which also means a compromised or confused agent cannot pass a payload that does something the type does not allow. Type validation at the action boundary is the security control, not a formality.

📚 The basic catalog 38:29

FactDetail
Ships with the protocolA general-purpose catalog you can use instead of writing your own
Size18 components — and, per the specification, 14 functions
CategoriesLayout (row, column, list, card, tabs, modal, divider), display, input
ComposabilityYou can include the basic catalog and extend it with your own components in the same surface
ToolingA composer with a component gallery, live JSON editing and a preview
The composer is the artefact to try before writing any code: it takes the same messages your agent will emit, shows the JSON, and renders the result live. That collapses the edit-compile-render loop to a paste — and it gives you a way to test a catalog without a model in the loop at all. For a protocol whose whole promise is "the agent composes, your app renders", a playground that separates those two halves is not a nicety.
The video says 18 components; the specification says 18 components and 14 functions. The functions matter — they are what lets a bound property call something like a currency formatter instead of receiving a pre-formatted string, which is another way the protocol keeps work off the model.

🔌 Connecting the agent 42:31

LayerRole
A2UIWhat an interface looks like — the message format
AG-UIHow it travels between agent and frontend
CopilotKitThe implementation: renderer, runtime endpoint, chat surface
Three separate concerns, and the layering is the point. A2UI deliberately does not define transport — the spec supports plain HTTP, WebSockets, AG-UI, A2A or MCP — so the same interface description can arrive over whatever channel your product already uses. The video's setup works because AG-UI has an activity message type that can carry A2UI operations as structured content rather than text, which is why the resulting state is a computed signal derived from messages rather than a bespoke callback.
The plumbing he writes is a warning about the current state of the ecosystem: filtering messages by role, checking the activity type, unwrapping a content key, flattening a nested array, handling the empty case. That is thirty lines of adapter that every team will write slightly differently. It works, and it will be framework-provided soon — but today it is the tax on being early.

🔍 The inspector and the duplicate 50:10

ObservationWhy it happens
The first message says the surface is "building"It is a status snapshot, not the operations payload
The operations arrive in a later messageThat is the one carrying the component JSON
The interface renders twice — once in the chat, once in the surfaceTwo consumers, one message stream
Fixed with a no-op activity componentRegister a component that renders nothing for that activity type
The duplicate render is the most useful bug in the video, because it exposes an assumption nobody states: once an agent can emit interfaces, a chat transcript is a second renderer of the same stream. Every product embedding generative UI will hit this — the message log and the surface both claim the content. The fix here is a client-side registration that suppresses one of them, which is correct and also a reminder that the choice of where an interface appears is a product decision the protocol leaves entirely to you.

🚧 Where it falls short 55:50

ProblemHis evidence
The model does not always follow the instruction"Show me three per row" was answered with something else — said plainly, with no spin
Weaker models get the JSON wrong on the first tryHe expects a high-to-middle chance of failure from a small Gemma-class model
The compact format helpsExpress is a domain-specific language that compiles to the JSON, at roughly a third of the token consumption
The honest remedyTune prompts, run evals, or use a stronger model — with the caveat that this was out of scope for the video
"I also don't want to give you any illusion here — it does not always follow the instructions as we would hope for."
A Google developer expert saying "this does not always work" is worth more than the rest of the hour, because it sets the expectation correctly: the protocol is stable, the model compliance is not. Everything in the design — flat lists, macros, the compact format, the catalog — exists to narrow the gap between what the model can write and what the renderer accepts. If your product needs a guarantee that a specific layout appears, you need a macro or a deterministic path, not a prompt.
Note the version detail he glosses: the hand-written examples use the property-binding and children-path forms he is teaching, while the published 1.0 specification prefixes dynamic bindings with an @ — @path and @call — and renames the wire envelopes. The framework he uses normalises this for you, which is convenient and also why you should read the specification before debugging by hand.

🧭 What v1.0 changed underneath 1:50

Change in 1.0Consequence
Bidirectional function RPCThe renderer and the agent can call functions on each other — four new message types
Prefixed bindings@path, @call; component-level @catalogId, @accessibility, @metadata, @checks
Per-surface catalogsA surface can pick a default catalog and mix components from others
Placement rulesCatalogs can declare allowed parents and children, so invalid composition is rejected early
One message to create a surfaceInitial components and data can be inlined
Placement rules are the quiet improvement worth noticing: if a catalog can say "this card may only appear inside a column or a list", then a whole class of layout errors becomes a validation failure at the agent rather than an ugly render on the client. That is the same principle as the component allow-list, pushed one level deeper — constraining not just what exists but where it may go.

✅ Claims checked

ClaimVerdictEvidence
A2UI 1.0 is from Google and open sourceCorrectAnnounced 11 November 2026; Apache-2.0 repository with about 18,000 stars
The catalog is a definition, not an implementationCorrectSpecification: name, description, property schemas, functions, prompt instructions
The renderer needs both a catalog implementation and a rendererCorrectThat is the client-side contract
createSurface is the first commandCorrectAnd v1.0 can inline components and data into it
updateComponents may be sent repeatedly, enabling streamingCorrectA log of operations, not a state snapshot
updateDataModel addresses values by pathCorrectJSON pointer paths into the data model
The component list is flat with children referenced by IDCorrect — and for the reason he givesSpecification: children are IDs, so "the surface stays a flat list instead of a nested tree"
A container can template children over a data-model path, giving a for loopCorrectChildList accepts a static array or a template with a component ID and a path
Dynamic properties accept a literal, a binding or a function callCorrectDynamic string/number/boolean types; @path and @call in v1.0
In A2UI the action is delivered as an input to the componentCorrect in practiceHis renderer's contract; actions carry an event name and a context object
The action context is untyped and should be parsedCorrectHe validates it with the same schema as the data model
The basic catalog has 18 componentsCorrect, but incompleteSpecification: 18 components and 14 functions
There is a composer with a gallery and live previewCorrectNamed in the specification and available from the project
AG-UI is the transport; CopilotKit implements the stackCorrectA2UI's spec lists AG-UI, A2A, MCP, WebSockets and HTTP as transports; CopilotKit is MIT, about 38,900 stars; AG-UI about 21,000
Operations travel inside an activity messageConsistent with the AG-UI integrationActivity type for the surface, content key for the operations
Express is roughly a third of the token consumptionHis measurement; the format is documentedMacros guide shows the single-line Express form compiling to full messages
The model does not always follow the layout instructionDemonstrated in the videoAnd consistent with the protocol's design choices
The renderer version he uses matches every 1.0 detailNot entirely — the framework normalises the v1.0 prefixesSpecification uses @path/@call and renamed envelopes

Basis note. Built from the full 59:07 video and checked against the A2UI v1.0 specification, the catalogs and macros guides, and repository metadata. The presenter is a Google developer expert, co-maintainer of the Angular integration for CopilotKit, and promotes his own training and consulting in the video; the tutorial content is genuine, the promotion is separated from it here. Where the transcript garbles a model name, no version is asserted. The observations about what the flat list, the action inversion and the duplicate render imply are this article's.

🔑 Key takeaways

  • Write the protocol by hand before you wire a model to it. You need a known-good message to bisect against.
  • A catalog is three things: a definition the model reads, implementations your app owns, and a function binding them.
  • The description field is prompt engineering with a schema attached — it is how the model decides what fits.
  • Operations are a log, not a snapshot, so your renderer must patch rather than rebuild or it will flicker.
  • The tree is flat because models are bad at nesting. A2UI is shaped around the weakness of its author.
  • Templated children are the killer feature: one component plus a path renders a hundred items at the cost of one.
  • Bind to the field, not the collection. Wrong paths render nonsense instead of erroring, so validation cannot catch them.
  • Actions arrive as inputs. The inversion is why a generic renderer can host components it has never seen.
  • Parse the action context against your own schema; at the boundary it is untyped, and that is a security control.
  • The basic catalog is 18 components and 14 functions — the functions keep formatting work off the model.
  • Three layers, three jobs: A2UI describes, AG-UI transports, CopilotKit implements.
  • Expect the interface twice — chat and surface both render the same stream; suppress one deliberately.
  • The model still does not obey layout instructions reliably. Macros and deterministic paths are the guarantee, not prompts.

🔗 Resources

  • The video — Rainer Hahnekamp, 59:07
  • The A2UI v1.0 specification — message structure, dynamic types, child lists
  • Catalogs and macros — the two guides that make the rest legible
  • a2ui-project/a2ui — SDKs, renderers and the basic catalog
  • CopilotKit and AG-UI — the stack used in the walkthrough
  • This site's earlier deep dive on A2UI 1.0 for the protocol's own announcement, the token economics and the MCP apps comparison
Basis note. The presenter sells training and consulting, and says so twice. No affiliate links. Protocol behaviour was verified against the specification rather than the narration; one place where the walkthrough's code predates or abstracts the 1.0 wire format is flagged in the article rather than smoothed over.

⏱ Timestamp index

0:00Generative UI and rendered components
0:39A2UI 1.0 from Google
0:47Transport: AG-UI and CopilotKit
1:03Who the presenter is
1:44The catalog is a definition
2:24The model builds a component tree as JSON
2:53The frontend implements the catalog and a renderer
3:48Write the JSON yourself first
4:49Starting the catalog with two components
5:13Zod schemas for the properties
7:11Implementing the components
9:00Binding definition to implementation
10:10Registering the catalog with the framework
11:21Adding a surface
12:28Operations as a conversation log
13:01createSurface with an ID
14:07updateComponents and the root component
15:30The first button renders
16:25Needing a container that accepts children
17:26The children schema
18:40Rendering children by ID
20:43Two buttons inside a row
21:31Why it is flat, not nested
22:13Nesting costs tokens and invites errors
22:24The model in use, and weaker models
22:51Express as a DSL that compiles to JSON
23:25Data binding begins
24:00updateDataModel
25:06Paths into the data model
26:00Switching the label to a dynamic string
27:45Referencing the first element
28:30The dynamic for loop via templated children
30:03Adding actions
31:01No outputs: the action is an input
32:34Action name and context
33:09The context must be an object
33:49Listening to action events
35:04Adding the meal to the log
36:18Passing the whole object as context
37:10Parsing the context with a schema
38:29The existing basic catalog
38:55The composer and component gallery
39:51Live preview of edited JSON
41:18Swapping in the list component
42:31Delegating the JSON to the agent
43:02AG-UI as the appropriate transport
44:29The agent now knows the catalog
45:12Operations become a computed signal
45:43Operations arrive as an activity message
47:39The operations content key
49:13Placeholders while waiting
50:10The inspector
51:58Status building versus the operations message
52:50The A2UI view in the inspector
53:14Removing the duplicate with a no-op activity
54:30Registering the activity component
55:40Asking for Austrian meals
55:50It does not always follow instructions
56:30Express at about a third of the tokens
57:11Prompts, evals and stronger models
57:27The core: JSON describing a component tree
58:18Training and workshops
☰ View all