Skip to content

feat: Expose Ollama reasoning (thinking) as <think> tags in OpenAI-compat SSE for generic clients #23923

Description

@pvyswiss

Feature Request

Ollama reasoning models (DeepSeek R1, Gemma 4) send reasoning in message.thinking. Open WebUI converts this to delta.reasoning_content -- a non-standard field that only DeepSeek-specific SDKs understand.

Generic OpenAI-compatible SDKs (@ai-sdk/openai-compatible, etc.) don't recognize reasoning_content and silently drop reasoning tokens.

Related to: #23917 (Bug 4)

Suggested Enhancement

Convert Ollama's thinking field into <think> tags inside the standard content field:

if reasoning_content:
    if not in_reasoning:
        in_reasoning = True
        message_content = "<think>\n" + reasoning_content
    else:
        message_content = reasoning_content
    reasoning_content = None
elif in_reasoning and message_content:
    in_reasoning = False
    message_content = "\n</think>\n\n" + message_content

Open WebUI's browser middleware already detects <think> tags and renders them as collapsible blocks -- fully backward-compatible.

Impact

  • Web UI: <think> tags rendered as collapsible reasoning (same as before)
  • API clients: Reasoning visible as standard content text

File

backend/open_webui/utils/response.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions