[GH-ISSUE #22508] issue: Custom message object field "thinking" set in filter inlet is stripped, preventing workarounds for passing model reasoning back to ollama API. #35255

Closed
opened 2026-04-25 09:29:14 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @kosmo1dev on GitHub (Mar 9, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/22508

Check Existing Issues

  • I have searched for any existing and/or related issues.
  • I have searched for any existing and/or related discussions.
  • I have also searched in the CLOSED issues AND CLOSED discussions and found no related items (your issue might already be addressed on the development branch!).
  • I am using the latest version of Open WebUI.

Installation Method

Docker

Open WebUI Version

v0.6.43

Ollama Version (if applicable)

v0.17.7

Operating System

Windows 10

Browser (if applicable)

No response

Confirmation

  • I have read and followed all instructions in README.md.
  • I am using the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have provided every relevant configuration, setting, and environment variable used in my setup.
  • I have clearly listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc).
  • I have documented step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation. My steps:
  • Start with the initial platform/version/OS and dependencies used,
  • Specify exact install/launch/configure commands,
  • List URLs visited, user input (incl. example values/emails/passwords if needed),
  • Describe all options and toggles enabled or changed,
  • Include any files or environmental changes,
  • Identify the expected and actual result at each stage,
  • Ensure any reasonably skilled user can follow and hit the same issue.

Expected Behavior

When Filter, in its inlet method, adds "thinking" field to the message objects sent in the request body, it should be preserved and sent to the Ollama API as part of the request.

Given that the documentation explicitly lists "Injecting Extra API Body Parameters" as a reason to use Filters, as well as the lack of support for the current Ollama API (admittedly poorly documented) thinking field in the message template of chat completion request, I believe filters should be capable of bridging this gap.

Actual Behavior

Despite the filter being executed and successfully modifying the "content" field of the message object, the "thinking" field it sets in message objects is then stripped before being sent to Ollama API. The API receives the request without this custom field and, in consequence, fails to properly pass thinking to the model.

Steps to Reproduce

  1. Setup Ollama as your API provider.
  2. Create a Filter function that adds "thinking" field to messages in the request body.
  3. Enable the filter globally.
  4. Monitor http requests sent to Ollama (e.g. using Wireshark).
  5. Start new chat with any reasoning model.
  6. Wait for a response.
  7. Send another message.
  8. Check latest POST /api/chat sent to your Ollama instance for presence of the "thinking" field.

Example Filter function definition:

import re
from pydantic import BaseModel, Field
from typing import Optional, List, Dict


class Filter:
    class Valves(BaseModel):
        priority: int = Field(default=0, description="Priority of the filter")

    def __init__(self):
        self.valves = self.Valves()
        self.pattern = re.compile(r"<think>(.*?)</think>", re.DOTALL)

    def inlet(self, body: dict, __user__: Optional[dict] = None) -> dict:
        messages: List[Dict] = body.get("messages", [])

        for msg in messages:
            content = msg.get("content")
            if not isinstance(content, str):
                continue

            thinking = "\n".join(self.pattern.findall(content))
            if thinking:
                new_content = self.pattern.sub("", content)
                msg["content"] = new_content.strip()
                msg["thinking"] = thinking

        print(body)
        return body

    def outlet(self, body: dict, __user__: Optional[dict] = None) -> dict:
        return body

Logs & Screenshots

Captured request body showing assistant message with "content" modified by the filter (reasoning removed) without it being added in a new "thinking" field.

{
    "model": "qwen3.5:9b",
    "messages": [
        {
            "role": "user",
            "content": "!!!!!"
        },
        {
            "role": "assistant",
            "content": "Oh hey! \ud83d\ude04 That\u2019s a lot of excitement! How can I help you today? Whether you\u2019ve got a question, need advice, or just want to chat \u2014 I\u2019m here for it! \ud83c\udf1f"
        },
        {
            "role": "user",
            "content": ":)"
        }
    ],
    "stream": true,
    "options": {
        "num_ctx": 40000
    }
}

Additional Information

No response

Originally created by @kosmo1dev on GitHub (Mar 9, 2026). Original GitHub issue: https://github.com/open-webui/open-webui/issues/22508 ### Check Existing Issues - [x] I have searched for any existing and/or related issues. - [x] I have searched for any existing and/or related discussions. - [x] I have also searched in the CLOSED issues AND CLOSED discussions and found no related items (your issue might already be addressed on the development branch!). - [x] I am using the latest version of Open WebUI. ### Installation Method Docker ### Open WebUI Version v0.6.43 ### Ollama Version (if applicable) v0.17.7 ### Operating System Windows 10 ### Browser (if applicable) _No response_ ### Confirmation - [x] I have read and followed all instructions in `README.md`. - [x] I am using the latest version of **both** Open WebUI and Ollama. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have **provided every relevant configuration, setting, and environment variable used in my setup.** - [x] I have clearly **listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup** (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc). - [x] I have documented **step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation**. My steps: - Start with the initial platform/version/OS and dependencies used, - Specify exact install/launch/configure commands, - List URLs visited, user input (incl. example values/emails/passwords if needed), - Describe all options and toggles enabled or changed, - Include any files or environmental changes, - Identify the expected and actual result at each stage, - Ensure any reasonably skilled user can follow and hit the same issue. ### Expected Behavior When Filter, in its inlet method, adds "thinking" field to the message objects sent in the request body, it should be preserved and sent to the Ollama API as part of the request. Given that [the documentation explicitly lists "Injecting Extra API Body Parameters" as a reason to use Filters](https://docs.openwebui.com/features/extensibility/plugin/functions/filter#-injecting-extra-api-body-parameters), as well as the lack of support for the current Ollama API (admittedly poorly documented) thinking field in the message template of chat completion request, I believe filters should be capable of bridging this gap. ### Actual Behavior Despite the filter being executed and successfully modifying the "content" field of the message object, the "thinking" field it sets in message objects is then stripped before being sent to Ollama API. The API receives the request without this custom field and, in consequence, fails to properly pass thinking to the model. ### Steps to Reproduce 1. Setup Ollama as your API provider. 2. Create a Filter function that adds "thinking" field to messages in the request body. 3. Enable the filter globally. 4. Monitor http requests sent to Ollama (e.g. using Wireshark). 5. Start new chat with any reasoning model. 6. Wait for a response. 7. Send another message. 8. Check latest POST /api/chat sent to your Ollama instance for presence of the "thinking" field. Example Filter function definition: ```python import re from pydantic import BaseModel, Field from typing import Optional, List, Dict class Filter: class Valves(BaseModel): priority: int = Field(default=0, description="Priority of the filter") def __init__(self): self.valves = self.Valves() self.pattern = re.compile(r"<think>(.*?)</think>", re.DOTALL) def inlet(self, body: dict, __user__: Optional[dict] = None) -> dict: messages: List[Dict] = body.get("messages", []) for msg in messages: content = msg.get("content") if not isinstance(content, str): continue thinking = "\n".join(self.pattern.findall(content)) if thinking: new_content = self.pattern.sub("", content) msg["content"] = new_content.strip() msg["thinking"] = thinking print(body) return body def outlet(self, body: dict, __user__: Optional[dict] = None) -> dict: return body ``` ### Logs & Screenshots Captured request body showing assistant message with "content" modified by the filter (reasoning removed) without it being added in a new "thinking" field. ```json { "model": "qwen3.5:9b", "messages": [ { "role": "user", "content": "!!!!!" }, { "role": "assistant", "content": "Oh hey! \ud83d\ude04 That\u2019s a lot of excitement! How can I help you today? Whether you\u2019ve got a question, need advice, or just want to chat \u2014 I\u2019m here for it! \ud83c\udf1f" }, { "role": "user", "content": ":)" } ], "stream": true, "options": { "num_ctx": 40000 } } ``` ### Additional Information _No response_
GiteaMirror added the bug label 2026-04-25 09:29:14 -05:00
Author
Owner

@Classic298 commented on GitHub (Apr 14, 2026):

8bd23b9145

<!-- gh-comment-id:4247412484 --> @Classic298 commented on GitHub (Apr 14, 2026): https://github.com/open-webui/open-webui/commit/8bd23b91459914eb7df5b5a66567d3544e0da168
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#35255