refactor(formats): introduce InferenceFormat base API#1981
Conversation
89a547a to
1134c08
Compare
|
I think we should get @nan-yu to review this too, because she's driving an overhaul of the inference SDK API surface |
0c828f8 to
bd47ea6
Compare
|
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. |
914f571 to
18e7970
Compare
60ede36 to
f22ebed
Compare
- 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.
…nd inference strategy
bc7c981 to
a586f1f
Compare
…hen parser is None
…te parse_response_to_parts
0c152db to
6f40a90
Compare
…tal gating and migrate to programmatic experiments configuration
…A2UI_EXPRESS_ENABLED
4ec172c to
27dffa7
Compare
| Returns: | ||
| The complete generated prompt system instruction. | ||
| """ | ||
| selected_catalog = self._format.get_selected_catalog( |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
Are these parameters mostly for backward compatibility?
Important
Stacked PR Series:
#1981(Foundation & Experiments API) 👈 This PRSummary
This pull request implements a unified strategies framework to support multiple message formats in the Python Agent SDK. It introduces the
InferenceFormatbase class and separates the standard JSON formatting logic from experimental layouts (such as Express DSL and Elemental).Changes
InferenceFormatclass ata2ui/inference_format.pyto decouple prompt generation and parsing.a2ui/prompt/generator.pyanda2ui/prompt/__init__.pyto hold the abstractPromptGeneratorclass, and added a deprecated compatibility shim ina2ui/prompt_generator.py.TransportFormatstrategy undera2ui/inference_formats/transport/.a2ui/inference_formats/transport/streaming.py.A2uiSchemaManager(schema/manager.py) to a deprecated compatibility wrapper that delegates toTransportFormat.a2ui/validation/validator.pycontaining a unifiedA2uiValidatorto consolidate validation, moving the legacy validation logic toa2ui/validation/validator_v08.py.A2uiValidatorto gate v1.0 schema validation programmatically using experiments configuration instead of fallback environment variables.has_format_contentto theParserinterface and deprecated the global helperhas_a2ui_parts.A2UI_EXPRESS_ENABLEDandA2UI_VERSION_1_0global 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: