Skip to content

feat(python): add CatalogSchemaInspector, macro placement hints, and RendererState.commit - #4471

Merged
gspencergoog merged 14 commits into
mainfrom
feat/modular-agent-seams
Dec 2, 2026
Merged

gspencergoog merged 14 commits into
mainfrom
feat/modular-agent-seams

Conversation

@gspencergoog

@gspencergoog gspencergoog commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Add typed catalog-schema inspection (a2ui.utils.experimental), @macro placement hints (allowed_parents, allowed_children), read-only MacroExpander.surface_catalogs tracking, and atomic RendererState.commit / surface_catalogs helpers to a2ui-agent-sdk. External extension packages can inspect catalog schemas, expand @macro components across turns, and commit multi-turn payloads without importing private a2ui.inference_formats._shared modules.

Reviewer Focus

  • python/a2ui_agent/src/a2ui/utils/catalog_inspector.py and python/a2ui_agent/src/a2ui/utils/experimental.py: Read-only schema classification (PropertyKind, PropertyValueType, is_integer, typed enum_values, child_id_key, is_checkable). Marked @experimental and exported from a2ui.utils.experimental because it will be superseded by CatalogModel in a2ui-core.
  • python/a2ui_agent/src/a2ui/transformers/macros/macro.py and expander.py: allowed_parents / allowed_children metadata on @macro, read-only MacroExpander.surface_catalogs tracking across turns, and refactored macro expansion helpers.
  • python/a2ui_agent/src/a2ui/utils/renderer_state.py: Atomic RendererState.commit() and surface_catalogs snapshot, plus widened _PayloadState str | None catalog ID typing.

Changes

  • Added CatalogSchemaInspector, PropertyInfo, PropertyKind, PropertyValueType, and resolve_default_catalog_id in python/a2ui_agent/src/a2ui/utils/catalog_inspector.py and exported them from a2ui.utils.experimental.
  • Moved shared schema and catalog helpers out of a2ui.inference_formats._shared into a2ui.utils._schema_helper and a2ui.utils._catalogs, keeping compatibility shims at the old paths.
  • Added allowed_parents and allowed_children parameters to @macro in python/a2ui_agent/src/a2ui/transformers/macros/macro.py, emitting allowedParents and allowedChildren schema metadata and rejecting bare strings.
  • Added read-only MacroExpander.surface_catalogs tracking and split _expand_component_list into smaller helpers in python/a2ui_agent/src/a2ui/transformers/macros/expander.py.
  • Added RendererState.commit() and surface_catalogs in python/a2ui_agent/src/a2ui/utils/renderer_state.py and widened _PayloadState catalog IDs to str | None.
  • Updated python/a2ui_agent/src/a2ui/utils/_experimental.py so @experimental preserves inspect.iscoroutinefunction for async callables.
  • Added explicit __all__ to python/a2ui_core/src/a2ui/core/schema/__init__.py and its generator in .agents/skills/a2ui-generate-pydantic-models/scripts/codegen_pydantic.py.
  • Added a2ui.experimental to FORBIDDEN_PREFIXES in python/a2ui_agent/tests/test_framework_agnostic.py.
  • Added unit tests in python/a2ui_agent/tests/utils/test_catalog_inspector.py, python/a2ui_agent/tests/test_macro_lowering.py, and python/a2ui_agent/tests/utils/test_experimental.py, and updated python/a2ui_agent/CHANGELOG.md.

Impact & Risks

  • All new a2ui.utils.experimental, RendererState, and @macro additions are backwards compatible with existing defaults (allowed_parents=(), allowed_children=()).
  • CatalogSchemaInspector emits an @experimental UserWarning on construction unless A2UI_SUPPRESS_EXPERIMENTAL_FEATURE_WARNINGS=1 is set.
  • a2ui.core.schema.__all__ is additive and preserves a2ui-core backwards compatibility.

Testing

  1. Run unit tests:
    uv run pytest python/a2ui_agent/tests/test_macro_lowering.py python/a2ui_agent/tests/utils/test_experimental.py python/a2ui_agent/tests/test_framework_agnostic.py python/a2ui_agent/tests/utils/test_catalog_inspector.py python/a2ui_core/tests/test_codegen_pydantic.py
  2. Run type checking:
    uv run mypy python/a2ui_agent/src python/a2ui_core/src/a2ui/core/schema/__init__.py
  3. Check formatting:
    uv run pyink --check python/a2ui_agent python/a2ui_core/src/a2ui/core/schema/__init__.py

@gspencergoog
gspencergoog added this pull request to stack #4475 December 1, 2026 00:11
gemini-code-assist[bot]

This comment was marked as resolved.

gspencergoog added a commit that referenced this pull request Dec 1, 2026
Signed-off-by: Greg Spencer <gspencer@google.com>
@gspencergoog gspencergoog changed the title feat(agent): expose CatalogSchemaInspector, MacroSpec, and lower_messages feat(agent): add CatalogSchemaInspector, macro collision policies, and stateless commit helpers Dec 1, 2026
@gspencergoog
gspencergoog marked this pull request as ready for review December 1, 2026 22:29
@gspencergoog
gspencergoog removed this pull request from stack #4475 December 1, 2026 22:40
@gspencergoog
gspencergoog added this pull request to stack #4501 December 1, 2026 22:46

@nan-yu nan-yu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, Greg! This gives extension packages a clean way to inspect catalogs and transform macros without reaching into _shared. The schema_helper move is byte-identical with working shims, the expander refactor keeps the old behavior, and the transactional commit rolls back correctly across batches, delete/re-create and defaultless surfaces. The full a2ui_agent suite, the codegen tests and mypy all pass locally.

