ollama - ✅(Solved) Fix Gemma4 with ollama 0.20.1 still have tool parsing error [1 pull requests, 22 comments, 8 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
ollama/ollama#15315Fetched 2026-04-08 02:44:19
View on GitHub
Comments
22
Participants
8
Timeline
51
Reactions
4
Assignees
Timeline (top)
commented ×22subscribed ×16referenced ×5mentioned ×3

Error Message

After updating with ollama version 0.20.1 for fixing gemma4 tool parsing error(#15254), ollama still show errors on tool calling. time=2026-04-04T13:58:18.757+09:00 level=WARN source=gemma4.go:293 msg="gemma4 tool call parsing failed" error="invalid character '' looking for beginning of value" content="call:write{content:\n\n# Project Style Guide for Autonomous Agents' Code Generation (AGENTS.md)\n\nThis document captures the *de facto* coding standards observed across the src/andcomponents/` source code, designed to ensure consistency for all generated code and modules consumed by the agent system. time=2026-04-04T13:57:33.487+09:00 level=WARN source=gemma4.go:293 msg="gemma4 tool call parsing failed" error="invalid character '\'' looking for beginning of value" content="call:grep{include:<|"|>.py<|"|>,output_mode:<|"|>content<|"|>,path:<|"|>/data/robotics/experiment1<|"|>,pattern:':\s\w+'<|"|>}"

PR fix notes

PR #15374: model/parsers: add gemma4 tool call repair

Description (problem / solution / changelog)

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.

Changed files

  • model/parsers/gemma4.go (modified, +371/-4)
  • model/parsers/gemma4_test.go (modified, +441/-5)

Code Example

time=2026-04-04T13:58:18.757+09:00 level=WARN source=gemma4.go:293 msg="gemma4 tool call parsing failed" error="invalid character '`' looking for beginning of value" content="call:write{content:\n\n# Project Style Guide for Autonomous Agents' Code Generation (AGENTS.md)\n\nThis document captures the *de facto* coding standards observed across the `src/` and `components/` source code, designed to ensure consistency for all generated code and modules consumed by the agent system.

time=2026-04-04T13:57:33.487+09:00 level=WARN source=gemma4.go:293 msg="gemma4 tool call parsing failed" error="invalid character '\\'' looking for beginning of value" content="call:grep{include:<|\"|>*.py<|\"|>,output_mode:<|\"|>content<|\"|>,path:<|\"|>/data/robotics/experiment1<|\"|>,pattern:':\\s*\\w+'<|\"|>}"
RAW_BUFFERClick to expand / collapse

What is the issue?

After updating with ollama version 0.20.1 for fixing gemma4 tool parsing error(#15254), ollama still show errors on tool calling. Using gemma4:e4b with opencode, oh-my-opencode, ollama 0.20.1

Relevant log output

time=2026-04-04T13:58:18.757+09:00 level=WARN source=gemma4.go:293 msg="gemma4 tool call parsing failed" error="invalid character '`' looking for beginning of value" content="call:write{content:\n\n# Project Style Guide for Autonomous Agents' Code Generation (AGENTS.md)\n\nThis document captures the *de facto* coding standards observed across the `src/` and `components/` source code, designed to ensure consistency for all generated code and modules consumed by the agent system.

time=2026-04-04T13:57:33.487+09:00 level=WARN source=gemma4.go:293 msg="gemma4 tool call parsing failed" error="invalid character '\\'' looking for beginning of value" content="call:grep{include:<|\"|>*.py<|\"|>,output_mode:<|\"|>content<|\"|>,path:<|\"|>/data/robotics/experiment1<|\"|>,pattern:':\\s*\\w+'<|\"|>}"

OS

Linux

GPU

Nvidia

CPU

AMD

Ollama version

0.20.1

extent analysis

TL;DR

The issue with ollama version 0.20.1 showing errors on tool calling after updating for fixing gemma4 tool parsing error may be resolved by properly escaping special characters in the tool call content.

Guidance

  • Verify that the content passed to the gemma4 tool call does not contain unescaped special characters, such as backticks or backslashes, which may be causing the parsing error.
  • Check the documentation for the gemma4 tool to ensure that the content format is correct and that any special characters are properly escaped.
  • Test the tool call with a simplified content string to isolate the issue and determine if the problem is with the content or the tool call itself.
  • Consider updating the ollama version or the gemma4 tool to a version that properly handles special characters in the content.

Example

No specific code snippet can be provided without more information about the tool call content and the expected format.

Notes

The provided log output suggests that the issue is with the parsing of special characters in the tool call content. However, without more information about the expected format and the tool call content, it is difficult to provide a more specific solution.

Recommendation

Apply workaround: Properly escape special characters in the tool call content to prevent parsing errors. This is a safe and reasonable approach given the information provided in the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

ollama - ✅(Solved) Fix Gemma4 with ollama 0.20.1 still have tool parsing error [1 pull requests, 22 comments, 8 participants]