issue: MCP tool call parsed, but sometimes not executed #6122

Closed
opened 2025-11-11 16:45:29 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @tan-yong-sheng on GitHub (Aug 17, 2025).

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.22

Ollama Version (if applicable)

No response

Operating System

Ubuntu 22.04

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

Wish to re-open this bug report: https://github.com/open-webui/open-webui/discussions/16278

Because I think I found the reason of the bug, see below:
(1) https://github.com/open-webui/open-webui/discussions/16278#discussioncomment-14132000
(2) https://github.com/open-webui/open-webui/discussions/16278#discussioncomment-14132465

Actual Behavior

just for your note for function calling API implementatoin which causes MCP tool call parased but sometimes not executed.

This error does not occur every time. Occasionally, the content field is missing in a tool message when using the OpenAI-compatible function calling API (I’m running this through LiteLLM as the wrapper). When that happens, the API returns the following error:

(1) mistral API (via LiteLLM)

litellm.BadRequestError: MistralException - {"detail":[{"type":"missing","loc":["body","messages",5,"tool","content"],"msg":"Field required", ... }]} 
{4B8AE53B-55A0-4EA2-A93B-E0AA9A41F203} {881FA90D-5F3B-40A3-8CB1-677D7E35E94C}

(2) gemini-2.5-flash

Another scenario where the tool is not executed properly (very similar to the previous case) happens when I use Gemini 2.5 Flash.

image

In this example, the function calling API returns null for the content field, while the finish_reason is "stop".
(Note: Usually, when finish_reason = "tool", it means the API has returned parameters for function execution, but when finish_reason = "stop", it means the conversation is finished without tool execution.)

image

Steps to Reproduce

Native function calling enabled for model, and others are as mentioned above

Logs & Screenshots

As attached

Additional Information

The reason is probably because of:

For example, missing or null 'content' parameter on the response output:

Example (invalid, causes your error):
(i) in mistral (wrapped via LiteLLM)
{
"role": "tool",
"tool_call_id": "4CqS6tOj0"
}

OR
(ii) in gemini-2.5-flash (wrapped via LiteLLM)

{
"role": "tool",
"tool_call_id": "4CqS6tOj0",
"content": ""
}

Example (valid):
{
"role": "tool",
"tool_call_id": "4CqS6tOj0",
"content": "Tool execution result: { ... }"
}

From what I can see, even though the rest of the API endpoint calls are executed correctly, the missing content field seems to stop the MCP tool from finishing its execution.

Screenshots:
{B8A66F99-41D3-44B8-9DA6-67BC96EBFD98}

{0C25250F-1B45-47D6-9530-91A73206E861}

Not sure whether this originates from LiteLLM or OpenWebUI, but in OpenWebUI we could add logic so that if the API response has a finish_reason of "stop" while the content field is either null or missing, the system should automatically retry/resend the request because that's a malformed output for function calling.

Originally created by @tan-yong-sheng on GitHub (Aug 17, 2025). ### 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.22 ### Ollama Version (if applicable) _No response_ ### Operating System Ubuntu 22.04 ### 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 Wish to re-open this bug report: https://github.com/open-webui/open-webui/discussions/16278 Because I think I found the reason of the bug, see below: (1) https://github.com/open-webui/open-webui/discussions/16278#discussioncomment-14132000 (2) https://github.com/open-webui/open-webui/discussions/16278#discussioncomment-14132465 ### Actual Behavior just for your note for function calling API implementatoin which causes MCP tool call parased but sometimes not executed. This error does not occur every time. Occasionally, the content field is missing in a tool message when using the OpenAI-compatible function calling API (I’m running this through LiteLLM as the wrapper). When that happens, the API returns the following error: (1) mistral API (via LiteLLM) ``` litellm.BadRequestError: MistralException - {"detail":[{"type":"missing","loc":["body","messages",5,"tool","content"],"msg":"Field required", ... }]} ``` <img width="906" height="461" alt="{4B8AE53B-55A0-4EA2-A93B-E0AA9A41F203}" src="https://github.com/user-attachments/assets/8c3614f2-498b-4803-8230-452c8f111033" /> <img width="899" height="334" alt="{881FA90D-5F3B-40A3-8CB1-677D7E35E94C}" src="https://github.com/user-attachments/assets/48a3bd3b-dc77-4b44-b25a-1e210b955187" /> (2) gemini-2.5-flash Another scenario where the tool is not executed properly (very similar to the previous case) happens when I use **Gemini 2.5 Flash**. <img width="1479" height="858" alt="image" src="https://github.com/user-attachments/assets/6d2ac8e5-63b6-46c7-903c-f19629aceefa" /> In this example, the function calling API returns **`null` for the `content` field**, while the **`finish_reason` is `"stop"`**. (Note: Usually, when `finish_reason = "tool"`, it means the API has returned parameters for function execution, but when `finish_reason = "stop"`, it means the conversation is finished without tool execution.) <img width="1911" height="941" alt="image" src="https://github.com/user-attachments/assets/7ded1d0e-aab9-4bd7-853e-581c0580a7eb" /> ### Steps to Reproduce Native function calling enabled for model, and others are as mentioned above ### Logs & Screenshots As attached ### Additional Information The reason is probably because of: For example, missing or null 'content' parameter on the response output: ❌ Example (invalid, causes your error): (i) in mistral (wrapped via LiteLLM) { "role": "tool", "tool_call_id": "4CqS6tOj0" } OR (ii) in gemini-2.5-flash (wrapped via LiteLLM) { "role": "tool", "tool_call_id": "4CqS6tOj0", "content": "" } ✅ Example (valid): { "role": "tool", "tool_call_id": "4CqS6tOj0", "content": "Tool execution result: { ... }" } From what I can see, even though the rest of the API endpoint calls are executed correctly, the missing `content` field seems to stop the MCP tool from finishing its execution. Screenshots: <img width="751" height="422" alt="{B8A66F99-41D3-44B8-9DA6-67BC96EBFD98}" src="https://github.com/user-attachments/assets/320a7bd3-a529-41f7-b573-c01df1ba0af6" /> <img width="753" height="421" alt="{0C25250F-1B45-47D6-9530-91A73206E861}" src="https://github.com/user-attachments/assets/eddd2b4c-97d5-4c35-9775-c619ab1df69d" /> Not sure whether this originates from LiteLLM or OpenWebUI, but in OpenWebUI we could add logic so that if the API response has a finish_reason of "stop" while the content field is either null or missing, the system should automatically retry/resend the request because that's a malformed output for function calling.
GiteaMirror added the bug label 2025-11-11 16:45:29 -06:00
Author
Owner

@tan-yong-sheng commented on GitHub (Aug 17, 2025):

Just to add on, this happen when I am trying with tool server, but I suspect it would be the same case for built in tool as well

@tan-yong-sheng commented on GitHub (Aug 17, 2025): Just to add on, this happen when I am trying with tool server, but I suspect it would be the same case for built in tool as well
Author
Owner

@tjbck commented on GitHub (Aug 18, 2025):

Unable to reproduce, could you confirm the same issue occurs with openai models?

@tjbck commented on GitHub (Aug 18, 2025): Unable to reproduce, could you confirm the same issue occurs with openai models?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#6122