[PR #15374] [MERGED] model/parsers: add gemma4 tool call repair #41001

Closed
opened 2026-04-23 01:45:33 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/15374
Author: @drifkin
Created: 4/7/2026
Status: Merged
Merged: 4/7/2026
Merged by: @ParthSareen

Base: mainHead: drifkin/gemma4-tool-repair


📝 Commits (1)

  • 5b9ac93 model/parsers: add gemma4 tool call repair

📊 Changes

2 files changed (+812 additions, -9 deletions)

View changed files

📝 model/parsers/gemma4.go (+371 -4)
📝 model/parsers/gemma4_test.go (+441 -5)

📄 Description

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.


🔄 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/15374 **Author:** [@drifkin](https://github.com/drifkin) **Created:** 4/7/2026 **Status:** ✅ Merged **Merged:** 4/7/2026 **Merged by:** [@ParthSareen](https://github.com/ParthSareen) **Base:** `main` ← **Head:** `drifkin/gemma4-tool-repair` --- ### 📝 Commits (1) - [`5b9ac93`](https://github.com/ollama/ollama/commit/5b9ac9379bcfc38b4fc6336b785a42f261afe48b) model/parsers: add gemma4 tool call repair ### 📊 Changes **2 files changed** (+812 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `model/parsers/gemma4.go` (+371 -4) 📝 `model/parsers/gemma4_test.go` (+441 -5) </details> ### 📄 Description 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. --- <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-23 01:45:33 -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#41001