Skip to content

fix(adk): support map additionalProperties and bind_param in ToolboxTool - #737

Open
hsusul wants to merge 1 commit into
googleapis:mainfrom
hsusul:fix/adk-schema-additional-properties-and-bind-param
Open

fix(adk): support map additionalProperties and bind_param in ToolboxTool#737
hsusul wants to merge 1 commit into
googleapis:mainfrom
hsusul:fix/adk-schema-additional-properties-and-bind-param

Conversation

@hsusul

@hsusul hsusul commented Jul 27, 2026

Copy link
Copy Markdown

Summary

  • What was wrong: ToolboxTool in toolbox-adk ignored additionalProperties on object/map parameter schemas when building ADK FunctionDeclaration objects (leaving additional_properties=None). Additionally, ToolboxTool lacked the bind_param convenience method available in other packages and threw TypeError when calling bind_params with the keyword argument bound_params.
  • What changed: In toolbox_adk.tool.ToolboxTool._build_schema, schema_additional_properties is now populated from param.additionalProperties and passed to google.genai.types.Schema(..., additional_properties=...). Updated bind_params to accept keyword argument bound_params (preserving backward compatibility with bounded_params), and added bind_param.
  • What regression coverage was added: test_get_declaration_additional_properties and test_bind_param_and_bind_params_keyword in packages/toolbox-adk/tests/unit/test_tool.py.

Problem

  1. When an ADK ToolboxTool was loaded for a tool containing a dictionary/map parameter (such as map<string, string>), _build_schema created a Schema(type=Type.OBJECT) without mapping additionalProperties. As a result, Gemini/ADK function declarations lost value schema constraints for map parameters.
  2. ToolboxTool in toolbox-adk diverged from toolbox-core, toolbox-langchain, and toolbox-llamaindex by missing the bind_param singular method and rejecting bound_params as a keyword argument name.

Root cause

  1. In toolbox_adk.tool.ToolboxTool._build_schema, schema_additional_properties = None was initialized, but never populated from param.additionalProperties and omitted from the Schema(...) constructor arguments.
  2. ToolboxTool in toolbox-adk named its parameter bounded_params instead of bound_params and did not implement bind_param.

Fix

  • In packages/toolbox-adk/src/toolbox_adk/tool.py:
    • Extracted param.additionalProperties in _build_schema and recursively converted it when present (or assigned boolean value when bool), passing additional_properties=schema_additional_properties to Schema(...).
    • Updated bind_params to accept bound_params (while preserving bounded_params fallback for backward compatibility).
    • Added bind_param(param_name, param_value) to delegate to bind_params({param_name: param_value}).

Tests

  • packages/toolbox-adk/tests/unit/test_tool.py:
    • test_get_declaration_additional_properties: Verifies FunctionDeclaration schema preservation for typed and boolean additionalProperties.
    • test_bind_param_and_bind_params_keyword: Verifies calling bind_param and bind_params(bound_params=...).

Validation

  • Executed PYTHONPATH=. /tmp/sdk_env/bin/pytest tests/unit -v inside packages/toolbox-adk: 56 passed.
  • Executed black --check ., isort --check ., and MYPYPATH='./src' mypy --cache-dir=.mypy_cache/ -p toolbox_adk in packages/toolbox-adk: all passed with zero errors.

Compatibility

  • Fixes ADK schema declarations for map/object parameters.
  • Preserves full backward compatibility for bind_params callers while aligning toolbox-adk API with toolbox-core, toolbox-langchain, and toolbox-llamaindex.

Non-goals

  • Did not alter core ParameterSchema or transport schema conversion logic.

@hsusul
hsusul requested a review from a team as a code owner July 27, 2026 19:06
@anubhav756 anubhav756 added the priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. label Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants