Repository navigation
feat(agent-sdk): add decision model core types, payload inspector, and single-call backends - #4154
gspencergoog wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the a2ui.inference_formats.decision module, providing a catalog-agnostic local decision-model A2UI synthesis framework. It includes various inference backends, data models, a payload inspector, semantic type classifiers, and a template registry, along with comprehensive unit tests. The review feedback highlights several robustness and compatibility improvements: ensuring custom model configurations are preserved for native Jev backends to support custom calibration, validating DecisionQuestion.id earlier in initialization to avoid misleading exceptions, using shutil.which to dynamically resolve the gcloud executable path for cross-platform compatibility, and using substring matching instead of endswith to robustly identify chat completion endpoints with query parameters.
2a1f897 to
07c5191
Compare
🧹 Docs Site Preview RemovedThe preview for PR #4154 has been cleaned up because the pull request is closed. |
…d single-call backends Squashed from the stacked branch history (backup: refs/backups/pre-squash-20261118/feat/decision-core-backends). PR: #4154
b483a8b to
ae7e1d9
Compare
…d single-call backends Squashed from the stacked branch history (backup: refs/backups/pre-squash-20261118/feat/decision-core-backends). PR: #4154
ae7e1d9 to
be57289
Compare
…d single-call backends Squashed from the stacked branch history (backup: refs/backups/pre-squash-20261118/feat/decision-core-backends). PR: #4154
be57289 to
3817090
Compare
…d single-call backends Squashed from the stacked branch history (backup: refs/backups/pre-squash-20261118/feat/decision-core-backends). PR: #4154
3817090 to
e9f8bae
Compare
…d single-call backends Squashed from the stacked branch history (backup: refs/backups/pre-squash-20261118/feat/decision-core-backends). PR: #4154
Move httpx>=0.27.0 out of a2ui-agent-sdk's unconditional dependencies into [project.optional-dependencies] decision (and [dependency-groups] dev for tests). Guard the httpx import in backends.py and fail with an actionable ImportError when constructing HTTP backends without the extra. Extend the isolated CI check to verify httpx is not installed by default. Signed-off-by: Greg Spencer <gspencer@google.com>
…spection Signed-off-by: Greg Spencer <gspencer@google.com>
…eflight, and error redaction - Ignore RuntimeError when closing stale/foreign-loop httpx clients. - Cancel sibling step-zero scoring tasks when one question fails. - Coalesce concurrent ADC token refreshes per event loop. - Expand URL sanitization regex to all schemes, guard urlsplit ValueError, and sanitize HTTP error details. - Bound [^}]* prefix in _CODE_SYNTAX_RE to prevent quadratic backtracking. Signed-off-by: Greg Spencer <gspencer@google.com>
e9f8bae to
4d2c1e6
Compare
Summary
Adds the core data models, payload inspector, catalog graph, template registry, shape-keyed plan cache, and backend adapters for
a2ui.inference_formats.experimental.decisionina2ui-agent-sdk. HTTP backends (JevHttpBackendandStepZeroLogprobBackend) depend onhttpxthrough the optionala2ui-agent-sdk[decision]extra so the default SDK install adds no new runtime dependencies.Reviewer Focus
python/a2ui_agent/pyproject.tomlandpython/a2ui_agent/src/a2ui/inference_formats/experimental/decision/backends.py: check thathttpx>=0.27.0is declared under[project.optional-dependencies] decision(and[dependency-groups] devfor tests), the top-levelhttpximport is guarded,DeterministicMockBackendworks withouthttpx, and HTTP backend constructors and factories raiseImportErrorpointing topip install 'a2ui-agent-sdk[decision]'.python/a2ui_agent/src/a2ui/inference_formats/experimental/decision/models.py: inspect the public dataclasses (DecisionQuestion,DecisionBatch,DecisionAnswer,ActionSpec,Calibration,SynthesisConfig,LayoutPlan,PlannedBlockwith its optionalid_prefix,SynthesisOutput,DecisionBackendError).python/a2ui_agent/src/a2ui/inference_formats/experimental/decision/backends.py: checkDecisionBackend(answer(batch)only),JevHttpBackend(pinnedjev-1.14.0for/v1/systemoneandgemini-decision-1for/v1beta/decisions, 30s HTTP timeout, server-reportedlast_call_latency_ms),StepZeroLogprobBackend, andcalibration_profiles.json.python/a2ui_agent/src/a2ui/inference_formats/experimental/decision/plan_cache.py: review the LRUPlanCachekeyed by(surface_id, shape_signature, actions_sig, mutable_paths, exclude, layout_brief)for zero-backend-call repeat renders.python/a2ui_agent/src/a2ui/inference_formats/experimental/decision/payload_inspector.pyandsemantic_types.py: check JSON Pointer extraction, value-shape classification, sensitive-key detection, collection homogeneity analysis, and grouped-array detection. An array whose elements are small wrapper objects around a nested array of objects (for examplemenuSections[i].items) is indexed as one pointer per section withgroupParent,groupIndex, andgroupLabelPointerhints, while flat arrays and rich records that merely contain a sub-array are left alone.python/a2ui_agent/src/a2ui/inference_formats/experimental/decision/template_registry.py: inspect template candidate filtering, pointer binding rules, and synthesized template promotion.Changes
models.py, including structuredActionSpecdeclarations,PlanReasonandFallbackSourceenums,BackendCapabilities,Calibration, andPlannedBlock.id_prefixso several blocks of one kind (grouped collections) get distinct component ids.DecisionBackendadapters inbackends.py(JevHttpBackendsupporting TypeSafe Jev/v1/systemoneand the Google Gemini Decisions API/v1beta/decisions,StepZeroLogprobBackend, andDeterministicMockBackend) and shipcalibration_profiles.jsonforjev/jev-1.14.0andgemini/gemini-decision-1.httpx>=0.27.0as an optional[decision]extra inpython/a2ui_agent/pyproject.toml(plus[dependency-groups] dev), guard thehttpximport inbackends.py, and check_require_httpx()in HTTP backend constructors and factories..github/workflows/python_ci.ymlto verifya2ui-agent-sdkdoes not pull inhttpx,DeterministicMockBackend()works without it, andJevHttpBackend(...)raises anImportErrorwith the install hint.plan_cache.py(PlanCache,PlanCacheKey,CachedPlan) to cache synthesized layout plans and component blueprints by payload shape signature.payload_inspector.pyandsemantic_types.pyto classify JSON leaf pointers, collection shapes, grouped section arrays, and mutable field candidates without leaking raw user strings.humanize_keykeeps acronyms (CPU,URL), and string values carrying an ISO currency suffix or an hours unit classify ascurrencyorduration.catalog_graph.py(includingdeclared_functions()for catalog-gated formatting),bindings.py, andtemplate_registry.pyto index catalog components, A2UI v1.0 data-path bindings, and registered surface templates.a2ui.inference_formats.experimental.decisionand add unit suites underpython/a2ui_agent/tests/decision/, includingtest_http_backends_require_the_decision_extra.Impact & Risks
a2ui.inference_formats.experimental.decisioninpython/a2ui_agent, alongside the other experimental formats (elemental,atom). Existing inference formats (express,direct_json) and the defaulta2ui-agent-sdkdependency set are unaffected.JevHttpBackendandStepZeroLogprobBackendraiseImportErrorwhenhttpxis not installed andDecisionBackendErrorwhen credentials, endpoints, or local models are missing instead of substituting mock answers.Testing
uv run pytest python/a2ui_agent/tests/decision -qto check model invariants, backend adapters, optionalhttpxgating, calibration scaling, plan cache eviction, payload inspection (flat, nested, and grouped arrays), catalog indexing, and template matching.uv run --isolated --no-project --with ./python/a2ui_core --with ./python/a2ui_agent python -c "import importlib.util, a2ui.inference_formats.experimental.decision as d; assert importlib.util.find_spec('httpx') is None; d.DeterministicMockBackend()"to verify the isolated install.uv run --all-packages mypy python/a2ui_agent/srcanduv run pyink --check python/a2ui_agent.