[GH-ISSUE #17135] issue: sending malformed "role": "tool" messages to OpenAI /v1/chat/completions endpoint #88921

Closed
opened 2026-05-15 13:43:57 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @Lioscro on GitHub (Sep 1, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/17135

Check Existing Issues

  • I have searched the existing issues and discussions.
  • I am using the latest version of Open WebUI.

Installation Method

Docker

Open WebUI Version

v0.6.26

Ollama Version (if applicable)

Metal llama.cpp v1.48.0 b6275 (via LM Studio)

Operating System

macOS Sequoia 15.6.1

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

OpenWebUI calls the /v1/chat/completions OpenAI(-like) endpoint with tool calls with body that is compliant with the OpenAI schema (https://platform.openai.com/docs/api-reference/chat/create)

Actual Behavior

When OpenWebUI POSTs the /v1/chat/completions endpoint, the messages array in the JSON body is malformed for tool calls ("role": "tool").

Based on the OpenAI documentation, the "content" key is required to be an array or a string, but OpenWebUI passes a null.

Image

Captured POST request to /v1/chat/completions OpenAI-like endpoint that is exposed via LM Studio:

{
    "model": "qwen3-30b-a3b-instruct-2507-mlx",
    "stream": true,
    "tools": [{redacted}],
    "messages": [
        ...
        {
            "role": "tool",
            "tool_call_id": "139950280",
            "content": null
        }
    ]
}

This results in LM Studio (and possibly other tools that enforce the schema) to reject the request. This shows up as tool calls "infinitely hanging." In other words, the OpenWebUI UI displays that the tool call was made and the call arguments, but it hangs forever and the actual request is never made. While the error itself is surfaced on LM Studio, and it is what rejects the request, I believe it is due to OpenWebUI passing a body that is not compliant with the OpenAI schema (linked above). Happy to raise this to LM Studio's team as well if that seems appropriate.

Image

May be related to these other issues / discussions.

Note that this does not seem to be an issue with every tool call.

Steps to Reproduce

Difficult to provide a minimum example since the issue doesn't seem to occur with every tool call, but it does seem like if it happens for a specific tool call and model, it consistently happens without fail. My setup is the following.

  1. LM Studio 0.3.24 with qwen3-30b-a3b-instruct-2507-mlx https://huggingface.co/lmstudio-community/Qwen3-30B-A3B-Instruct-2507-MLX-6bit and tool calling set to native
  2. Local LLM service running and serving on local network at port 1234
  3. LM Studio's OpenAI-like endpoint added as OpenAI endpoint in OpenWebUI
Image
  1. mcpo version git-757e4fe running with firecrawl-mcp MCP. Note that due to this issue, the actual MCP server isn't even called, so you don't need to have a working firecrawl deployment working. In other words you can set FIRECRAWL_API_URL to anything.
  {
    "mcpServers": {
      "time": {
        "command": "uvx",
        "args": ["mcp-server-time@2025.8.4", "--local-timezone=America/Los_Angeles"]
      },
      "firecrawl": {
        "command": "npx",
        "args": ["-y", "firecrawl-mcp@1.12.0"],
        "env": {
            "FIRECRAWL_API_URL": "http://firecrawl-firecrawl-api:3002"
        }
      }
    }
  }
  1. Add the firecrawl MCP as a tool in OpenWebUI and allow the model to call it
Image
  1. Ask the model to call the firecrawl_search endpoint with a predefined query (e.g. Call the firecrawl_search endpoint with the query: Apple).

Logs & Screenshots

Error in LM Studio due to malformed body

2025-09-01 16:23:26 [ERROR]
 [Server Error] Your payload's 'messages' array in misformatted. Messages from roles [user, system, tool] must contain a 'content' field. Got 'object'

Other images are embedded inline in the previous sections.

Additional Information

No response

Originally created by @Lioscro on GitHub (Sep 1, 2025). Original GitHub issue: https://github.com/open-webui/open-webui/issues/17135 ### Check Existing Issues - [x] I have searched the existing issues and discussions. - [x] I am using the latest version of Open WebUI. ### Installation Method Docker ### Open WebUI Version v0.6.26 ### Ollama Version (if applicable) Metal llama.cpp v1.48.0 b6275 (via LM Studio) ### Operating System macOS Sequoia 15.6.1 ### 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 OpenWebUI calls the `/v1/chat/completions` OpenAI(-like) endpoint with tool calls with body that is compliant with the OpenAI schema (https://platform.openai.com/docs/api-reference/chat/create) ### Actual Behavior When OpenWebUI POSTs the `/v1/chat/completions` endpoint, the `messages` array in the JSON body is malformed for tool calls (`"role": "tool"`). Based on the OpenAI documentation, the `"content"` key is required to be an array or a string, but OpenWebUI passes a `null`. <img width="587" height="506" alt="Image" src="https://github.com/user-attachments/assets/98424737-ae93-45c2-8c65-f7f1d022e518" /> Captured POST request to `/v1/chat/completions` OpenAI-like endpoint that is exposed via LM Studio: ```json { "model": "qwen3-30b-a3b-instruct-2507-mlx", "stream": true, "tools": [{redacted}], "messages": [ ... { "role": "tool", "tool_call_id": "139950280", "content": null } ] } ``` This results in LM Studio (and possibly other tools that enforce the schema) to reject the request. This shows up as tool calls "infinitely hanging." In other words, the OpenWebUI UI displays that the tool call was made and the call arguments, but it hangs forever and the actual request is never made. While the error itself is surfaced on LM Studio, and it is what rejects the request, I believe it is due to OpenWebUI passing a body that is not compliant with the OpenAI schema (linked above). Happy to raise this to LM Studio's team as well if that seems appropriate. <img width="1095" height="399" alt="Image" src="https://github.com/user-attachments/assets/45fa5163-48fe-4873-af4f-6956875f4390" /> May be related to these other issues / discussions. * https://github.com/open-webui/open-webui/discussions/16717 * https://github.com/open-webui/open-webui/discussions/14610 Note that this does not seem to be an issue with every tool call. ### Steps to Reproduce Difficult to provide a minimum example since the issue doesn't seem to occur with every tool call, but it does seem like if it happens for a specific tool call and model, it consistently happens without fail. My setup is the following. 1. LM Studio 0.3.24 with `qwen3-30b-a3b-instruct-2507-mlx` https://huggingface.co/lmstudio-community/Qwen3-30B-A3B-Instruct-2507-MLX-6bit and tool calling set to `native` 2. Local LLM service running and serving on local network at port 1234 3. LM Studio's OpenAI-like endpoint added as OpenAI endpoint in OpenWebUI <img width="587" height="506" alt="Image" src="https://github.com/user-attachments/assets/491ecbec-f533-4834-ba45-81b308b9ad8e" /> 4. mcpo version `git-757e4fe` running with `firecrawl-mcp` MCP. Note that due to this issue, the actual MCP server isn't even called, so you don't need to have a working firecrawl deployment working. In other words you can set `FIRECRAWL_API_URL` to anything. ```json { "mcpServers": { "time": { "command": "uvx", "args": ["mcp-server-time@2025.8.4", "--local-timezone=America/Los_Angeles"] }, "firecrawl": { "command": "npx", "args": ["-y", "firecrawl-mcp@1.12.0"], "env": { "FIRECRAWL_API_URL": "http://firecrawl-firecrawl-api:3002" } } } } ``` 5. Add the firecrawl MCP as a tool in OpenWebUI and allow the model to call it <img width="587" height="562" alt="Image" src="https://github.com/user-attachments/assets/e822df12-ac92-4448-ac34-39f32291030d" /> 6. Ask the model to call the `firecrawl_search` endpoint with a predefined query (e.g. Call the `firecrawl_search` endpoint with the query: Apple). ### Logs & Screenshots Error in LM Studio due to malformed body ``` 2025-09-01 16:23:26 [ERROR] [Server Error] Your payload's 'messages' array in misformatted. Messages from roles [user, system, tool] must contain a 'content' field. Got 'object' ``` Other images are embedded inline in the previous sections. ### Additional Information _No response_
GiteaMirror added the bug label 2026-05-15 13:43:57 -05:00
Author
Owner

@Lioscro commented on GitHub (Sep 2, 2025):

Actually, looking into it a bit more, seems like something is causing OpenWebUI to not even call mcpo (verified by checking mcpo logs; usually there is a Calling endpoint: ... entry, but none present whenever this issue happens), hence the null content. Why OpenWebUI decides to skip calling the tool entirely is a mystery to me...

Other tools work fine

Image

And another model can call the firecrawl_search endpoint properly

Image
<!-- gh-comment-id:3243437812 --> @Lioscro commented on GitHub (Sep 2, 2025): Actually, looking into it a bit more, seems like something is causing OpenWebUI to not even call mcpo (verified by checking mcpo logs; usually there is a `Calling endpoint: ...` entry, but none present whenever this issue happens), hence the `null` content. Why OpenWebUI decides to skip calling the tool entirely is a mystery to me... Other tools work fine <img width="1147" height="485" alt="Image" src="https://github.com/user-attachments/assets/41670b82-d583-4cd5-ba26-24c731532e0a" /> And another model can call the `firecrawl_search` endpoint properly <img width="1147" height="944" alt="Image" src="https://github.com/user-attachments/assets/20c3c247-ce97-40f8-a178-f81852a01c74" />
Author
Owner

@Lioscro commented on GitHub (Sep 2, 2025):

Update: turns out the "infinite hanging" behavior was caused by the model taking my instruction to call firecrawl_search literally (it should have been tool_firecrawl_search_post. Interesting that some models understood that I meant tool_firecrawl_search_post instead and called the right endpoint.

Would have been nice if OpenWebUI told me that it was trying to call a non-existent tool... (can we have this?) And perhaps even reply back to the model to tell it that the tool it tried to call doesn't exist so that it can attempt to fix itself...

In either case, the main point of this issue, OpenWebUI passing a schema-non-compliant body to the endpoint is still an issue.

<!-- gh-comment-id:3243481861 --> @Lioscro commented on GitHub (Sep 2, 2025): Update: turns out the "infinite hanging" behavior was caused by the model taking my instruction to call `firecrawl_search` literally (it should have been `tool_firecrawl_search_post`. Interesting that some models understood that I meant `tool_firecrawl_search_post` instead and called the right endpoint. Would have been nice if OpenWebUI told me that it was trying to call a non-existent tool... (can we have this?) And perhaps even reply back to the model to tell it that the tool it tried to call doesn't exist so that it can attempt to fix itself... In either case, the main point of this issue, OpenWebUI passing a schema-non-compliant body to the endpoint is still an issue.
Author
Owner

@rgaricano commented on GitHub (Sep 2, 2025):

something like this: https://github.com/open-webui/open-webui/issues/16966#issuecomment-3229638997?

<!-- gh-comment-id:3243497103 --> @rgaricano commented on GitHub (Sep 2, 2025): something like this: https://github.com/open-webui/open-webui/issues/16966#issuecomment-3229638997?
Author
Owner

@tjbck commented on GitHub (Sep 2, 2025):

"content": null should be accepted by the model inference engine, @Lioscro are you able to reproduce the issue with openai models like gpt-4.1?

<!-- gh-comment-id:3244753012 --> @tjbck commented on GitHub (Sep 2, 2025): `"content": null` should be accepted by the model inference engine, @Lioscro are you able to reproduce the issue with openai models like gpt-4.1?
Author
Owner

@tan-yong-sheng commented on GitHub (Sep 2, 2025):

I am recently facing some kind of error with tool call as well, as discussed here. I can't detect the reason why it happens that time, and not sure if the comments above are the reason.

https://github.com/open-webui/open-webui/discussions/16278#discussioncomment-14267103

<!-- gh-comment-id:3246461159 --> @tan-yong-sheng commented on GitHub (Sep 2, 2025): I am recently facing some kind of error with tool call as well, as discussed here. I can't detect the reason why it happens that time, and not sure if the comments above are the reason. https://github.com/open-webui/open-webui/discussions/16278#discussioncomment-14267103
Author
Owner

@tjbck commented on GitHub (Sep 3, 2025):

Should be addressed with 37bf0087e5

<!-- gh-comment-id:3248549568 --> @tjbck commented on GitHub (Sep 3, 2025): Should be addressed with 37bf0087e5b8a324009c9d06b304027df351ea6b
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#88921