Generative User Interfaces
Summary
Problem Statement
Currently, creating custom user interfaces for agent interactions requires programmers to define specific tool renderers. This limits the flexibility and adaptability of agent-driven applications.Motivation
This draft describes an AG-UI extension that addresses generative user interfaces—interfaces produced directly by artificial intelligence without requiring a programmer to define custom tool renderers. The key idea is to leverage our ability to send client-side tools to the agent, thereby enabling this capability across all agent frameworks supported by AG-UI.Status
- Status: Draft
- Author(s): Markus Ecker (mail@mme.xyz)
Challenges and Limitations
Tool Description Length
OpenAI enforces a limit of 1024 characters for tool descriptions. Gemini and Anthropic impose no such limit.Arguments JSON Schema Constraints
Classes, nesting,$ref
, and oneOf
are not reliably supported across LLM
providers.
Context Window Considerations
Injecting a large UI description language into an agent may reduce its performance. Agents dedicated solely to UI generation perform better than agents combining UI generation with other tasks.Detailed Specification
Two-Step Generation Process
Step 1: What to Generate?
Inject a lightweight tool into the agent: Tool Definition:- Name:
generateUserInterface
- Arguments:
- description: A high-level description of the UI (e.g., “A form for entering the user’s address”)
- data: Arbitrary pre-populated data for the generated UI
- output: A description or schema of the data the agent expects the user to submit back (fields, required/optional, types, constraints)
Step 2: How to Generate?
Delegate UI generation to a secondary LLM or agent:- The CopilotKit user stays in control: Can make their own generators, add custom libraries, include additional prompts etc.
- On tool invocation, the secondary model consumes
description
,data
, andoutput
to generate the user interface - This model is focused solely on UI generation, ensuring maximum fidelity and consistency
- The generation method can be swapped as needed (e.g., JSON, HTML, or other renderable formats)
- The UI format description is not subject to structural or length constraints, allowing arbitrarily complex specifications
Implementation Examples
Example Output: UISchemaGenerator
Example Output: ReactFormHookGenerator
Implementation Considerations
Client SDK Changes
TypeScript SDK additions:- New
generateUserInterface
tool type - UI generator registry for pluggable generators
- Validation layer for generated UI schemas
- Response handler for user-submitted data
- Support for UI generation tool invocation
- Schema validation utilities
- Serialization for UI definitions
Integration Impact
- All AG-UI integrations can leverage this capability without modification
- Frameworks emit standard tool calls; client handles UI generation
- Backward compatible with existing tool-based UI approaches
Use Cases
Dynamic Forms
Agents can generate forms on-the-fly based on conversation context without pre-defined schemas.Data Visualization
Generate charts, graphs, or tables appropriate to the data being discussed.Interactive Workflows
Create multi-step wizards or guided processes tailored to user needs.Adaptive Interfaces
Generate different UI layouts based on user preferences or device capabilities.Testing Strategy
- Unit tests for tool injection and invocation
- Integration tests with multiple UI generators
- E2E tests demonstrating various UI types
- Performance benchmarks comparing single vs. two-step generation
- Cross-provider compatibility testing