Skip to content

API Reference parrot.outputs.a2ui.models

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.outputs.a2ui.models

View source

A2UI v1.0 wire message models.

This module ships the complete A2UI v1.0 <https://a2ui.org/specification/v1.0-a2ui/>_ message set as Pydantic v2 models. These classes ARE the wire: an envelope-by-key shape ({"version": "v1.0", "<messageKey>": {...}}, exactly one message key), a top-level-props Component (child/children, catalogId, weight, accessibility, checks, action, metadata.extensions), and the full v1.0 agent-to-renderer / renderer-to-agent message set.

Verified against the vendored/pinned upstream schemas (google/A2UI@90157ec10f36cf8e192daa71c95d2684af20c756, specification/v1_0/json/{common_types,agent_to_renderer,renderer_to_agent}.json) fetched during implementation of FEAT-470 TASK-2532. The permanent vendored copies with a drift test land in TASK-2534 (parrot.outputs.a2ui.catalog.basic.spec).

Design invariants (spec FEAT-470, carried over from FEAT-273):

  • Greenfield / one-way import rule (G8) — nothing in this module imports from parrot.bots, parrot.clients, agents, or DatasetManager. Only Pydantic v2 and the standard library are used.
  • version is injected only by serialization.serialize (G3) — the envelope wrapper models (:class:A2UIAgentMessage, :class:A2UIRendererMessage) declare version: Literal["v1.0"] as a validation constraint (so deserialize/validate_message can check it), but nothing in this module ever defaults or writes it when building/dumping the inner per-message models (CreateSurface, ActionMessage, ...) — that remains :mod:parrot.outputs.a2ui.serialization's exclusive job.
  • Wire props are top-level — component-specific catalog properties (text, url, ...) are NOT nested under a properties key; they live at the top level of the Component object (extra="allow"). Presentation semantics that are NOT part of the official wire (renderer hints, optional bindings, parrot-only variants) belong in metadata.extensions.parrot_* — never as top-level component props.
  • Bindings are {"path": "..."} — the legacy {"$bind": "..."} syntax is a read-only compatibility concern, normalized by :mod:parrot.outputs.a2ui.compat (TASK-2533) before it ever reaches these models. is_valid_pointer/is_binding_expression/BINDING_KEY are kept here (unused by the new models themselves) purely so compat.py has a single source for JSON-Pointer shape checking.

Class A2UIAgentMessage

The agent-to-renderer wire envelope: version + exactly one message.

serialize/deserialize (TASK-2533) are the only callers expected to construct/parse this directly; application code builds/consumes the inner message classes (CreateSurface, ...).

Fields:

Field Type Default Description
version Literal['v1.0'] The A2UI protocol version. Always "v1.0".
create_surface CreateSurface | None None The createSurface message, if this is one.
update_components UpdateComponents | None None The updateComponents message, if this is one.
update_data_model UpdateDataModel | None None The updateDataModel message, if this is one.
delete_surface DeleteSurface | None None The deleteSurface message, if this is one.
call_renderer_function CallRendererFunction | None None The callRendererFunction message, if this is one.
agent_function_response AgentFunctionResponse | None None The agentFunctionResponse message, if this is one.

Class A2UIMessageBase

Common, non-behavioral base for every A2UI v1.0 inner wire message.

All ten concrete message payloads (CreateSurface, ..., ErrorMessage) inherit from this so callers can do a single isinstance(x, A2UIMessageBase) check to detect "this is an A2UI message" (e.g. :mod:parrot.outputs.a2ui.emission). The envelope wrappers (:class:A2UIAgentMessage, :class:A2UIRendererMessage) do NOT inherit from this — they are a distinct "version + exactly one message" concept.

Class A2UIRendererMessage

The renderer-to-agent wire envelope: version + exactly one message.

Fields:

Field Type Default Description
version Literal['v1.0'] The A2UI protocol version. Always "v1.0".
action ActionMessage | None None The action message, if this is one.
call_agent_function CallAgentFunction | None None The callAgentFunction message, if this is one.
renderer_function_response RendererFunctionResponse | None None The rendererFunctionResponse message, if this is one.
error ErrorMessage | None None The error message, if this is one.

Class AccessibilityAttributes

Attributes to enhance accessibility for assistive technologies.

Fields:

Field Type Default Description
label DynamicString | None None A short accessible label.
description DynamicString | None None Additional accessible description.
live Literal['off', 'polite', 'assertive'] 'off' Controls screen reader announcements for dynamic updates.
hidden DynamicBoolean False Hides the element and its children from assistive technologies when true.

