Gemma 4 template breaks tool schemas
A user found that Gemma 4's default chat template strips nested JSON Schema constructs from tool definitions, so nullable `$ref`-based parameters lose meaning before the model sees them. A small Jinja patch that preserves schema structure fixed tool calling across the affected setups.
This is a classic "the model isn't the bug, the serialization layer is" failure: if the template flattens schema before the prompt is built, tool calling can look unreliable even when the weights are fine.
- –Common MCP and tool schemas rely on `anyOf`, `$ref`, and `$defs`; dropping those breaks more than just one nullable object
- –The fact that Qwen3.5 and gpt-oss worked on the same tool points to a template fidelity issue, not a general inference-engine problem
- –Preserving `oneOf`, `allOf`, `enum`, `const`, and nullable arrays or objects should make Gemma 4 much less brittle in real agent stacks
- –For developers, the takeaway is to inspect rendered prompts and schema expansion, not just model outputs, when tool calls fail
DISCOVERED
45d ago
2026-04-29
PUBLISHED
45d ago
2026-04-29
RELEVANCE
AUTHOR
EntertainmentBroad43
