mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-17 08:21:12 -05:00
[GH-ISSUE #22240] issue: openai api native tool calling doesn't follow json schema #122983
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @pfn on GitHub (Mar 4, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/22240
Check Existing Issues
Installation Method
Git Clone
Open WebUI Version
v0.8.8
Ollama Version (if applicable)
No response
Operating System
linux
Browser (if applicable)
chrome
Confirmation
README.md.Expected Behavior
Native tool calling should follow JSON schema specified at https://developers.openai.com/api/reference/python/resources/chat/subresources/completions/methods/create/
tool-role content should not be merged into assistant-role content, it must stay as separate tool role content. there are too many instances that the model does know recognize that it executed a tool due to the content merge.
related
Actual Behavior
Initial response to assistant tool_call is correct, openwebui sends back a tool-role message with the result. subsequent turns merge the tool-role content into the assistant-role content.
Steps to Reproduce
Edit backend/open_webui/routers/openai.py to log the final payload. Enable native tool calling, send a prompt requesting a tool call to run, observe the json payloads that occur. send a prompt acknowledging the tool result, observe the resulting json payloads
Logs & Screenshots
Prompt: generate a random image for me
Payload:
Sent to endpoint for toolcall result (correct):
My prompt: do a random web search, only tell me the number of results found, summarizing is unnecessary
Sent to endpoint for acknowledging toolcall result:
Prompt: ok (last message to illustrate that tool content is getting collapsed into assistant)
Additional Information
To be clear, the issue here is that merging the tool content down into the assistant content is that it is essentially pre-filling the assistant response: breaking context cache, and making the model think that it output that information rather than a tool.
@Classic298 commented on GitHub (Mar 6, 2026):
@pfn can you please confirm this is still the case on latest dev?
@Classic298 commented on GitHub (Mar 6, 2026):
@pfn do you have any filters or functions?
@pfn commented on GitHub (Mar 6, 2026):
@Classic298 I have the Smart Infographic, Smart Mind Map and Generate Image actions installed, these do not work on the chat body (for the purpose of modification). No filters are active.
Does running dev clobber a main version database? I was always under the impression that it can be irreversibly broken due to missing/bad migrations, etc. I have avoided running dev for this reason.
Here is an example of the problem. I just encountered this during a tool session generating images. This final result is the model hallucinating that it can generate images simply by embedding the JSON into its output, at this point, the model refused to make any more tool calls to generate_image and would only "generate" images by embedding JSON it "thinks" would result in an image, because it was trained to do this by previous context.
@Classic298 commented on GitHub (Mar 6, 2026):
@pfn there are currently zero Migrations from 0.8.8 to dev
And even if there were, Migrations are generally only merged in if they work
@Classic298 commented on GitHub (Mar 6, 2026):
Thanks
@pfn commented on GitHub (Mar 6, 2026):
the result merging behavior did not change in :dev (git pulled dev and applied this logging diff) @Classic298
tool calling seems to have gotten worse: some "Task ...." got injected into my prompt invisibly for the search web request.
@Classic298 commented on GitHub (Mar 6, 2026):
That's intended that's the rag system prompt
@Classic298 commented on GitHub (Mar 6, 2026):
Ok thanks for letting me know I'll try to investigate further tomorrow
@pfn commented on GitHub (Mar 6, 2026):
Ooops, you're right, I missed that in the original snippet I sent with the base issue.
@tjbck commented on GitHub (Mar 8, 2026):
@pfn where are you logging these payloads? and are you using temp chats?