v0.20.3: model/parsers: add gemma4 tool call repair (#15374)

Ollama Releases / 4/7/2026

📰 NewsDeveloper Stack & InfrastructureTools & Practical UsageModels & Research

Key Points

  • v0.20.3では、Gemma4の厳格なツールパーサーが失敗した場合に備えて、よくある誤りを修復するリカバリ手順を追加しました。
  • 修復は複数の候補を生成し、パースできた最初の候補を採用する「候補パイプライン」で実装されています。
  • 修復対象には、Gemma文字列の区切り欠落、シングルクォートによる文字列指定、ツールスキーマ上文字列であるのに生のターミナル値が入るケース、必要な修復後にのみの「オブジェクト閉じ」欠落などが含まれます。
  • #15315に記載された不正なツールコールの回帰テストと、個々の修復ヘルパーおよび候補パイプラインのためのユニットテストが強化されています。

The existing strict gemma4 tool parser is still the primary path, but if
this fails, we try to repair by fixing some of the most commonly seen
mistakes these models seem to make in practice.

We repair by building up a set of candidates, and use the first candidate
that parses.

Repairs cover:

  • missing Gemma string delimiters
  • single-quoted string values, including a dangling Gemma delimiter
  • raw terminal string values (if the corresponding tool schema indicates
    it should be a string)
  • missing object close only after a concrete repair

Add regression coverage for malformed tool calls from issue #15315 and
focused unit tests for the individual repair helpers and candidate
pipeline.