I spent a while chasing broken tool calls from Gemma 4 31B (Bedrock’s OpenAI-compatible endpoint) and narrowed part of it down to something I haven’t seen reported: specific JSON Schema keywords on a tool parameter.
Each keyword tested alone on a five-parameter tool, 20 calls per arm, with one earlier tool call in the history:
| Keyword on one parameter | Correct | What comes back | |---|---|---| | none (control) | 20/20 | | | minLength: 1 | 0/20 | ":" ,"};network" | | maxLength: 50 | 0/20 | same kind of thing | | maxItems: 10 | 0/20 | [] every time | | minLength on array items | 0/20 | [] every time | | minItems: 1 | 7/20 | malformed items | | pattern | 17/20 | value padded with dashes | | uniqueItems | 0/20 | HTTP 400 | | minimum, maximum, enum, default, format, anyOf null | 20/20 | |
Why I think it’s the serving layer and not the model:
The nasty ones are maxItems and minLength on items: an empty array is valid JSON, so your tool just runs with missing input.
Second trigger: free-form objects (no declared properties) and untyped arrays. Keys the model has to invent come back with stray punctuation, e.g. ",bool", ",must". Declared keys are fine.
Workarounds that held up for me: strip those six keywords from the schema copy sent to Gemma (keep validating on the tool server), and present free-form values as a string holding JSON text, then decode.
Caveats: one model size, one host, root cause unproven (constrained decoding is my guess), and 20 calls per arm. If your validation library emits these keywords (e.g. .min(1)), it’s worth checking your schemas.
Write-up: Six JSON Schema keywords that appear to corrupt Gemma 4 tool calls | Keiran Holloway
Probe (single file, any OpenAI-compatible endpoint): GitHub - keiranholloway/gemma4-toolcall-probe: Probe an OpenAI-compatible endpoint for damaged Gemma 4 tool-call arguments · GitHub
Has anyone seen the same on vLLM, llama.cpp or another hosted provider? I’d like to know whether this is specific to Bedrock.