Skip to content

feat(decision_binder): add ToolPointerBinder and ADK after_tool_callback - #4322

Closed
gspencergoog wants to merge 15 commits into
feat/decision-cascadefrom
feat/decision-binder-adk
Closed

gspencergoog wants to merge 15 commits into
feat/decision-cascadefrom
feat/decision-binder-adk

Conversation

@gspencergoog

Copy link
Copy Markdown
Collaborator

Summary

Adds ToolPointerBinder (a2ui.inference_formats.experimental.decision_binder) and ADK after_tool_callback integration (a2ui.adk.decision_callbacks) so structured tool outputs can bind directly to Express templates, @macro components, 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 for updateDataModel, and transport lowering.
  • python/a2ui_adk/src/a2ui/adk/decision_callbacks.py: untrusted A2UI_VALIDATED_JSON_KEY stripping, short-circuiting when processor_store returns None, transactional RendererState updates, and ADK @experimental decoration.
  • python/a2ui_adk/src/a2ui/adk/a2a/part_converter.py, event_converter.py, and python/a2ui_adk/src/a2ui/adk/__init__.py: allowed_a2ui_tool_names allowlist and lazy make_adk_after_tool_callback export.

Changes

  • Added a2ui.inference_formats.experimental.decision_binder exporting ToolPointerBinder, BindResult, and ExpressSurfaceSpec.
  • Added make_adk_after_tool_callback in python/a2ui_adk/src/a2ui/adk/decision_callbacks.py and lazily re-exported it from a2ui.adk.
  • Added allowed_a2ui_tool_names allowlist parameter to A2uiPartConverter and A2uiEventConverter (rejecting bare strings).
  • Added unit tests in python/a2ui_agent/tests/decision_binder/test_tool_pointer_binder.py and python/a2ui_adk/tests/test_decision_callbacks.py.
  • Updated python/a2ui_agent/CHANGELOG.md and python/a2ui_adk/CHANGELOG.md.

Impact & Risks

  • Importing a2ui.adk does not eagerly load a2ui.adk.decision_callbacks or a2ui.inference_formats.experimental.decision_binder.
  • Raw tool responses containing a spoofed A2UI_VALIDATED_JSON_KEY are stripped before binding or passthrough, and A2uiPartConverter only reads A2UI_VALIDATED_JSON_KEY from explicitly allowlisted tool names (or the A2UI tool / bypass_tool_check=True).

Testing

  • uv run pyink --check python/a2ui_agent python/a2ui_adk
  • uv run --all-packages mypy . and uv run mypy --follow-imports=silent python/a2ui_agent/src/a2ui/inference_formats/experimental/decision_binder/*.py
  • A2UI_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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@gspencergoog
gspencergoog force-pushed the feat/decision-binder-adk branch from 809b4a6 to 39d8a59 Compare November 20, 2026 01:47
@gspencergoog
gspencergoog changed the base branch from feat/decision-kernel-standalone to feat/decision-cascade November 20, 2026 01:47
@gspencergoog
gspencergoog added this pull request to stack #4324 November 20, 2026 01:47
@gspencergoog
gspencergoog force-pushed the feat/decision-binder-adk branch 2 times, most recently from 00d7757 to cd26555 Compare November 20, 2026 03:52
@gspencergoog
gspencergoog removed this pull request from stack #4324 November 20, 2026 22:51
@gspencergoog
gspencergoog added this pull request to stack #4343 November 20, 2026 22:51
@gspencergoog
gspencergoog removed this pull request from stack #4343 November 20, 2026 23:53
@gspencergoog
gspencergoog added this pull request to stack #4345 November 20, 2026 23:53
@gspencergoog
gspencergoog force-pushed the feat/decision-binder-adk branch from 4c6a751 to b755edd Compare November 24, 2026 01:36
@gspencergoog
gspencergoog marked this pull request as ready for review November 24, 2026 01:47
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>
Comment thread python/a2ui_adk/CHANGELOG.md Resolved
@gspencergoog
gspencergoog force-pushed the feat/decision-binder-adk branch from b755edd to afbe0e4 Compare November 30, 2026 16:58
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>
gspencergoog added a commit that referenced this pull request Dec 1, 2026
# Conflicts:
#	python/a2ui_agent/tests/decision/test_decision_kernel.py
# Conflicts:
#	python/a2ui_agent/src/a2ui/inference_formats/experimental/decision/payload_inspector.py
gspencergoog added a commit to gspencergoog/A2UI that referenced this pull request Dec 1, 2026
@gspencergoog

Copy link
Copy Markdown
Collaborator Author

Closing this PR in favor of the modularized replacement stack.

@jacobsimionato: Previous review comments have been incorporated into the replacement PRs:

🤖 Agent-generated

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.

2 participants