跪拜 Guibai
← All articles
Frontend · Android · Flutter

Flutter A2UI 1.0 Shrinks AI UI Token Use and Enforces Component Rules

By 恋猫de小郭 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

A2UI 1.0 makes AI-generated UIs cheaper and structurally safer, but it still requires per-platform widget implementation and pushes transport and state management back onto the app. For teams building Flutter clients with agent-generated interfaces, this is the first protocol version that treats common engineering pain points as first-class problems.

Summary

Flutter's A2UI 1.0 protocol and SDK packages are out, replacing the original genui. The release splits responsibilities across three packages: a2ui_agent tells the model what components exist and compiles Express or JSON into A2UI messages; a2ui_core validates messages and manages surfaces, component trees, data models, and function calls; a2ui_flutter maps validated components to Flutter widgets. The old SurfaceController and Conversation/Transport wrappers are gone, so apps now manage chat history and network transport themselves.

The protocol adds several engineering fixes for AI-generated UIs. Catalogs now support allowedParents and allowedChildren rules that the client enforces before building widgets, returning UNALLOWED_CHILD or UNALLOWED_PARENT errors. A single Surface can use multiple Catalogs, so common and business-specific components stay separate. Express, a compact output format replacing verbose JSON, cuts token usage: with Gemini 3.8 Flash and 54 samples, median output tokens drop from 807 to 297 (63% less), input tokens from 10,980 to 6,000, with the same 53/54 pass@1. A full dashboard generation time drops from 10 seconds to 5.

The new callAgentFunction lets deterministic interactions, like incrementing a quantity, call a registered backend function directly, while only genuinely new questions go back to the LLM. metadata.extensions carries correlation tokens from Python multi-agent backends to Flutter for tracing. A2UI still requires implementing custom widgets on each rendering target; the protocol only standardizes the message layer.

Takeaways
— A2UI 1.0 is a protocol version; the pub packages are a2ui_flutter 0.4.0, a2ui_core 0.8.0, and a2ui_agent 0.4.0, all supporting protocol 1.0.
— Express format cuts median code output tokens from 807 to 297 (63% less) and median input tokens from 10,980 to 6,000, with identical Pass@1 of 53/54 across 54 samples.
— Switching to Express reduces a full dashboard generation from 10 seconds to 5 seconds.
— Catalogs now support allowedParents and allowedChildren; the client rejects invalid component nesting with UNALLOWED_CHILD or UNALLOWED_PARENT errors.
— A2UI 1.0 lets one Surface use multiple Catalogs, so base components, finance charts, and profile cards can be maintained separately and combined via @catalogId.
— The new callAgentFunction routes deterministic operations like quantity increments directly to backend functions, while only new reasoning questions go to the LLM.
— metadata.extensions attaches correlation tokens to Surfaces, components, Catalogs, and Actions for tracing generation, rendering, and clicks across Python multi-agent backends.
— The old SurfaceController is replaced by MessageProcessor, and Conversation/Transport wrappers are gone; apps now manage chat history and network transport themselves.
Conclusions

The two-layer validation, where the model sees Catalog rules but the client rejects violations before building, treats LLM mistakes as an expected failure mode rather than trying to prevent them at generation time only.

Because Express halves token counts without changing pass rates, the dominant cost of AI UI generation isn't the model's reasoning but the serialization of repeating JSON structure.

A2UI still doesn't deliver cross-platform widgets from a single Catalog; each rendering target needs its own implementation, so the protocol's value is in message and validation standardization, not eliminating platform work.

Concepts & terms
A2UI (Agent-to-UI)
A protocol and SDK set that lets an AI agent generate interactive UI descriptions (surfaces, components, data bindings) that clients render using predefined widgets, instead of generating code.
Catalog
A whitelist and schema describing which components an agent may use, including allowed nesting rules. Flutter clients use it to validate and build UI.
Express
A compact, function-call-style output format for A2UI messages that cuts token usage vs full JSON, later compiled to standard A2UI JSON by the agent SDK.
MessageProcessor
In a2ui_core, the class that validates incoming A2UI messages, manages Surface state, component trees, data models, and function calls.
Surface
A named UI region created by the agent via createSurface; components and data updates are scoped to it.
callAgentFunction
A protocol mechanism that lets the Flutter client invoke a deterministic backend function directly, bypassing the LLM for operations like quantity changes or fee calculations.
metadata.extensions
A field for attaching arbitrary extension data (e.g., correlation IDs) to Surfaces, components, Catalogs, and Actions for tracing and integration.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