# Six JSON Schema keywords make Gemma 4 31B return malformed tool-call arguments on Bedrock (minLength: 0/20 correct). Probe + write-up

> Source: <https://discuss.huggingface.co/t/six-json-schema-keywords-make-gemma-4-31b-return-malformed-tool-call-arguments-on-bedrock-minlength-0-20-correct-probe-write-up/193028#post_1>
> Published: 2026-12-02 19:11:12+00:00

**Recommendation:** Probe your tool schemas keyword by keyword with repeated calls before shipping; strip minLength, maxLength, maxItems, item-level minLength and uniqueItems from the copy sent to Gemma and keep validation server-side.
More in the playbook "Evals and testing for LLM apps": <https://wpnews.pro/playbooks/evals-testing>

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](https://keiranholloway.github.io/gemma4-toolcall-probe/)

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](https://github.com/keiranholloway/gemma4-toolcall-probe)

Has anyone seen the same on vLLM, llama.cpp or another hosted provider? I’d like to know whether this is specific to Bedrock.
