v0.20.6-rc0: gemma4: update renderer to match new jinja template (#15490)

Ollama Releases / 4/11/2026

📰 NewsDeveloper Stack & InfrastructureModels & Research

Key Points

  • Google’s updated Jinja template for gemma4 prompted this release to update the renderer for parity with the new template.
  • The change also includes a small upstream-alignment update to the parser because the upstream parsing behavior has slightly shifted.
  • Several edge cases were corrected, particularly around type unions, and the upstream output format is noted as unusual (a stringified array) though models generally handle it.
  • The renderer adds a special-case for very simple AnyOf constructs by treating them as type unions to better support likely uses of type unions in practice.
  • Additional robustness fixes were made, including preferring empty over None, handling tool results with missing IDs more carefully, and a lint fix.
  • gemma4: update renderer to match new jinja template

Google has updated their jinja template for gemma4, and so this change
gives us parity with the new template. The parsing also slightly changed
upstream, so we make a small change to our parser as well.

I've also corrected a few probably existing edge cases, especially
around type unions. The upstream output format is weird (a stringified
array), but in practice the models seem to understand it well.

  • gemma4: special case simple AnyOfs

The upstream template doesn't handle AnyOfs, but since in the previous
commit we saw type unions work reasonably well, I'm now treating very
simple AnyOfs as type unions to help in cases where they might be used

  • fix lint

  • gemma4: prefer empty instead of None

We can't currently distinguish between a result being not-present vs.
empty. The empty case seems more important (e.g., a legitimately empty
tool call)

  • gemma4: be more careful for tool results with missing IDs