[PR #14923] fix: respect format parameter when think is disabled for qwen3.5 series #25461

Open
opened 2026-04-19 18:13:56 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14923
Author: @LincolnBurrows2017
Created: 3/18/2026
Status: 🔄 Open

Base: mainHead: fix/byte-token-parsing


📝 Commits (3)

  • 187cc62 fix: handle errors properly in API client and envconfig LogLevel
  • 1ba8d4f fix: correct hex byte token parsing in SentencePiece.Decode
  • f267389 fix: respect format parameter when think is disabled for qwen3.5 series

📊 Changes

4 files changed (+15 additions, -6 deletions)

View changed files

📝 api/client.go (+4 -1)
📝 envconfig/config.go (+9 -3)
📝 server/routes.go (+1 -1)
📝 tokenizer/sentencepiece.go (+1 -1)

📄 Description

Description

The format parameter was being ignored when think is disabled for models with builtin parsers like qwen3.5. This happened because the condition only checked if the model has a builtin parser and thinking capability, but didn't verify if thinking is actually enabled.

Root Cause

In server/routes.go, the condition for ignoring the format parameter was:

if req.Format != nil && structuredOutputsState == structuredOutputsState_None && ((builtinParser != nil || thinkingState != nil) && slices.Contains(m.Capabilities(), model.CapabilityThinking)) {
    currentFormat = nil
}

For qwen3.5 models:

  • builtinParser is always non-nil (qwen3.5 has a builtin parser)
  • The model has thinking capability
  • So the format was being ignored regardless of whether thinking was actually enabled

Fix

This fix adds a check for req.Think.Bool() to ensure the format is only ignored when thinking is actually enabled:

if req.Format != nil && structuredOutputsState == structuredOutputsState_None && ((builtinParser != nil || thinkingState != nil) && slices.Contains(m.Capabilities(), model.CapabilityThinking) && req.Think != nil && req.Think.Bool()) {
    currentFormat = nil
}

This ensures that when thinking is disabled (think: false), the format parameter is properly respected.

Fixes: https://github.com/ollama/ollama/issues/14645


🔄 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/14923 **Author:** [@LincolnBurrows2017](https://github.com/LincolnBurrows2017) **Created:** 3/18/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/byte-token-parsing` --- ### 📝 Commits (3) - [`187cc62`](https://github.com/ollama/ollama/commit/187cc62a1afd34c59921ad156752ca94e6492df5) fix: handle errors properly in API client and envconfig LogLevel - [`1ba8d4f`](https://github.com/ollama/ollama/commit/1ba8d4f9d64031225bfec12cdbcccab569c43334) fix: correct hex byte token parsing in SentencePiece.Decode - [`f267389`](https://github.com/ollama/ollama/commit/f2673895cfbb0c9db9b0413fe76b1712f8dbad55) fix: respect format parameter when think is disabled for qwen3.5 series ### 📊 Changes **4 files changed** (+15 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `api/client.go` (+4 -1) 📝 `envconfig/config.go` (+9 -3) 📝 `server/routes.go` (+1 -1) 📝 `tokenizer/sentencepiece.go` (+1 -1) </details> ### 📄 Description ## Description The format parameter was being ignored when think is disabled for models with builtin parsers like qwen3.5. This happened because the condition only checked if the model has a builtin parser and thinking capability, but didn't verify if thinking is actually enabled. ## Root Cause In `server/routes.go`, the condition for ignoring the format parameter was: ```go if req.Format != nil && structuredOutputsState == structuredOutputsState_None && ((builtinParser != nil || thinkingState != nil) && slices.Contains(m.Capabilities(), model.CapabilityThinking)) { currentFormat = nil } ``` For qwen3.5 models: - `builtinParser` is always non-nil (qwen3.5 has a builtin parser) - The model has thinking capability - So the format was being ignored regardless of whether thinking was actually enabled ## Fix This fix adds a check for `req.Think.Bool()` to ensure the format is only ignored when thinking is actually enabled: ```go if req.Format != nil && structuredOutputsState == structuredOutputsState_None && ((builtinParser != nil || thinkingState != nil) && slices.Contains(m.Capabilities(), model.CapabilityThinking) && req.Think != nil && req.Think.Bool()) { currentFormat = nil } ``` This ensures that when thinking is disabled (`think: false`), the format parameter is properly respected. Fixes: https://github.com/ollama/ollama/issues/14645 --- <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-19 18:13:56 -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#25461