Skip to content

fix(llm): normalize Gemini schema union types - #238

Merged
stippi merged 1 commit into
mainfrom
fix/gemini-json-schema-union
Oct 12, 2026
Merged

stippi merged 1 commit into
mainfrom
fix/gemini-json-schema-union

Conversation

@daniel-kurzynski

Copy link
Copy Markdown
Collaborator

Summary

  • normalize array-valued JSON Schema type unions to Gemini-supported anyOf schemas
  • preserve scalar type values and existing schema sanitization behavior
  • add regression coverage for nested union types

Motivation

Gemini's Schema.type accepts a single scalar enum value, while tool definitions may use standard JSON Schema unions such as:

{"type": ["string", "number", "boolean"]}

Sending such a declaration can cause request translation to fail before the model receives the request. Expressing the same union with anyOf is accepted.

Validation

  • cargo test -p llm vertex --lib (14 passed)
  • cargo check -p llm --tests
  • cargo clippy -p llm --all-targets --all-features -- -D warnings
  • cargo fmt --all -- --check
  • git diff --check
  • replayed the complete 146-tool request successfully with the existing stream_function_call_arguments: true behavior retained

This PR intentionally does not change streaming function-call argument behavior.

@stippi
stippi merged commit 533f4bd into main Oct 12, 2026
5 checks passed
@stippi
stippi deleted the fix/gemini-json-schema-union branch October 12, 2026 18:47
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.

2 participants