[PR #14660] server: apply format constraint when thinking is disabled #61469

Open
opened 2026-04-29 16:33:37 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14660
Author: @majiayu000
Created: 3/6/2026
Status: 🔄 Open

Base: mainHead: fix/format-with-think-disabled


📝 Commits (1)

  • 9034842 server: apply format constraint when thinking is disabled

📊 Changes

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

View changed files

📝 server/routes.go (+2 -1)
📝 server/routes_generate_test.go (+63 -0)

📄 Description

Summary

  • Fix format/structured outputs being silently ignored when think=false on thinking-capable models (e.g. qwen3.5)

Problem

When sending think=false + format=json, the structured outputs logic still defers format masking (sets currentFormat = nil) because the condition only checks whether the model has a builtin parser or thinking capability, not whether thinking is actually enabled for the request. Since no thinking content is produced, the restart signal never fires, and format masking is never applied.

Fix

Add a thinkEnabled check so that format masking is only deferred when thinking will actually produce content.

Test plan

  • Added format applied when think disabled test to TestChatWithPromptEndingInThinkTag
  • Verifies that with think=false + format, the completion receives the format constraint directly (single call, format not nil)
  • All existing structured outputs tests pass (think=true behavior unchanged)

Fixes #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/14660 **Author:** [@majiayu000](https://github.com/majiayu000) **Created:** 3/6/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/format-with-think-disabled` --- ### 📝 Commits (1) - [`9034842`](https://github.com/ollama/ollama/commit/90348424c5bf11c300ced9c2a572a97f8df772f2) server: apply format constraint when thinking is disabled ### 📊 Changes **2 files changed** (+65 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `server/routes.go` (+2 -1) 📝 `server/routes_generate_test.go` (+63 -0) </details> ### 📄 Description ## Summary - Fix format/structured outputs being silently ignored when `think=false` on thinking-capable models (e.g. qwen3.5) ## Problem When sending `think=false` + `format=json`, the structured outputs logic still defers format masking (sets `currentFormat = nil`) because the condition only checks whether the model has a builtin parser or thinking capability, not whether thinking is actually enabled for the request. Since no thinking content is produced, the restart signal never fires, and format masking is never applied. ## Fix Add a `thinkEnabled` check so that format masking is only deferred when thinking will actually produce content. ## Test plan - Added `format applied when think disabled` test to `TestChatWithPromptEndingInThinkTag` - Verifies that with `think=false` + format, the completion receives the format constraint directly (single call, format not nil) - All existing structured outputs tests pass (think=true behavior unchanged) Fixes #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-29 16:33:37 -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#61469