Skip to content

feat(python): generate Pydantic models and basic catalog for A2UI spec v1.0 - #2308

Open
nan-yu wants to merge 1 commit into
v1_0_firing_python_5_v08from
v1_0_firing_python_6_generate_v10
Open

feat(python): generate Pydantic models and basic catalog for A2UI spec v1.0#2308
nan-yu wants to merge 1 commit into
v1_0_firing_python_5_v08from
v1_0_firing_python_6_generate_v10

Conversation

@nan-yu

@nan-yu nan-yu commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR is Layer 6 in the stacked PR series to implement comprehensive multi-version support and A2UI v1.0 execution in Python.

It generates and registers the strongly typed Pydantic data models and basic catalog definitions for A2UI protocol v1.0:

  • Schema Models (python/a2ui_core/src/a2ui/core/schema/v1_0/):

    • constants.py: Spec version constants (SPEC_VERSION = "v1.0").
    • common_types.py: StrictBaseModel, dynamic value types (DynamicString, DynamicNumber, DynamicBoolean, DynamicValue), DataBinding, FunctionCall, FunctionResponse, ComponentCommon, AccessibilityAttributes.
    • agent_to_renderer.py: Modern outbound messages (CreateSurfaceMessage, UpdateComponentsMessage, UpdateDataModelMessage, DeleteSurfaceMessage, CallRendererFunctionMessage, AgentFunctionResponseMessage, AgentToRendererMessage).
    • renderer_to_agent.py: Modern inbound messages (A2uiRendererActionMessage, CallAgentFunctionMessage, RendererFunctionResponseMessage, A2uiClientErrorMessage, RendererToAgentMessage).
    • renderer_capabilities.py: A2uiRendererCapabilities, V10Capabilities, InlineCatalog, FunctionDefinition, ValidationResult.
    • __init__.py: Version export namespace and backward-compatibility aliases.
  • Basic Catalog (python/a2ui_core/src/a2ui/core/basic_catalog/v1_0/):

    • components.py: 18 basic component models (TextComponent, ButtonComponent, VideoComponent, SliderComponent, TextFieldComponent, etc.) and BASIC_COMPONENTS registration map.
    • function_apis.py: 14 basic function APIs with dynamic arguments (RequiredApi, RegexApi, LengthApi, OpenUrlApi, AndApi, OrApi, NotApi, etc.).
    • __init__.py: BasicCatalog class bound to v1.0 basic catalog ID.
  • Multi-Version Protocol Root (python/a2ui_core/src/a2ui/core/schema/__init__.py):

    • Registered V1_0 = "v1.0" in A2uiProtocolVersion enum.
    • Updated multi-version envelope unions:
      AgentToRendererMessage = Union[
          v0_8.ServerToClientMessage,
          v0_9.ServerToClientMessage,
          v1_0.AgentToRendererMessage,
      ]
      RendererToAgentMessage = Union[
          v0_8.ClientToServerMessage,
          v0_9.ClientToServerMessage,
          v1_0.RendererToAgentMessage,
      ]
  • Generator Enhancements (codegen_pydantic.py):

    • Dynamic common_types import computation based on actual symbols used in generated modules.
    • Strictly conditional generation of styles.py and FunctionDefinition based on schema definitions.

The Stack

  • #2285: feat(skills): add automated Pydantic model generator skill for A2UI schemas
  • #2299: feat(python): establish versioned schema architecture and multi-version envelope unions
  • #2301: feat(python): generate Pydantic model classes and basic catalog for A2UI spec v0.9
  • #2303: feat(python): generate Pydantic model classes and basic catalog for A2UI spec v0.8
  • This PR: feat(python): generate Pydantic models and basic catalog for A2UI spec v1.0

Verification

  • uv run pyink --check .: Passed
  • uv run --all-packages mypy .: Passed (106 source files checked, 0 errors)
  • uv run pytest python/: Passed (722 passed, 2 skipped)

TAG=agy
CONV=707c9b6b-b2da-4940-ba6e-67f0b4f1d563

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for version 1.0 of the A2UI protocol, introducing auto-generated Pydantic models, components, and function APIs for v1_0, and updating multi-version protocol unions. Feedback on the changes highlights two key issues in the code generator: first, a regression where FunctionDefinition in v1_0 compiles to a StrictBaseModel that forbids extra properties, which should be fixed by dynamically injecting additionalProperties: True; second, a potential false positive in import matching where simple substring checks can incorrectly match shorter type names (like DynamicString inside DynamicStringList), which should be resolved using word boundary matching.

Comment thread .agents/skills/a2ui-generate-pydantic-models/scripts/codegen_pydantic.py Outdated
Comment thread .agents/skills/a2ui-generate-pydantic-models/scripts/codegen_pydantic.py Outdated
@nan-yu
nan-yu force-pushed the v1_0_firing_python_6_generate_v10 branch from afd91b6 to 2b8c02c Compare August 17, 2026 21:41
@nan-yu
nan-yu force-pushed the v1_0_firing_python_6_generate_v10 branch from 2b8c02c to 298c40e Compare August 17, 2026 21:58
@nan-yu
nan-yu force-pushed the v1_0_firing_python_6_generate_v10 branch from 298c40e to 90c8e3f Compare August 17, 2026 22:01
@nan-yu
nan-yu force-pushed the v1_0_firing_python_6_generate_v10 branch from 90c8e3f to 74381fc Compare August 17, 2026 22:03
@nan-yu
nan-yu force-pushed the v1_0_firing_python_6_generate_v10 branch from 74381fc to a40f0b7 Compare August 17, 2026 22:07
@nan-yu
nan-yu force-pushed the v1_0_firing_python_6_generate_v10 branch from a40f0b7 to c435582 Compare August 17, 2026 22:31
@nan-yu
nan-yu force-pushed the v1_0_firing_python_6_generate_v10 branch from c435582 to 0bc127d Compare August 17, 2026 22:36
@nan-yu
nan-yu force-pushed the v1_0_firing_python_6_generate_v10 branch from 0bc127d to 9c40d87 Compare August 17, 2026 22:39
@nan-yu
nan-yu force-pushed the v1_0_firing_python_6_generate_v10 branch from 9c40d87 to e25f70f Compare August 17, 2026 22:42
@nan-yu
nan-yu force-pushed the v1_0_firing_python_6_generate_v10 branch from e25f70f to 47fe72b Compare August 17, 2026 23:38
@nan-yu
nan-yu force-pushed the v1_0_firing_python_6_generate_v10 branch from 47fe72b to 907e350 Compare August 18, 2026 00:43
@nan-yu
nan-yu force-pushed the v1_0_firing_python_6_generate_v10 branch from 907e350 to 2f933ad Compare August 18, 2026 01:19
@nan-yu
nan-yu force-pushed the v1_0_firing_python_6_generate_v10 branch from 2f933ad to aa093bc Compare August 18, 2026 04:07
@nan-yu
nan-yu force-pushed the v1_0_firing_python_6_generate_v10 branch 2 times, most recently from e65a90a to d469d2f Compare August 18, 2026 04:16
@nan-yu
nan-yu force-pushed the v1_0_firing_python_6_generate_v10 branch from d469d2f to 4716f6f Compare August 18, 2026 04:29
@nan-yu
nan-yu force-pushed the v1_0_firing_python_6_generate_v10 branch from 4716f6f to 22badcd Compare August 18, 2026 04:38
…c v1.0

- Generate Pydantic schema models for A2UI protocol v1.0 under `python/a2ui_core/src/a2ui/core/schema/v1_0/`:
  - `constants.py`: Spec constants (`SPEC_VERSION = "v1.0"`).
  - `common_types.py`: `StrictBaseModel`, dynamic value types, `DataBinding`, `FunctionCall`, `FunctionResponse`, `ComponentCommon`, `AccessibilityAttributes`.
  - `agent_to_renderer.py`: Modern outbound messages (`CreateSurfaceMessage`, `UpdateComponentsMessage`, `UpdateDataModelMessage`, `DeleteSurfaceMessage`, `CallRendererFunctionMessage`, `AgentFunctionResponseMessage`, `AgentToRendererMessage`).
  - `renderer_to_agent.py`: Modern inbound messages (`A2uiRendererActionMessage`, `CallAgentFunctionMessage`, `RendererFunctionResponseMessage`, `A2uiClientErrorMessage`, `RendererToAgentMessage`).
  - `renderer_capabilities.py`: `A2uiRendererCapabilities`, `V10Capabilities`, `InlineCatalog`, `FunctionDefinition`, `ValidationResult`.
- Generate basic catalog components and function APIs for v1.0 under `python/a2ui_core/src/a2ui/core/basic_catalog/v1_0/`:
  - `components.py`: 18 basic component models and `BASIC_COMPONENTS` list.
  - `function_apis.py`: 14 basic function APIs with dynamic typing.
  - `__init__.py`: `BasicCatalog` registration for v1.0.
- Register `A2uiProtocolVersion.V1_0 = "v1.0"` and update root schema envelope unions in `python/a2ui_core/src/a2ui/core/schema/__init__.py`.
- Improve Pydantic generator (`codegen_pydantic.py`):
  - Dynamic `common_types` import computation based on actual symbols used in generated modules.
  - Strictly conditional `styles.py` and `FunctionDefinition` generation based on specification schema definitions.

TAG=agy
CONV=707c9b6b-b2da-4940-ba6e-67f0b4f1d563
@nan-yu
nan-yu force-pushed the v1_0_firing_python_6_generate_v10 branch from 22badcd to 9fe708e Compare August 18, 2026 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant