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

Ollama Releases / 4/7/2026

📰 NewsDeveloper Stack & InfrastructureTools & Practical Usage

Key Points

  • v0.20.3-rc0では、Gemma4のツール呼び出しパーサーについて、既存の厳格パスで失敗した場合に自動修復(repair)を試みる仕組みが追加されました。
  • 修復は複数候補(candidates)を段階的に生成し、最初にパースできた候補を採用する方式で実装されています。
  • 修復対象には、Gemma文字列の区切り欠落、単一引用符の文字列(ぶら下がった区切りを含む)、ツールスキーマ上文字列であるのに生の終端文字列になっているケース、などが含まれます。
  • さらに、壊れたツール呼び出しに対する回帰カバレッジ(issue #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.