Skip to content

refactor(formats): introduce InferenceFormat base API#1981

Merged
gspencergoog merged 23 commits into
mainfrom
unified-inference-formats-foundation
Jul 15, 2026
Merged

refactor(formats): introduce InferenceFormat base API#1981
gspencergoog merged 23 commits into
mainfrom
unified-inference-formats-foundation

Conversation

@gspencergoog

@gspencergoog gspencergoog commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Important

Stacked PR Series:

  1. #1981 (Foundation & Experiments API) 👈 This PR
  2. #1982 (Inference Strategies & Eval Solver)
  3. #1996 (Streaming Support)

Summary

This pull request implements a unified strategies framework to support multiple message formats in the Python Agent SDK. It introduces the InferenceFormat base class and separates the standard JSON formatting logic from experimental layouts (such as Express DSL and Elemental).

Changes

  • Added the abstract InferenceFormat class at a2ui/inference_format.py to decouple prompt generation and parsing.
  • Added a2ui/prompt/generator.py and a2ui/prompt/__init__.py to hold the abstract PromptGenerator class, and added a deprecated compatibility shim in a2ui/prompt_generator.py.
  • Moved standard JSON parsing and generation to the TransportFormat strategy under a2ui/inference_formats/transport/.
  • Moved the legacy streaming parser code to a2ui/inference_formats/transport/streaming.py.
  • Converted A2uiSchemaManager (schema/manager.py) to a deprecated compatibility wrapper that delegates to TransportFormat.
  • Created a2ui/validation/validator.py containing a unified A2uiValidator to consolidate validation, moving the legacy validation logic to a2ui/validation/validator_v08.py.
  • Updated A2uiValidator to gate v1.0 schema validation programmatically using experiments configuration instead of fallback environment variables.
  • Added has_format_content to the Parser interface and deprecated the global helper has_a2ui_parts.
  • Removed all remaining A2UI_EXPRESS_ENABLED and A2UI_VERSION_1_0 global environment variable gating checks across the SDK and test suites.

Impact and risks

This change is backward-compatible. By default, the SDK uses the standard JSON strategy (TransportFormat), and experimental formats remain opt-in.

Testing

Run the pytest suite to verify all unit and conformance tests pass:

uv run pytest

gemini-code-assist[bot]

This comment was marked as resolved.

Comment thread agent_sdks/python/a2ui_agent/src/a2ui/a2a/parts.py Outdated
Comment thread agent_sdks/python/a2ui_agent/src/a2ui/formats/__init__.py Outdated
Comment thread agent_sdks/python/a2ui_agent/src/a2ui/formats/__init__.py Outdated
Comment thread agent_sdks/python/a2ui_agent/src/a2ui/formats/__init__.py Outdated
Comment thread agent_sdks/python/a2ui_agent/src/a2ui/formats/__init__.py Outdated
Comment thread agent_sdks/python/a2ui_agent/src/a2ui/formats/__init__.py Outdated
Comment thread agent_sdks/python/a2ui_agent/src/a2ui/formats/__init__.py Outdated
Comment thread agent_sdks/python/a2ui_agent/src/a2ui/formats/__init__.py Outdated
Comment thread agent_sdks/python/a2ui_agent/src/a2ui/schema/manager.py
Comment thread agent_sdks/python/a2ui_agent/src/a2ui/formats/__init__.py Outdated
@gspencergoog
gspencergoog force-pushed the unified-inference-formats-foundation branch from 89a547a to 1134c08 Compare July 10, 2026 16:59
Comment thread agent_sdks/python/a2ui_agent/src/a2ui/a2a/parts.py Outdated
Comment thread agent_sdks/python/a2ui_agent/src/a2ui/formats/__init__.py Outdated
Comment thread agent_sdks/python/a2ui_agent/src/a2ui/formats/__init__.py Outdated
@jacobsimionato

Copy link
Copy Markdown
Collaborator

I think we should get @nan-yu to review this too, because she's driving an overhaul of the inference SDK API surface

Comment thread agent_sdks/python/a2ui_agent/src/a2ui/a2a/parts.py Outdated
Comment thread agent_sdks/python/a2ui_agent/src/a2ui/formats/__init__.py Outdated
@gspencergoog gspencergoog changed the title refactor(formats): introduce InferenceFormat base API and registry refactor(formats): introduce InferenceFormat base API Jul 13, 2026
@gspencergoog
gspencergoog force-pushed the unified-inference-formats-foundation branch from 0c828f8 to bd47ea6 Compare July 13, 2026 19:44
@gspencergoog

Copy link
Copy Markdown
Collaborator Author

I also updated how experiments are enabled, so that it doesn't rely on environment variables at all anymore. The experimental inference formats both rely on 1.0 features, so they needed different validation, which means that we needed some way to configure experiments on the validator and other components.

I opted for an explicit set of experiment strings in the configuration, which seemed to be the cleanest way to enable them.

Comment thread agent_sdks/python/a2ui_agent/src/a2ui/a2a/parts.py Outdated
@gspencergoog
gspencergoog force-pushed the unified-inference-formats-foundation branch 2 times, most recently from 914f571 to 18e7970 Compare July 13, 2026 21:56
Comment thread agent_sdks/python/a2ui_agent/src/a2ui/formats/__init__.py Outdated
Comment thread agent_sdks/python/a2ui_agent/src/a2ui/formats/__init__.py Outdated
Comment thread agent_sdks/python/a2ui_agent/src/a2ui/formats/__init__.py Outdated
Comment thread agent_sdks/python/a2ui_agent/src/a2ui/formats/__init__.py Outdated
Comment thread agent_sdks/python/a2ui_agent/src/a2ui/formats/__init__.py Outdated
@gspencergoog
gspencergoog force-pushed the unified-inference-formats-foundation branch 2 times, most recently from 60ede36 to f22ebed Compare July 13, 2026 22:13
gemini-code-assist[bot]

This comment was marked as resolved.

- Created abstract `InferenceFormat` base class and `Parser.compile` contracts.
- Relocated core transport strategy/parser/streaming files to new package structure under `a2ui.inference_formats.transport`.
- Overwrote legacy strategy and schema paths with deprecation redirects pointing to the new structure.
- Removed legacy `A2uiSchemaManager` references and renamed variables/instances to `transport_format` across all SDK tests, evaluation strategies, and sample agents.
@gspencergoog
gspencergoog force-pushed the unified-inference-formats-foundation branch from bc7c981 to a586f1f Compare July 14, 2026 22:52
@gspencergoog
gspencergoog force-pushed the unified-inference-formats-foundation branch from 0c152db to 6f40a90 Compare July 14, 2026 23:41
@gspencergoog
gspencergoog force-pushed the unified-inference-formats-foundation branch from 4ec172c to 27dffa7 Compare July 15, 2026 00:30
Returns:
The complete generated prompt system instruction.
"""
selected_catalog = self._format.get_selected_catalog(

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.

The get_selected_catalog method can be extracted out as a helper function in the utils/catalog_resolver.py.
https://docs.google.com/document/d/17BuULV88IlsUStOFthGMgfeW1XMtLUyQDm3oflgXi-k/edit?resourcekey=0-fltDWdFS4VEdDHSTzq--QA&tab=t.0#bookmark=id.im80bpefqd27.

The intent is to remove the need for the format instance.

include_schema: bool = False,
include_examples: bool = False,
validate_examples: bool = False,
) -> str:

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.

Are these parameters mostly for backward compatibility?

Comment thread agent_sdks/python/a2ui_agent/src/a2ui/parser/parser.py
Comment thread agent_sdks/python/a2ui_agent/src/a2ui/strategies/schema/__init__.py Outdated
Comment thread agent_sdks/python/a2ui_agent/src/a2ui/prompt_generator.py Outdated
@gspencergoog
gspencergoog merged commit 6cb4599 into main Jul 15, 2026
33 checks passed
@gspencergoog
gspencergoog deleted the unified-inference-formats-foundation branch July 15, 2026 21:30
@github-project-automation github-project-automation Bot moved this from Todo to Done in A2UI Jul 15, 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