Skip to content

fix(google): send tool schemas via parametersJsonSchema#263

Merged
Kamilbenkirane merged 1 commit intomainfrom
fix/gemini-parameters-json-schema
Apr 18, 2026
Merged

fix(google): send tool schemas via parametersJsonSchema#263
Kamilbenkirane merged 1 commit intomainfrom
fix/gemini-parameters-json-schema

Conversation

@Kamilbenkirane
Copy link
Copy Markdown
Member

Summary

Closes #262.

The legacy functionDeclarations[].parameters field restricts enum to TYPE_STRING properties. Any integer Choice constraint (e.g. veo-3.0-generate-001's duration = Choice([4, 6, 8]) or gemini-embedding-001's dimensions = Choice([768, 1536, 3072])) produced a 400 at tool-registration time.

Gemini's November 2025 update introduced parametersJsonSchema, which accepts raw JSON Schema — integer enums, $defs, $ref, anyOf, additionalProperties, and title — with no sanitization (Google announcement). parametersJsonSchema is mutually exclusive with parameters per the API reference.

Change

ToolsMapper._map_user_tool now emits the schema under parametersJsonSchema instead of parameters. The _remove_titles helper is deleted — title is natively supported by the JSON Schema field.

Ecosystem precedent

  • pydantic-ai uses parametersJsonSchema unconditionally in its Gemini provider.
  • Google's python-genai SDK emits deprecation warnings on its legacy Schema.from_json_schema sanitizer, steering callers toward parametersJsonSchema.
  • celeste-python's text-model catalog is entirely 2.5 / 3.x — all within Google's "all actively supported Gemini models" set.

Test plan

  • New tests/unit_tests/test_google_tools_mapper.py covering:
    • Schema emitted under parametersJsonSchema, not parameters.
    • Integer enum on a non-string property preserved.
    • title fields preserved.
    • Tool with no parameters emits no schema field.
  • Full unit test suite passes (598 tests).
  • ruff + mypy clean.

The legacy functionDeclarations[].parameters field restricts enum to
TYPE_STRING properties, so any integer Choice (e.g. veo-3 duration
[4, 6, 8], gemini-embedding dimensions [768, 1536, 3072]) produced a
400 at tool-registration time. Gemini's November 2025 update added
parametersJsonSchema, which accepts raw JSON Schema — integer enums,
$defs, $ref, anyOf, additionalProperties — with no sanitization.

Switch ToolsMapper._map_user_tool to emit parametersJsonSchema and
drop the now-unused _remove_titles helper (title is natively
supported by the JSON Schema field).

Closes #262.
@Kamilbenkirane Kamilbenkirane merged commit a669031 into main Apr 18, 2026
11 checks passed
@claude
Copy link
Copy Markdown

claude bot commented Apr 18, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

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.

Gemini tool registration rejects integer-Choice constraints; use parametersJsonSchema instead of legacy parameters

1 participant