Class Action

Interaction handler: either an agent-side event or a function call.

Exactly one of event or function_call MUST be set.

Fields:

Field Type Default Description
event EventAction | None None Triggers an agent-side event.
function_call FunctionCall | None None Executes a renderer- or agent-side function.

Class ActionMessage

action — a user-initiated action reported by the renderer.

Attributes:

Attribute Type Description
name str The action name, from the component's action.event.name.
user_message str | None Optional human-readable description of the action, after resolving bindings.
surface_id str The surface where the event originated.
source_component_id str The component that triggered the event.
timestamp str ISO 8601 timestamp of when the event occurred.
context dict[str, Any] Key-value pairs from action.event.context, resolved.
metadata ComponentMetadata | None Optional client-side metadata sent back with the action.
data_model dict[str, Any] | None The surface's full data model, attached by the renderer when the owning surface was created with sendDataModel: true. None means the renderer did not attach one (distinct from an explicitly empty {}, which means the surface's data model is empty). Unlike :attr:CreateSurface.data_model, this defaults to None rather than {} because a surface always starts with some data model, whereas an action may or may not carry one at all.

Class AgentFunctionResponse

agentFunctionResponse — the agent's response to a callAgentFunction.

Attribute BINDING_KEY

Class CallAgentFunction

callAgentFunction — the renderer asks the agent to run a function.

Attributes:

Attribute Type Description
surface_id str The surface where the call originated.
function_call_id str Unique id for this call; the agent MUST copy it into the matching agentFunctionResponse.
call_function FunctionCall The function to invoke.

Class CallRendererFunction

callRendererFunction — the agent asks the renderer to run a function.

Attributes:

Attribute Type Description
function_call_id str Unique id for this call; the renderer MUST copy it into the matching rendererFunctionResponse.
call_function FunctionCall The function to invoke. Note: for THIS message, callFunction.catalogId is REQUIRED by the official schema (stricter than the shared :class:FunctionCall model) — that stricter constraint is enforced by jsonschema validation (TASK-2535), not by Pydantic here.

Class CheckRule

A single validation check rule applied to an input component.

The condition evaluates (at render time, via FunctionEvaluator, TASK-2537) to a :class:ValidationResult.

Fields:

