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

Closed
opened 2026-05-05 23:53:22 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @pvyswiss on GitHub (Apr 21, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/23923

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

Originally created by @pvyswiss on GitHub (Apr 21, 2026). Original GitHub issue: https://github.com/open-webui/open-webui/issues/23923 ## 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: ```python 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`
Author
Owner

@tjbck commented on GitHub (Apr 24, 2026):

Open to discussion.

<!-- gh-comment-id:4311182013 --> @tjbck commented on GitHub (Apr 24, 2026): Open to discussion.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#58776