Skip to content

feat: implement schema packaging and runtime loading#555

Merged
gspencergoog merged 1 commit intogoogle:mainfrom
nan-yu:a2ui-schema-manager
Feb 13, 2026
Merged

feat: implement schema packaging and runtime loading#555
gspencergoog merged 1 commit intogoogle:mainfrom
nan-yu:a2ui-schema-manager

Conversation

@nan-yu
Copy link
Collaborator

@nan-yu nan-yu commented Jan 27, 2026

  • Add a base InferenceStrategy class
  • Add PackSpecsBuildHook to copy JSON schemas into the package during build time.
  • Update pyproject.toml to include assets and configure the build hook.
  • Implement A2uiSchemaManager for robust schema loading, pruning, and prompt generation.

Description

Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.

List which issues are fixed by this PR. For larger changes, raising an issue first helps reduce redundant work.

Pre-launch Checklist

If you need help, consider asking for advice on the discussion board.

Copy link
Contributor

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

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 introduces schema packaging and runtime loading capabilities, along with a base InferenceStrategy class and an A2uiSchemaManager. The changes include adding a build hook to copy JSON schemas into the package, updating pyproject.toml to include these assets, and implementing robust schema loading and prompt generation logic. New test files have also been added to cover the new functionality. Dependency updates in uv.lock are also included, which appear to be routine updates.

@nan-yu nan-yu force-pushed the a2ui-schema-manager branch 7 times, most recently from c6f12bb to c290c91 Compare January 28, 2026 18:35
@nan-yu nan-yu force-pushed the a2ui-schema-manager branch 3 times, most recently from 1f7fd48 to 957e27d Compare February 11, 2026 23:51
@nan-yu nan-yu force-pushed the a2ui-schema-manager branch 2 times, most recently from 9939eff to 8c55d42 Compare February 12, 2026 17:57
@google google deleted a comment from gemini-code-assist bot Feb 13, 2026
@google google deleted a comment from nan-yu Feb 13, 2026
@google google deleted a comment from gemini-code-assist bot Feb 13, 2026
@gspencergoog
Copy link
Collaborator

/gemini summary

@gemini-code-assist
Copy link
Contributor

gemini-code-assist bot commented Feb 13, 2026

Summary of Changes

This pull request significantly enhances the A2UI agent's capability to manage and utilize JSON schemas for LLM interactions. It establishes a streamlined process for packaging schemas with the Python distribution, ensures flexible runtime loading and resolution of these schemas, and provides tools for dynamically adapting the schema content based on client needs. This foundational work improves the agent's ability to generate accurate and context-aware system prompts for various UI configurations and custom components.

Highlights

  • Schema Packaging and Build Hook: Implemented a PackSpecsBuildHook using Hatchling to automatically copy A2UI JSON schemas from the monorepo's specification directory into the Python package's assets during the build process, ensuring schemas are bundled with the distribution.
  • Dynamic Schema Loading and Management: Introduced A2uiSchemaManager for robust runtime loading of A2UI schemas (server-to-client, common types, and catalogs). This manager supports loading from package resources or the filesystem, handles schema versioning, and resolves references within schemas.
  • Schema Pruning and Customization: Added functionality within A2uiCatalog and A2uiSchemaManager to prune schemas based on allowed components and to resolve custom catalog schemas against a basic catalog, enabling flexible adaptation to client UI capabilities and custom component definitions.
  • LLM System Prompt Generation: The A2uiSchemaManager now provides a method to generate comprehensive LLM system prompts, incorporating role descriptions, workflow details, UI descriptions, and optionally including the relevant A2UI schemas and examples.
  • Core Abstraction for Inference Strategies: Defined a base abstract class InferenceStrategy to standardize the interface for generating system prompts, allowing for different implementations like schema-based or template-based approaches.
  • Dependency Updates: Updated various Python dependencies in uv.lock, including google-adk, google-genai, packaging, pycparser, pyparsing, and sqlalchemy, and adjusted the typing-extensions marker.
Changelog
  • a2a_agents/python/a2ui_agent/.gitignore
    • Added a new entry to ignore packaged JSON schema assets.
  • a2a_agents/python/a2ui_agent/pack_specs_hook.py
    • Added a new build hook to copy JSON schema files into the Python package during build time.
  • a2a_agents/python/a2ui_agent/pyproject.toml
    • Updated build configuration to include schema assets in wheels and sdists.
    • Configured the new PackSpecsBuildHook to run during the build process.
  • a2a_agents/python/a2ui_agent/src/a2ui/inference/init.py
    • Added an empty __init__.py file to mark the directory as a Python package.
  • a2a_agents/python/a2ui_agent/src/a2ui/inference/inference_strategy.py
    • Added a new abstract base class InferenceStrategy for defining common prompt generation methods.
  • a2a_agents/python/a2ui_agent/src/a2ui/inference/schema/init.py
    • Added an empty __init__.py file to mark the directory as a Python package.
  • a2a_agents/python/a2ui_agent/src/a2ui/inference/schema/catalog.py
    • Added a new module defining CustomCatalogConfig and A2uiCatalog dataclasses.
    • Implemented methods for schema pruning, example loading, and reference resolution within catalogs.
  • a2a_agents/python/a2ui_agent/src/a2ui/inference/schema/constants.py
    • Added a new module to centralize constants related to A2UI assets, schema keys, and repository root discovery.
  • a2a_agents/python/a2ui_agent/src/a2ui/inference/schema/loader.py
    • Added a new module defining abstract and concrete classes for loading JSON schema files from various sources.
  • a2a_agents/python/a2ui_agent/src/a2ui/inference/schema/manager.py
    • Added a new module implementing A2uiSchemaManager for comprehensive schema loading, management, and prompt generation.
    • Integrated fallback logic for schema loading from package resources, local assets, and source repository.
  • a2a_agents/python/a2ui_agent/src/a2ui/inference/template/init.py
    • Added an empty __init__.py file to mark the directory as a Python package.
  • a2a_agents/python/a2ui_agent/src/a2ui/inference/template/manager.py
    • Added a new module defining A2uiTemplateManager as a placeholder for future template-based prompt generation.
  • a2a_agents/python/a2ui_agent/tests/inference/test_catalog.py
    • Added new unit tests for the A2uiCatalog class, covering its properties and methods.
  • a2a_agents/python/a2ui_agent/tests/inference/test_resolve_catalog_schema.py
    • Added new unit tests for the A2uiCatalog.resolve_schema static method, verifying schema reference resolution.
  • a2a_agents/python/a2ui_agent/tests/inference/test_schema_manager.py
    • Added new unit tests for the A2uiSchemaManager class, covering initialization, schema loading, and prompt generation logic.
  • a2a_agents/python/a2ui_agent/tests/integration/verify_load_real.py
    • Added a new integration test to verify the successful loading of A2uiSchemaManager for different schema versions.
  • a2a_agents/python/a2ui_agent/uv.lock
    • Updated the version of typing-extensions to support Python 3.13.
    • Updated the google-adk dependency from 1.22.1 to 1.23.0.
    • Updated the google-genai dependency from 1.59.0 to 1.60.0.
    • Updated the packaging dependency from 25.0 to 26.0.
    • Updated the pycparser dependency from 2.23 to 3.0.
    • Updated the pyparsing dependency from 3.3.1 to 3.3.2.
    • Updated the sqlalchemy dependency from 2.0.45 to 2.0.46.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/python_a2ui_agent_build_and_test.yml
Activity
  • A bot suggested improving the repo_root calculation in pack_specs_hook.py to be more robust than hardcoded relative paths.
  • The author updated pack_specs_hook.py to dynamically find the repository root by searching for the specification directory.
  • A bot suggested improving the repo_root calculation in manager.py to be more robust than hardcoded relative paths.
  • The author updated manager.py to dynamically find the repository root by searching for the specification directory.
  • A bot suggested using copy.deepcopy instead of json.loads(json.dumps(...)) for deep copying schema objects in catalog.py.
  • The author implemented the suggestion to use copy.deepcopy in catalog.py.

- Add a base InferenceStrategy class
- Add PackSpecsBuildHook to copy JSON schemas into the package during
  build time.
- Update pyproject.toml to include assets and configure the build hook.
- Implement A2uiSchemaManager for robust schema loading, pruning, and
  prompt generation.
@nan-yu nan-yu force-pushed the a2ui-schema-manager branch from 8c55d42 to 2f65262 Compare February 13, 2026 19:12
@gspencergoog gspencergoog merged commit 7c454a0 into google:main Feb 13, 2026
7 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in A2UI Feb 13, 2026
@nan-yu nan-yu deleted the a2ui-schema-manager branch February 13, 2026 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants