2 December 2026 · Keiran Holloway
Add minLength: 1 to one string parameter of a tool, and Gemma 4 31B on Amazon Bedrock returns that argument malformed in 20 of 20 calls. Remove the keyword and it is correct in 20 of 20.
The model is not confused. It picks the right tool and, asked to write the same arguments as plain text, writes them correctly every time. The damage happens in the serving layer, in the step that converts Gemma’s own tool-call notation into OpenAI-style tool_calls.
I found two triggers:
minLength, maxLength, pattern, minItems, maxItems and uniqueItems corrupt, empty or reject the parameter they sit on.Two small rewrites in a proxy contain both. On a test environment, accepted calls to the worst-affected tool went from about 12% to 93%, with no corrupted or empty arguments. Two other models ran through the same client and the same tool definitions as a control, and succeeded on every call.
This is a workaround, not a fix. The upstream behaviour has not changed, and I have not proven the root cause.
Gemma 4 does not write tool calls as JSON. It writes its own notation, with bare key names and a special token around strings:
<|tool_call>call:process{action:<|"|>poll<|"|>,sessionId:<|"|>calm-ridge<|"|>,timeout:20000}<tool_call|>
Every serving stack has to parse that into JSON tool_calls. That conversion is where arguments break. Public reports of serving stacks corrupting Gemma 4 tool-call arguments go back to April 2026, the month the model was released.
My setup was an open-source chat client (LibreChat) with MCP tools, a proxy I control, and Bedrock’s OpenAI-compatible endpoint serving google.gemma-4-31b. Requests carried 46 to 67 tool definitions. Unless I say otherwise, the probe results below were measured by sending requests straight to Bedrock, with nothing of mine in the path.
I first saw it on a test tool with one string parameter declared as {"type":"string","minLength":1}. The expected call was {"area":"core"}. The model returned a bad value in 12 of 14 calls:
{"area":":"}
{"area":"};core"}
{"area":">';core'"}
The tool rejected each one with a clear error listing the valid names. The model sent the same bad value again. The turn took about 435 seconds.
I then tested each keyword alone on a neutral five-parameter tool, 20 independent calls per arm. A call counts as correct only when all five arguments are right.
| Keyword added to one parameter | Correct | What comes back when wrong |
|---|---|---|
| None (control) | 20/20 | |
minLength: 1 on a string |
0/20 | ":", "/></network>", "};network" |
maxLength: 50 on a string |
0/20 | Same kind of malformed value |
pattern: ^[a-z-]+$ on a string |
17/20 | Value padded with dashes |
minItems: 1 on an array |
7/20 | Malformed values inside items |
maxItems: 10 on an array |
0/20 | [] every time |
minLength: 1 on array items |
0/20 | [] every time |
uniqueItems: true on an array |
0/20 | HTTP 400, no model output |
minimum, maximum, exclusiveMinimum |
20/20 | |
default, enum, format: date |
20/20 | |
anyOf string or null |
20/20 |
Four things stand out:
maxItems and minLength on items return an empty array. That is valid JSON, so the tool runs with missing input and reports no error.minLength, a fresh chat gave 60% to 85% correct. With one earlier call of the same tool in the history, it gave 0% to 25%..min(1) in a validation library, your tool definition carries minLength.I did not test multipleOf, const, minProperties or maxProperties.
Three checks point at the serving layer.
So the corruption comes from how the serving side uses the schema. Constrained decoding is my suspect. I have not proven it.
No request setting fixed it. Each of these was tested over 20 calls with the schema unchanged and one earlier tool call in the history:
| Setting | Correct |
|---|---|
temperature 0 |
0/20 |
temperature 1.0, top_p 0.95 |
2/20 |
frequency_penalty 0.5 |
1/20 |
tool_choice forced or required |
0/20 |
parallel_tool_calls false |
0/20 |
reasoning_effort low or high |
0/20 |
| Thinking disabled | 3/20 |
| System prompt with an example of the correct call | 2/20 |
| Earlier tool call removed from history | 15/20 |
Prompt-only fixes cannot work here. The damage happens after the model has written the call.
The second trigger involves none of the six keywords. Any parameter that is an object with no declared properties is damaged: a search query, a filter map, any dict.
The intended call, for a search tool that takes an Elasticsearch-style query:
{"search_params":{"query":{"bool":{"must":[{"term":{"tags":"tag_a"}},{"term":{"tags":"tag_b"}}]}}}}
What arrives takes three forms.
Stray punctuation on key names. This was 102 of 141 failures in one replay. The structure is right, but each key the model invents carries a leading comma or semicolon:
{"search_params":{"query":{",bool":{",must":[{",term":{"tags":"tag_a"}},{",term":{"tags":"tag_b"}}]}}}}
Contents dropped. The object arrives empty: "query":{}.
The whole parameter collapses into a string. It holds Gemma’s own notation, sometimes followed by leaked reasoning text.
The pattern is consistent. Names the tool definition declares (search_params, size, sort) always arrive intact. Only keys the model has to invent (bool, must, term) are damaged.
To locate the fault, I sent the same questions and the same tool definition two ways, 24 calls each:
| How the call is returned | Well-formed | Corrupted key names |
|---|---|---|
| Native tool calling | 0/24 | 19/24 |
| Plain JSON text, tool definition in the system message | 16/24 | 0/24 |
With the host’s conversion bypassed, there were no corrupted keys. The plain-text route is not clean either: about a third of replies did not parse as JSON. So it is no free fix.
Arrays with untyped items ({"type":"array","items":{}}) break the same way. A list of [attribute, operator, value] triples arrived as [[true, true, true]] or [[null, null, null]]. As declared, 0 of 12 calls were well-formed. Sent as JSON text, 12 of 12 were.
The free-form fault was not always there. In a deployment I work on, calls to the search tool succeeded 72% of the time up to 6 November 2026. From 12 November, they succeeded 12% of the time.
Nothing on my side changed. The tool definition and system prompt sent to the model were byte-identical before and after, checked by hash.
I then replayed six requests recorded as working in late October, unchanged, on 29 November. Sent straight to Bedrock, 3 of 50 came back well-formed.
Identical input, different output, weeks apart. Something upstream of my proxy changed, and nothing announced it. If you run an open-weight model through a hosted endpoint, your tool-calling behaviour can shift under you with no version bump to pin.
Both rewrites live in a proxy between the client and the model host. Three rules shaped them:
The proxy removes minLength, maxLength, pattern, minItems, maxItems and uniqueItems from every tool schema before it is sent, at any depth. A parameter that happens to be named pattern is data and is kept.
The cost is one round trip: an invalid value is now rejected by the tool instead of being prevented. Limits the model benefits from knowing (“at most 20 items”) belong in the parameter description, since the keywords never reached its prompt anyway.
Each free-form value is presented to the model as a string parameter, then decoded back into an object before the tool call leaves the proxy.
// As the tool server declares it
"query": { "type": "object", "additionalProperties": true, "description": "Search query" }
// As sent to Gemma
"query": { "type": "string", "description": "Search query. Write this value as JSON text." }
Two details matter. Earlier calls of the same tool in the conversation history are rewritten the same way, so the model’s past calls match the parameter it is now asked to fill. And the decode is tolerant: it accepts bare key names, single quotes and a missing outer brace, because Gemma sometimes writes its own notation inside the string.
| Change | Measure | Before | After |
|---|---|---|---|
| Keyword strip | Calls with a valid constrained string, real traffic | 2 of 14 | 80 of 80 |
| Keyword strip | Calls with a non-empty constrained array | Empty every time | 35 of 35 |
| Free-form as JSON text | Keys uncorrupted, first question | 0/20 | 19/20, later 40/40 |
| Free-form as JSON text | Keys uncorrupted, follow-up after an earlier call | 0/40 | 20/20 |
| Untyped arrays as JSON text | Well-formed array of triples | 0/36 | 36/36 |
The free-form and untyped-array rows came from a probe that sent my real tool definition, system prompt and tool list. The public probe uses a stand-in tool and returns different rates. See “Reproduce it” below.
Once keys arrived intact, a second layer showed: clean arguments in the wrong shape, and complete calls that then ran on to the output limit. Narrow, guarded repairs at decode time handled those.
With everything deployed on a test environment, 93% of calls to the search tool were accepted in one day’s run, against about 12% before. Most of the rest were refused by my own limit on repeating a search. Counts of the three damage forms: stray characters on keys 0, empty query 0, whole parameter as text 1.
If you build tools that Gemma 4 will call:
If you run the platform:
{"error": ...} as normal output hid a 70% failure rate from my test runner.If you serve the model: honour a schema keyword, ignore it, or reject it. Returning corrupted arguments is a defect.
The probe is public: gemma4-toolcall-probe. It is one Python file with one dependency, and it works against any OpenAI-compatible endpoint serving Gemma 4.
It has four suites: the schema keywords (16 arms, including a control), free-form objects, untyped arrays, and native tool calling against plain JSON text. Each arm runs 20 calls, fresh and with one earlier tool call in the history. It runs no tools and sends only synthetic data. It also reports prompt token counts per arm, so you can check for yourself that a keyword never reaches the model.
I reran the public probe before publishing: 320 keyword calls, with history. Every keyword arm matched the table above except two, both within what 20 calls per arm allows. minItems gave 9/20 against 7/20, and pattern gave 15/20 against 17/20. uniqueItems was rejected with HTTP 400 every time.
The free-form figures differ more, and you should expect that. The figures in this article came from an earlier probe carrying my real tool definition, system prompt and tool list. The public probe uses a stand-in tool. On the first question it returned well-formed free-form arguments in 21 of 40 calls as declared, where I measured 0 of 20. As JSON text it returned 16 of 40, where I measured 19 of 20. Its JSON-text failures were Lucene-style query strings in place of JSON, so a firmer tool description may help. I have not tested that.
Stand-in and real tool definitions also gave different results during the investigation. Use the probe’s free-form suite to test your own endpoint, and confirm any finding with your real request.
The repository’s README explains how to read the output and lists each failure kind the probe reports.
This class of fault is not new. Gemma 4 was released on 2 April 2026. Four days later, a vLLM issue reported its Gemma 4 parser corrupting tool-call arguments. That bug was fixed within two days, and reports of related faults have continued since.
| Report | What it describes | How it compares |
|---|---|---|
| vLLM #39089 | Opened 6 April 2026. The parser turns boolean true into trutrue in tool-call arguments. Fixed 8 April. |
Earliest dated report I found of parser-side argument corruption |
| vLLM #51284 | The model writes string values inside arrays and objects as plain JSON, and the parser keeps stray quote characters | Closest match: damage inside nested structures, top-level names fine |
| vLLM #39468 | Values wrapped in Gemma’s string-delimiter token, or the raw call returned as message content | Matches the collapse-into-text form |
| vLLM #44522 | Native tool-call markup streamed as plain text, with delimiter fragments leaking into values | Same leak |
| vLLM #47906 | A parser change in one release silently returned numbers, booleans and nulls as strings | A serving upgrade changing output for identical input |
| vLLM #39072 | A required property missing from tool arguments | Same family |
| vLLM #53363 | tool_choice: "required" not enforced with the Gemma 4 parser |
Consistent with tool_choice not helping |
| llama.cpp #21680 | Malformed nested JSON in tool-call arguments for an MCP tool, causing a parse error | Same family, different stack |
| hermes-agent #7457 | A hosted API returns Gemma 4 tool calls as plain text with no tool_calls |
Same family, hosted API |
| Hugging Face forum thread | Collects malformed tool-call reports across stacks | Background |
| Google: function calling with Gemma 4 | The native notation | Reference |
What I did not find: any report linking schema keywords such as minLength to corrupted arguments, any report specific to Bedrock, or an exact match for my most common form, a leading comma or semicolon on the key. The Bedrock behaviour I measured also has its own start date: it appeared between 6 and 12 November 2026.