跳转到主要内容

A2UI — Agent to UI

A2UI lets the Agent describe UI structure through declarative JSON. The frontend renders it as native React components inline in the chat area. When users interact with components (e.g., clicking buttons), events are dispatched back to the Agent for follow-up processing.

How It Works

Basic Usage

The Agent calls the render_ui tool with a components array:
The tool result contains an a2ui field. When StageGroup detects this field, it renders the A2UIRenderer component.

Component Catalog

Layout Components

Row

Arranges children horizontally.

Column

Arranges children vertically.

Card

Container with title and border.

Content Components

Text

Text display with Markdown support.

Image

Image display.

Divider

Horizontal separator.

Badge

Label/badge.

List

List display.

Table

Table display.

Interactive Components

Button

Clickable button that triggers an Action callback.

Profy Business Components

ExpertCard

Expert information card.

CreditDisplay

Credit balance display.

PlanBadge

Subscription plan badge.

StatusIndicator

Status indicator.

PricingTable

Pricing comparison table.

ProgressBar

Progress bar.

Action Handling

When a user clicks a Button with an action prop, the frontend dispatches the event to the Agent:
The Agent reads this action in its next reasoning turn and can respond accordingly (e.g., navigate to payment, update displayed content).

Examples

Plan Comparison

Status Dashboard

Action Confirmation

Best Practices

  1. Prefer A2UI over Inline Visualization when displaying structured data (tables, lists, status) — A2UI components are more consistent and performant
  2. Keep component trees shallow — no more than 3 levels of nesting
  3. Use snake_case for action names — e.g., confirm_delete, select_plan, making them easy for the Agent to parse
  4. Use payload for context — Button’s payload field carries additional data the Agent needs, avoiding positional inference
  5. Group with Cards — logically related components belong in the same Card for visual coherence
  6. Choose Inline Visualization when you need freeform drawing/Canvas/WebGL — A2UI only supports predefined components