litellm/tests/unit/llms/bedrock_mantle
izzybn c1b181c84f
fix(bedrock_mantle): drop the JSON Schema keywords gemma-4 rejects from tool and response schemas (#54214)
* fix(bedrock_mantle): drop the JSON Schema keywords gemma-4 rejects from tool and response schemas

* fix(bedrock_mantle): read gemma-4 schema keyword support from the cost map and clean extra_body schemas

Mantle models whose cost-map entry sets supports_all_json_schema_keywords to false get the refused keywords dropped, a deployment's model_info flag wins, and schemas sent through extra_body on chat and Responses get the same drop

* fix(bedrock_mantle): keep not subschemas and fall back to the gemma-4 name check when the cost map lacks the flag

Dropping a keyword under not forbids values the caller allowed, and Mantle accepts these keywords there. A cost map without supports_all_json_schema_keywords, such as the remote map before this change ships, now still drops the keywords for gemma-4. The flag is also set on the regional gemma-4 rows, and the drop path logs one debug line

* fix(bedrock_mantle): keep min/maxProperties for gemma-4, walk components schemas and read the request region's cost-map row

gemma-4 accepts minProperties and maxProperties, so only the other 17 keywords are dropped.
Root components.schemas entries are walked too, since a #/components/schemas ref reaches them.
The supports_all_json_schema_keywords lookup reads the row for the region the request goes to first,
then the row without a region, then the gemma-4 name fallback.

* fix(bedrock_mantle): drop min/maxProperties again and read the cost-map row for the region each route sends to

* fix(bedrock_mantle): stop the gemma-4 keyword drop from tightening a ref inside not

Once a gemma-4 schema loses a refused keyword, a not with a $ref, $dynamicRef
or $recursiveRef key anywhere under it is dropped whole, since its target may
have lost a keyword and the not would then forbid values the caller allowed.
The rebuild no longer walks into not subtrees, which it kept as sent anyway, so
the cost stays linear. A warning names the model when a keyword was dropped

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-25 07:04:08 +00:00
..
chat test: move whole-unit legacy test files into tests/unit and delete dead skips (#44807) 2026-10-07 05:02:28 +00:00
passthrough test(unit): make every tests/unit directory a package so pytest collection is unique 2026-09-20 11:50:59 +00:00
__init__.py test(unit): make every tests/unit directory a package so pytest collection is unique 2026-09-20 11:50:59 +00:00
test_bedrock_mantle_messages_transformation.py feat(messages): serve bedrock mantle messages on rust only (#52328) 2026-11-18 17:36:06 -08:00
test_bedrock_mantle_responses_transformation.py fix(bedrock_mantle): drop the JSON Schema keywords gemma-4 rejects from tool and response schemas (#54214) 2026-11-25 07:04:08 +00:00
test_bedrock_mantle_transformation.py fix(bedrock_mantle): drop the JSON Schema keywords gemma-4 rejects from tool and response schemas (#54214) 2026-11-25 07:04:08 +00:00