adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

feat(tools): Support tuple tool parameters

Open RaghunandanKumar opened this issue 5 months ago • 2 comments

Summary

  • Support homogeneous tuple annotations such as tuple[float, float] and tuple[str, ...] in automatic function declarations.
  • Parse supported tuples as array schemas instead of falling back to Pydantic JSON schema fields that google.genai.types.Schema rejects.
  • Add regression coverage for tuple tool parameters and optional tuple parameters.

Fixes #3575

Verification

  • uv run pytest tests/unittests/tools/test_from_function_with_options.py -q
  • uv run pytest tests/unittests/tools -q
  • uv run pre-commit run --files src/google/adk/tools/_function_parameter_parse_util.py tests/unittests/tools/test_from_function_with_options.py

RaghunandanKumar avatar Jun 11 '26 02:06 RaghunandanKumar

Hi @RaghunandanKumar , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Can you please fix the failing mypy-diff tests before we can proceed with the review.

rohityan avatar Jun 11 '26 21:06 rohityan

Hi @rohityan, I pushed a follow-up fix in 703a108e for the failing mypy-diff check.

The issue was the new tuple handling comparing the typed get_origin(...) result against tuple, which mypy reported as a new comparison-overlap error. I typed the local origin value as Any before the runtime origin checks and kept the tuple behavior unchanged.

Local verification:

  • uv run pytest tests/unittests/tools/test_from_function_with_options.py -> 17 passed
  • uv run pyink src/google/adk/tools/_function_parameter_parse_util.py tests/unittests/tools/test_from_function_with_options.py --check -> passed
  • Re-ran the CI-style mypy error filter; the new tuple comparison-overlap error is no longer present. The remaining output matches existing repo baseline errors.

The new PR head currently shows check-changes, cla/google, and header-check passing; the mypy/test workflows have not appeared in the check rollup yet.

RaghunandanKumar avatar Jun 12 '26 00:06 RaghunandanKumar

Thank you @RaghunandanKumar for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit a57c3e4.

Closing this PR as the changes are now in the main branch.

adk-bot avatar Jun 19 '26 06:06 adk-bot