Skip to content

feat(tools): Support tuple tool parameters#6076

Closed
RaghunandanKumar wants to merge 8 commits into
google:mainfrom
RaghunandanKumar:fix/issue-3575
Closed

feat(tools): Support tuple tool parameters#6076
RaghunandanKumar wants to merge 8 commits into
google:mainfrom
RaghunandanKumar:fix/issue-3575

Conversation

@RaghunandanKumar

Copy link
Copy Markdown
Contributor

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

Parse homogeneous tuple annotations as array schemas for automatic function declarations instead of falling back to Pydantic JSON schema output that GenAI Schema rejects.

Fixes google#3575
@adk-bot adk-bot added the tools [Component] This issue is related to tools label Jun 11, 2026
@RaghunandanKumar RaghunandanKumar marked this pull request as ready for review June 11, 2026 02:55
@rohityan rohityan self-assigned this Jun 11, 2026
@rohityan rohityan added the request clarification [Status] The maintainer need clarification or more information from the author label Jun 11, 2026
@rohityan

Copy link
Copy Markdown
Collaborator

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.

@RaghunandanKumar

Copy link
Copy Markdown
Contributor Author

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.

@haranrk haranrk assigned haranrk and unassigned rohityan Jun 17, 2026
copybara-service Bot pushed a commit that referenced this pull request Jun 19, 2026
Merge #6076

## 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`

Co-authored-by: Haran Rajkumar <haranrk@google.com>
COPYBARA_INTEGRATE_REVIEW=#6076 from RaghunandanKumar:fix/issue-3575 a53780a
PiperOrigin-RevId: 934745222
@adk-bot

adk-bot commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

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 adk-bot added the merged [Status] This PR is merged label Jun 19, 2026
@adk-bot adk-bot closed this Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged [Status] This PR is merged request clarification [Status] The maintainer need clarification or more information from the author tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Tuple for function tool signature

4 participants