Skip to content

fix(tools): handle tuple schemas in function parsing fallback#5429

Open
kaligautier wants to merge 1 commit intogoogle:mainfrom
kaligautier:fix/5428-functiontool-tuple-schema
Open

fix(tools): handle tuple schemas in function parsing fallback#5429
kaligautier wants to merge 1 commit intogoogle:mainfrom
kaligautier:fix/5428-functiontool-tuple-schema

Conversation

@kaligautier
Copy link
Copy Markdown
Contributor

@kaligautier kaligautier commented Apr 21, 2026

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

2. Or, if no issue exists, describe the change:

N/A (issue exists).

Problem:
FunctionTool automatic declaration parsing crashes when a parameter uses
list[tuple[bytes, str]] | None. The fallback path relies on Pydantic schema
output, but google.genai.types.Schema rejects tuple prefixItems, causing a
startup failure.

Solution:
Normalize tuple-related JSON Schema output in the fallback parser before
validation by types.Schema:

  • convert prefixItems to a supported shape (items.anyOf)
  • drop unsupported tuple-only fields (unevaluatedItems, items: false)
  • add a regression test that covers list[tuple[bytes, str]] | None

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Passed locally:

  • uv run --with pytest --with pytest-asyncio pytest tests/unittests/tools/test_from_function_with_options.py -q17 passed
  • uv run --with pytest --with pytest-asyncio pytest tests/unittests/tools/test_build_function_declaration.py tests/unittests/tools/test_function_tool.py tests/unittests/tools/test_from_function_with_options.py -q83 passed

Manual End-to-End (E2E) Tests:

Manual validation using the issue repro signature:

  • Ran from_function_with_options with input_bytes: list[tuple[bytes, str]] | None
  • Verified declaration is generated (no startup crash), required fields are
    computed correctly, and the optional tuple parameter remains nullable.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

This fix intentionally targets schema compatibility in the legacy automatic
function declaration fallback path without changing tool behavior.

@adk-bot adk-bot added the tools [Component] This issue is related to tools label Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FunctionTool automatic parsing fails on list[tuple[bytes, str]] parameter type

2 participants