Lesson 14.07 · Phase 14 · Agent UX & Interfaces
Generative UI
Let the model choose which components to show. Never let it write the page. A component catalog, strict validation and escaping turn "the model made a UI" from a security hole into a feature.
Learning objectives
- Define a component catalog: allowed types, typed props, which can have children, allowed button actions, and size and depth limits.
- Validate a model's JSON component tree against the catalog, and render it with every string escaped.
- Fall back to plain text on any failure, so a bad spec degrades the answer instead of breaking or attacking the page.
- Run a real model, see where it goes wrong, and add only a narrow normalisation step before strict validation.
"Show me order 1042" deserves more than a paragraph: a card with the status, a table of items and a "Start a return" button. You could ask the model to write HTML. Then the text it read from a customer's message (Phase 12: indirect injection) arrives inside your page as <img src=x onerror=...>, a link says javascript:..., and a button is wired to deleteaccount.
Loading the full lesson…