Field Type Default Description
condition FunctionCall | DataBinding Path or function call evaluating to a ValidationResult.
message str | None None Optional fallback error message (plain string — verified against common_types.json#/$defs/CheckRule, NOT a DynamicString as an earlier spec draft speculated).

Attribute ChildList

Class ChildTemplate

A template for generating a dynamic list of children from a data list.

Fields:

Field Type Default Description
component_id str The component to use as a template.
path str The path to the list of component property objects in the data model.

Class Component

A single A2UI v1.0 UI component.

Catalog-specific properties (e.g. text for Text, url for Image) live at the TOP LEVEL of this object (extra="allow") — NOT nested under a properties key. This model captures the envelope properties shared across every catalog component (common_types.json#/$defs/ComponentCommon plus the per-component child/children/weight/action conveniences that recur across most catalog components); full per-component schema validation (required catalog props, enums, ...) is jsonschema's job (TASK-2535).

Fields:

Field Type Default Description
id str The unique identifier for this component within the surface.
component str The catalog component type name (e.g. "Text", "Row").
catalog_id str | None None The catalog ID for this component, overriding any surface-level default catalogId.
child str | None None A reference to a single child component id.
children ChildList | None None A static list of child component ids, or a :class:ChildTemplate generating them dynamically.
weight float | None None The relative flex weight within a Row/Column.
accessibility AccessibilityAttributes | None None Accessibility attributes.
checks list[CheckRule] | None None Renderer-side validation checks (Checkable components).
action Action | None None The interaction handler for actionable components.
metadata ComponentMetadata | None None Vendor extension metadata.

Class ComponentMetadata

Optional component-level metadata for vendor extensions.

Fields:

Field Type Default Description
extensions Extensions | None None Vendor extension key/value pairs.

Class CreateSurface

createSurface — create a new surface and begin rendering it.

Creating a surface implicitly instantiates the canonical reserved Surface container component with child: "root".

Attributes:

Attribute Type Description
surface_id str Globally-unique (for the renderer's lifetime) surface id.
catalog_id str | None The default catalog id for this surface. Components/ function calls without an explicit catalogId use this.
send_data_model bool If true, the renderer sends the full data model back with every message. Defaults to False.
components list[Component] Inline components for a one-shot, SSR-friendly surface.
data_model dict[str, Any] The initial root data model object for the surface.
metadata SurfaceMetadata | None Optional surface-level metadata.

Class DataBinding

A JSON-Pointer path to a value in the surface data model (v1.0 wire).

Fields:

Field Type Default Description
path str A JSON Pointer path to a value in the data model.

Class DeleteSurface

deleteSurface — delete an existing surface.

Attributes:

Attribute Type Description
surface_id str The surface to delete.

Attribute DynamicBoolean

Attribute DynamicNumber

Attribute DynamicString

Attribute DynamicStringList

Class ErrorMessage

error — a renderer-side error report.

Covers both shapes in renderer_to_agent.json#/$defs/...error: a "Validation Failed" error (code in {VALIDATION_FAILED, UNALLOWED_PARENT, UNALLOWED_CHILD}, requires surfaceId + path), and a "Generic" error (any other code, requires exactly one of surfaceId/functionCallId).

Attributes:

Attribute Type Description
code str The error code.
message str A short description of the error.
surface_id str | None The surface where the error occurred.
path str | None JSON pointer to the field that failed validation (validation errors only).
function_call_id str | None The function invocation this error responds to (generic errors only).

Class EventAction

The agent-side event dispatched by an :class:Action.

Fields:

Field Type Default Description
name str The name of the action to be dispatched to the agent.
user_message DynamicString | None None Optional human-readable message describing the action performed by the user.
context dict[str, Any] Key-value pairs for the action context (literals or dynamic values, resolved by the renderer before dispatch).

Class Extensions

Optional extension metadata (metadata.extensions).

Keys MUST be Unicode identifiers (UAX #31). Keys starting with a2ui_ are reserved for official A2UI extensions — parrot's own presentation semantics use the parrot_* prefix instead (spec §7).

Attributes:

Attribute Type Description
root dict[str, Any]

Class FunctionCall

Invokes a named function (renderer-side or agent-side; see catalog).

Fields:

Field Type Default Description
call str The name of the function to call (or "@index" for the template-scope system function).
args dict[str, Any] Arguments passed to the function.
catalog_id str | None None The catalog ID for this function, overriding any surface-level default catalogId. Some call sites (e.g. callRendererFunction) require this to be present — that stricter constraint is enforced by jsonschema validation (TASK-2535), not by this shared model.

Class FunctionCallError

An error object indicating failure of a function call.

Attributes:

Attribute Type Description
code str Machine-readable error code.
message str Human-readable error message.

Class RendererFunctionResponse

rendererFunctionResponse — the renderer's response to a callRendererFunction.

Attribute SurfaceMetadata

Class UpdateComponents

updateComponents — update a surface with a new set of components.

Can be sent multiple times. One component across all updateComponents/ inline createSurface components for a surface MUST have id="root".

Attributes:

Attribute Type Description
surface_id str The surface to update.
components list[Component] The new/updated components.

Class UpdateDataModel

updateDataModel — update the data model for an existing surface.

Attributes:

Attribute Type Description
surface_id str The surface whose data model is being updated.
path str | None An optional path within the data model. Omitted (or "/") refers to the entire data model.
value Any The data to write at path. REQUIRED (may be None, which deletes the key/value at path) — a missing value is a validation error, distinct from an explicit null.

Class ValidationResult

The result of evaluating a :class:CheckRule condition.

Not part of the wire schema itself (a CheckRule.condition evaluates to this shape at render time) — this is the FunctionEvaluator (TASK-2537) contract.

Fields:

Field Type Default Description
valid bool Whether the check passed.
code str | None None Optional machine-readable code for the failure.
message str | None None Optional human-readable message.
severity Literal['error', 'warning', 'info'] 'error' The severity of the result when valid is False.

Function is_binding_expression

Return whether value is a legacy data-model binding expression.

A legacy binding is a mapping of the form {"$bind": "<json-pointer>"}. The v1.0 wire uses :class:DataBinding ({"path": "..."}") instead; this helper exists for :mod:parrot.outputs.a2ui.compat to detect the old shape during normalization.

is_binding_expression(value: Any) -> bool

Parameter Type Default Description
value Any Any candidate value.

Returns: bool — True if value is a legacy binding expression mapping, else False.

Function is_valid_pointer

Return whether pointer is a syntactically well-formed JSON Pointer.

This is a shape check only (RFC 6901 grammar). It does NOT verify that the pointer resolves against any document — resolution is the bake pass's job.

is_valid_pointer(pointer: str) -> bool

Parameter Type Default Description
pointer str The candidate JSON Pointer string.

Returns: bool — True if pointer matches the JSON Pointer grammar, else False.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally