litellm/tests/unit/llms/gemini
quietjules bc3113fff2
fix(vertex-ai): send union-root tool schemas as parametersJsonSchema (#51835)
* fix(vertex-ai): send union-root tool schemas as parametersJsonSchema

A function tool whose parameters root is a union (anyOf, oneOf or allOf at
the root, a type list, or a root $ref to one of those) cannot be expressed in
the Vertex and Gemini parameters field, so those tools answered 400. They now
go out as parametersJsonSchema with the caller's JSON Schema unchanged, on both
the tools and the legacy functions paths. Every other tool keeps the converted
parameters it had before. The local token counter also reads
parametersJsonSchema, so these tools still count

* fix(vertex-ai): resolve chained root refs and tuple schemas for parametersJsonSchema

A root $ref that points at another $ref now resolves to its end, so a chain
that ends in a union also goes out as parametersJsonSchema. A schema built
with tuples or sets is turned into its JSON form first, so it no longer falls
back to the parameters field. A type of ["object"] stays on the parameters
field, which already accepts it. Only tools whose root could need
parametersJsonSchema pay for the JSON conversion

* fix(vertex-ai): resolve long root $ref chains without recursion

* fix(vertex-ai): keep parameters for Vertex batch rows and Vertex countTokens

Vertex batch merges every row's keys into one shape, so a parametersJsonSchema tool in one row breaks every parameters row in the file. Vertex countTokens accepts parametersJsonSchema but leaves it out of the count. Both keep sending parameters, and the Gemini API count route keeps parametersJsonSchema, which it counts in full.

* fix(vertex-ai): resolve a root $ref chain in linear time

Walk $defs by name once with cycle detection, so a long missing ref or a
long-named ref cycle beside many defs no longer costs quadratic CPU

* fix(vertex-ai): send a root $ref tool as parametersJsonSchema when a union sits beside the ref

Check the root and every ref on its chain for anyOf, oneOf, allOf, or a non-object type, since a rule next to a $ref was dropped when only the chain's end was checked

* fix(vertex-ai): keep a bare root union tool on parameters when the call can be forced to it

* fix(vertex-ai): keep a bare root union tool on parameters when extra_body forces the call

* fix(vertex-ai): keep integer enums on a tool that extra_body forces back to parameters

* fix(vertex-ai): keep a union beside a looping root $ref on parameters and read the forcing mode in any case

A root union next to a $ref chain that loops back on itself went out as parametersJsonSchema, and Google
answers 400 "circular ref loop" for that, where base sent parameters and got 200. A looping chain now
stays on parameters whatever sits next to the $ref

An extra_body toolConfig with mode "any" forces the call on the Gemini API, but only "ANY" and "VALIDATED"
were read as forcing, so a bare root union tool moved to parametersJsonSchema and the forced call answered
400. The mode is now compared in upper case

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-14 17:29:37 -05:00
..
audio_transcription fix(audio-transcription): keep transcripts out of transcription error messages (#50137) 2026-11-05 18:07:15 -08:00
batches feat(gemini): file-backed batch jobs on /v1/batches with output download and spend tracking (#51032) 2026-11-11 12:00:32 -08:00
decisions feat(gemini): support gemini-decision-1 on /v1/decisions and /v1/systemone (#51220) 2026-11-11 18:33:22 -08:00
files feat(gemini): file-backed batch jobs on /v1/batches with output download and spend tracking (#51032) 2026-11-11 12:00:32 -08:00
google_genai fix(streaming): keep merged think tags balanced and split SSE lines only on CR/LF (#48755) 2026-10-28 17:00:29 -07:00
image_edit fix(vertex_ai): bill gemini image text, thinking and priority tokens at their own rates (#51017) 2026-11-11 02:50:55 +00:00
image_generation test: move whole-unit legacy test files into tests/unit and delete dead skips (#44807) 2026-10-07 05:02:28 +00:00
realtime fix(realtime)!: send the Gemini Live setup at the first content so session.update settings apply (#39864) 2026-10-30 01:31:39 -07:00
videos feat(videos): add first-class OpenRouter video request fields (#50319) 2026-11-06 16:50:48 -08:00
__init__.py
test_cost_calculator.py
test_gemini_client_setup.py chore(cost-map): remove the 52 rows whose provider retired them before 2026 (#49974) 2026-11-03 16:23:06 -08:00
test_gemini_common_utils.py fix(vertex-ai): send union-root tool schemas as parametersJsonSchema (#51835) 2026-11-14 17:29:37 -05:00
test_gemini_image_generation_transformation.py fix(vertex_ai): bill gemini image text, thinking and priority tokens at their own rates (#51017) 2026-11-11 02:50:55 +00:00
test_gemini_streaming.py test: migrate local_testing SDK and provider tests out of build_and_test (#45760) 2026-10-10 23:14:25 +00:00
test_gemini_tts.py fix(gemini)!: answer 400 for an unsupported chat audio format, drop it under drop_params (#49423) 2026-11-02 04:33:19 -08:00
test_image_usage_transformation.py fix(vertex_ai): bill gemini image text, thinking and priority tokens at their own rates (#51017) 2026-11-11 02:50:55 +00:00