[PR #15370] [MERGED] model/parsers: suppress extra gemma4 closing tool tags #20396

Closed
opened 2026-04-16 07:35:15 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/15370
Author: @drifkin
Created: 4/6/2026
Status: Merged
Merged: 4/6/2026
Merged by: @drifkin

Base: mainHead: drifkin/gemma4-close-tool


📝 Commits (1)

  • 84778e9 model/parsers: suppress extra gemma4 closing tool tags

📊 Changes

2 files changed (+105 additions, -1 deletions)

View changed files

📝 model/parsers/gemma4.go (+34 -1)
📝 model/parsers/gemma4_test.go (+71 -0)

📄 Description

We've observed Gemma 4 occasionally emitting extra <tool_call|> tags after a valid tool call. We suppress leading close tags in this immediate post-tool-call state so the extra close tags do not leak into assistant content. The tradeoff is that if the model intentionally begins its next content span with the literal string "<tool_call|>", we will erroneously treat it as noise and drop it.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/15370 **Author:** [@drifkin](https://github.com/drifkin) **Created:** 4/6/2026 **Status:** ✅ Merged **Merged:** 4/6/2026 **Merged by:** [@drifkin](https://github.com/drifkin) **Base:** `main` ← **Head:** `drifkin/gemma4-close-tool` --- ### 📝 Commits (1) - [`84778e9`](https://github.com/ollama/ollama/commit/84778e96ffd67b0a32914f139cccc9f96911684d) model/parsers: suppress extra gemma4 closing tool tags ### 📊 Changes **2 files changed** (+105 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `model/parsers/gemma4.go` (+34 -1) 📝 `model/parsers/gemma4_test.go` (+71 -0) </details> ### 📄 Description We've observed Gemma 4 occasionally emitting extra <tool_call|> tags after a valid tool call. We suppress leading close tags in this immediate post-tool-call state so the extra close tags do not leak into assistant content. The tradeoff is that if the model intentionally begins its next content span with the literal string "<tool_call|>", we will erroneously treat it as noise and drop it. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-16 07:35:15 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#20396