Repository navigation
feat(decision_binder): add ToolPointerBinder and ADK after_tool_callback - #4322
gspencergoog wants to merge 15 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces ToolPointerBinder to bind tool-result JSON Pointers directly into Express templates, @macro components, and Client-Side Templates without requiring an extra LLM synthesis call. It also adds make_adk_after_tool_callback to integrate this binder into ADK pipelines, and updates A2uiPartConverter and A2uiEventConverter with an allowed_a2ui_tool_names allowlist. Feedback on the changes includes defensively verifying that extracted text attributes are strings in _extract_intent to avoid runtime errors, and adding a safety limit to the suffix collision resolution loop in _choose_surface_id to prevent potential infinite loops.
809b4a6 to
39d8a59
Compare
00d7757 to
cd26555
Compare
4c6a751 to
b755edd
Compare
Signed-off-by: Greg Spencer <gspencer@google.com>
…acros and fill_macro Signed-off-by: Greg Spencer <gspencer@google.com>
… catalog_id Signed-off-by: Greg Spencer <gspencer@google.com>
b755edd to
afbe0e4
Compare
# Conflicts: # python/a2ui_adk/CHANGELOG.md # python/a2ui_agent/CHANGELOG.md
Signed-off-by: Greg Spencer <gspencer@google.com>
Signed-off-by: Greg Spencer <gspencer@google.com>
Signed-off-by: Greg Spencer <gspencer@google.com>
# Conflicts: # python/a2ui_agent/CHANGELOG.md
The ADK callback could leave a spoofed validated-JSON key in a tool response, crashed the turn when the decision model failed, and tied a2ui.adk to the experimental binder. The binder trusted model answers it had not offered, mishandled enums with a "none" value, and redacted the data model with rules that differed from pointer inspection. - Replace make_adk_after_tool_callback with the generic make_tool_ui_callback in a2ui.adk, and move the binder adapter to a2ui.adk.experimental as make_tool_pointer_binder_callback. - Strip the untrusted key in place and return a truthy override, since ADK discards a falsy one. Make skip_summarization configurable. - Catch binder and validation errors, and validate against a stateless processor's catalogs. - Add redact_payload to the decision kernel so inspection and redaction share one set of rules, and skip keys a renderer cannot address. - Accept only offered targets and options, reject boolean answers with no probability mass, and split slot questions to fit max_pairs. - Replace express_surfaces with the SurfaceTemplate protocol and the ExpressSurfaceTemplate adapter, which enforces the bound surface ID and keeps template defaults. - Make Client-Side Template discovery opt-in with template_catalogs, reject ambiguous bare names, reserved macro parameters, and pre-v1.0 catalogs. - Split binder.py into target, slot, prompt, and Express modules. - Ignore malformed validated payloads in A2uiPartConverter. Signed-off-by: Greg Spencer <gspencer@google.com>
# Conflicts: # python/a2ui_agent/tests/decision/test_decision_kernel.py
# Conflicts: # python/a2ui_agent/src/a2ui/inference_formats/experimental/decision/payload_inspector.py
…and part converter
|
Closing this PR in favor of the modularized replacement stack. @jacobsimionato: Previous review comments have been incorporated into the replacement PRs:
🤖 Agent-generated |
Summary
Adds
ToolPointerBinder(a2ui.inference_formats.experimental.decision_binder) and ADKafter_tool_callbackintegration (a2ui.adk.decision_callbacks) so structured tool outputs can bind directly to Express templates,@macrocomponents, or Client-Side Templates without an extra LLM synthesis call.Reviewer Focus
python/a2ui_agent/src/a2ui/inference_formats/experimental/decision_binder/binder.py: target eligibility, 1-call vs 2-call pair budgeting, unclassified required-property checks, recursive secret/excluded-path redaction forupdateDataModel, and transport lowering.python/a2ui_adk/src/a2ui/adk/decision_callbacks.py: untrustedA2UI_VALIDATED_JSON_KEYstripping, short-circuiting whenprocessor_storereturnsNone, transactionalRendererStateupdates, and ADK@experimentaldecoration.python/a2ui_adk/src/a2ui/adk/a2a/part_converter.py,event_converter.py, andpython/a2ui_adk/src/a2ui/adk/__init__.py:allowed_a2ui_tool_namesallowlist and lazymake_adk_after_tool_callbackexport.Changes
a2ui.inference_formats.experimental.decision_binderexportingToolPointerBinder,BindResult, andExpressSurfaceSpec.make_adk_after_tool_callbackinpython/a2ui_adk/src/a2ui/adk/decision_callbacks.pyand lazily re-exported it froma2ui.adk.allowed_a2ui_tool_namesallowlist parameter toA2uiPartConverterandA2uiEventConverter(rejecting bare strings).python/a2ui_agent/tests/decision_binder/test_tool_pointer_binder.pyandpython/a2ui_adk/tests/test_decision_callbacks.py.python/a2ui_agent/CHANGELOG.mdandpython/a2ui_adk/CHANGELOG.md.Impact & Risks
a2ui.adkdoes not eagerly loada2ui.adk.decision_callbacksora2ui.inference_formats.experimental.decision_binder.A2UI_VALIDATED_JSON_KEYare stripped before binding or passthrough, andA2uiPartConverteronly readsA2UI_VALIDATED_JSON_KEYfrom explicitly allowlisted tool names (or the A2UI tool /bypass_tool_check=True).Testing
uv run pyink --check python/a2ui_agent python/a2ui_adkuv run --all-packages mypy .anduv run mypy --follow-imports=silent python/a2ui_agent/src/a2ui/inference_formats/experimental/decision_binder/*.pyA2UI_SUPPRESS_EXPERIMENTAL_FEATURE_WARNINGS=1 uv run pytest python/a2ui_agent/tests/decision_binder/ python/a2ui_agent/tests/test_experimental_import_isolation.py python/a2ui_adk/tests/ -q