A few things I found, inline:

  • seed_surface_catalogs loses the sidecar surface catalog across turns, so macros on those surfaces stop expanding on turn 2.
  • Icon.name is classified as a plain enum, which hides that it can be bound.
  • v0.8 catalogs are accepted but give wrong metadata.
  • Only the inspector class is marked experimental, not the types it returns.

🤖 Agent-generated

@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

🧹 Docs Site Preview Removed

The preview for PR #4471 has been cleaned up because the pull request is closed.

@jacobsimionato

jacobsimionato commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

@gspencergoog Heads-up as we start implementing #2865 (CatalogMessageTransformer / TransformerPipeline on A2uiGenerator and A2uiRequestProcessor) in a PR stack on top of #4456:

  • CatalogSchemaInspector, MacroSpec / get_macro_spec, and @macro(allowed_parents=..., allowed_children=...) fit cleanly with the pipeline work and are orthogonal.
  • For build_inference_catalogs and lower_messages, our plan is for TransformerPipeline + A2uiRequestProcessor to be the single canonical user-facing integration path (handling both RendererState.transaction() rollback and multi-turn inference_surface_catalogs), so build_inference_catalogs / lower_messages can stay thin low-level wrappers over the same core (or delegate to TransformerPipeline) for a2ui-decision without creating two competing ways to wire macros into agents.

Happy to coordinate as both stacks move forward.

🤖 Agent-generated

gspencergoog added a commit that referenced this pull request Dec 2, 2026
…dererState.commit, drop on_collision, static core __all__)
gspencergoog added a commit that referenced this pull request Dec 2, 2026
@gspencergoog

Copy link
Copy Markdown
Collaborator Author

@gspencergoog Heads-up as we start implementing #2865 (CatalogMessageTransformer / TransformerPipeline on A2uiGenerator and A2uiRequestProcessor) in a PR stack on top of #4456:

@jacobsimionato Sounds good, let's converge on TransformerPipeline / CatalogMessageTransformer from #4533 as the single user-facing composition path.

Current state on my side:

Sound good?

gspencergoog added a commit that referenced this pull request Dec 2, 2026
… and restore synthesizer kernel extensions

Signed-off-by: Greg Spencer <gspencer@google.com>

@nan-yu nan-yu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the quick turnaround! I re-checked the earlier comments against 7a5312c. The Icon.name classification, v0.8 rejection, experimental marking and v1.0-only placement hints are all fixed. The new MacroExpander.surface_catalogs covers most of the multi-turn sidecar case, with one rollback gap left (inline).

The PR title and description also still describe on_collision, seed_surface_catalogs and commit_or_validate_messages, which no longer exist. Could they be refreshed to match the CHANGELOG?

🤖 Agent-generated

@gspencergoog gspencergoog changed the title feat(agent): add CatalogSchemaInspector, macro collision policies, and stateless commit helpers feat(python): add CatalogSchemaInspector, macro placement hints, and RendererState.commit Dec 2, 2026
@jacobsimionato

Copy link
Copy Markdown
Collaborator

@gspencergoog Heads-up as we start implementing #2865 (CatalogMessageTransformer / TransformerPipeline on A2uiGenerator and A2uiRequestProcessor) in a PR stack on top of #4456:

@jacobsimionato Sounds good, let's converge on TransformerPipeline / CatalogMessageTransformer from #4533 as the single user-facing composition path.

Current state on my side:

Sound good?

This sounds good! I'm also trying to see if I can simplify the design a bit for the MessageTransformer stuff e.g. I don't love the concept of binding. Hopefully that will only make the interactions simpler also.

@jacobsimionato jacobsimionato left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM! All Round 3 feedback is cleanly addressed, the merge with main is clean, and splitting the transformer pipeline into #4543 keeps this PR focused. Before squash-merging, please update the PR title and description so they reflect the final API (a2ui.utils.experimental, RendererState.commit/surface_catalogs, and dropping on_collision and the standalone commit helpers).

🤖 Agent-generated

…ages

Move internal schema helper and catalog check modules down into
a2ui.utils (with shims kept in a2ui.inference_formats._shared) to keep
internal imports acyclic, publish CatalogSchemaInspector and PropertyInfo
for typed read-only schema inspection, add allowed_parents and
allowed_children kwargs to @macro, and publish MacroSpec, get_macro_spec,
build_inference_catalogs, and lower_messages.

Signed-off-by: Greg Spencer <gspencer@google.com>
Signed-off-by: Greg Spencer <gspencer@google.com>
Signed-off-by: Greg Spencer <gspencer@google.com>
…public extension guide

Signed-off-by: Greg Spencer <gspencer@google.com>
…dererState.commit, drop on_collision, static core __all__)
…taging

Stage surface_catalogs updates on a local copy inside transform_to_transport so
mid-batch failures leave instance state unchanged, and add a transaction()
context manager so callers can roll back MacroExpander surface tracking when
RendererState.commit rejects a lowered batch.
…degen param

Signed-off-by: Greg Spencer <gspencer@google.com>
@gspencergoog
gspencergoog force-pushed the feat/modular-agent-seams branch from 2dfff42 to bc5a623 Compare December 2, 2026 22:05
@gspencergoog
gspencergoog enabled stacked auto-merge (squash) December 2, 2026 22:13
@gspencergoog
gspencergoog merged commit e6f4ebf into main Dec 2, 2026
57 checks passed
@gspencergoog
gspencergoog deleted the feat/modular-agent-seams branch December 2, 2026 22:21
github-actions Bot added a commit that referenced this pull request Dec 2, 2026
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.

3 participants