[GH-ISSUE #14850] think=False breaks JSON structured output with format when using qwen3.5:27b #35339

Closed
opened 2026-04-22 19:46:38 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @VacantHusky on GitHub (Mar 14, 2026).
Original GitHub issue: https://github.com/ollama/ollama/issues/14850

What is the issue?

Description

When using Ollama v0.18.0 with the qwen3.5:27b model, JSON structured output stops working if the think parameter is set to False.

If think is enabled (e.g. "low"), the model returns valid JSON that matches the provided schema.
However, when think=False, the returned content is no longer valid JSON and fails schema validation.

This appears to break the format structured output feature.


Environment

  • Ollama version: 0.17.7, 0.18.0
  • Model: qwen3.5:27b
  • Python client: ollama
  • OS: Windows 11

Minimal Reproduction

from pydantic import BaseModel
from ollama import Client
from typing import List


class FriendInfo(BaseModel):
    name: str
    age: int
    is_available: bool


class FriendList(BaseModel):
    friends: List[FriendInfo]


def main(think):
    client = Client(host="127.0.0.1")

    response = client.chat(
        model='qwen3.5:27b',
        think=think,
        messages=[{
            'role': 'user',
            'content': 'I have two friends. The first is Ollama 22 years old busy saving '
                       'the world, and the second is Alonso 23 years old and wants to '
                       'hang out. Return a list of friends in JSON format'
        }],
        format=FriendList.model_json_schema(),
        options={'temperature': 0},
    )

    print(response.message.content)

    friends_response = FriendList.model_validate_json(response.message.content)
    print(friends_response)


if __name__ == '__main__':
    main('low')
    main(False)

Expected Behavior

Both calls should return valid JSON matching the provided schema.

Example expected output:

{
  "friends": [
    {
      "name": "Ollama",
      "age": 22,
      "is_available": false
    },
    {
      "name": "Alonso",
      "age": 23,
      "is_available": true
    }
  ]
}

Actual Behavior

  • think="low" → Works correctly.
  • think=False → Returned content is not valid JSON and fails model_validate_json.

Possible Cause

It appears that disabling thinking mode may bypass or interfere with the structured output (format) mechanism.


Question

Is this expected behavior, or a bug in the interaction between:

  • think=False
  • format (JSON schema structured output)

Relevant log output


OS

Windows

GPU

Nvidia

CPU

Intel

Ollama version

0.18.0

Originally created by @VacantHusky on GitHub (Mar 14, 2026). Original GitHub issue: https://github.com/ollama/ollama/issues/14850 ### What is the issue? ### Description When using **Ollama v0.18.0** with the **qwen3.5:27b** model, JSON structured output stops working if the `think` parameter is set to `False`. If `think` is enabled (e.g. `"low"`), the model returns valid JSON that matches the provided schema. However, when `think=False`, the returned content is no longer valid JSON and fails schema validation. This appears to break the `format` structured output feature. --- ### Environment * Ollama version: **0.17.7**, **0.18.0** * Model: **qwen3.5:27b** * Python client: `ollama` * OS: Windows 11 --- ### Minimal Reproduction ```python from pydantic import BaseModel from ollama import Client from typing import List class FriendInfo(BaseModel): name: str age: int is_available: bool class FriendList(BaseModel): friends: List[FriendInfo] def main(think): client = Client(host="127.0.0.1") response = client.chat( model='qwen3.5:27b', think=think, messages=[{ 'role': 'user', 'content': 'I have two friends. The first is Ollama 22 years old busy saving ' 'the world, and the second is Alonso 23 years old and wants to ' 'hang out. Return a list of friends in JSON format' }], format=FriendList.model_json_schema(), options={'temperature': 0}, ) print(response.message.content) friends_response = FriendList.model_validate_json(response.message.content) print(friends_response) if __name__ == '__main__': main('low') main(False) ``` --- ### Expected Behavior Both calls should return valid JSON matching the provided schema. Example expected output: ```json { "friends": [ { "name": "Ollama", "age": 22, "is_available": false }, { "name": "Alonso", "age": 23, "is_available": true } ] } ``` --- ### Actual Behavior * `think="low"` → Works correctly. * `think=False` → Returned content is not valid JSON and fails `model_validate_json`. --- ### Possible Cause It appears that disabling thinking mode may bypass or interfere with the structured output (`format`) mechanism. --- ### Question Is this expected behavior, or a bug in the interaction between: * `think=False` * `format` (JSON schema structured output) ### Relevant log output ```shell ``` ### OS Windows ### GPU Nvidia ### CPU Intel ### Ollama version 0.18.0
GiteaMirror added the bug label 2026-04-22 19:46:38 -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#35339