mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-17 15:53:59 -06:00
[GH-ISSUE #23957] issue: Tool calling causing a repeat in messages when using pipeline #90863
Reference in New Issue
Block a user
Originally created by @jayteaftw on GitHub (Apr 21, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/23957
Check Existing Issues
Installation Method
Docker
Open WebUI Version
v8.12
Ollama Version (if applicable)
No response
Operating System
Mac OS
Browser (if applicable)
No response
Confirmation
README.md.Expected Behavior
When running the pipeline I show below, I expect the Model to Produce the text "The weather is 22°C", show the tool call, and finally print "Done"
Actual Behavior
Instead it prints "The weather is 22°C. Done.", the tool call, and then multiple chat messages of "The weather is 22°C. Done."
Steps to Reproduce
Setup a pipeline
Logs & Screenshots
Additional Information
What are the proper messages that a pipeline can retun/ stream?
For example, it mentions strings and generators in the documentation but yielding the following seems to be valid but is not mentioned in the documentation
@Classic298 commented on GitHub (Apr 21, 2026):
can you share the code of the pipeline? might be a pipeline issue.
@jayteaftw commented on GitHub (Apr 21, 2026):
@Classic298 this is what you are looking for? This is what I linked above and used to reproduce this error
@Classic298 commented on GitHub (Apr 21, 2026):
Couple of things going on here:
1. You're on v0.8.12. Current is 0.9.x with a significantly reworked streaming path. Before we dig in, please reproduce on the latest build — there's a reasonable chance this is already addressed.
2. Your pipeline is emitting a non-spec-compliant stream. Per the OpenAI Chat Completions spec,
finish_reason: "tool_calls"terminates the assistant turn. The expected flow is:finish_reason: "tool_calls"→ stream endsrole: "tool"message → sends a new completion requestWhat your pipeline does — yielding more
contentdeltas afterfinish_reason: "tool_calls"— isn't defined behavior. The duplication you're seeing is Open WebUI's streaming handler reacting to a stream shape it doesn't expect:finish_reason: "tool_calls"triggers the tool-call handling path, but your stream keeps yielding, so the handler ends up processing the content twice.Fix your pipeline: either
finish_reason: "tool_calls"in the middle — emit the tool_calls delta without finishing, continue with more content, then close withfinish_reason: "stop"at the very end. (Note: this second pattern still isn't officially OpenAI-spec either, so behavior is best-effort.)On your question about valid pipeline return types:
strand generators/iterators yielding either raw text or OpenAI-compatible chunk dicts are both supported. The chunk-dict pattern is the one you're already using — it's fine as long as the stream follows normal OpenAI semantics (singlefinish_reasonat the end of the turn).@jayteaftw commented on GitHub (Apr 21, 2026):
@Classic298 Hmm interesting,
I guess the bigger picture is I have a deep agent from langchain running in an open webui pipeline.
Since the tools are be executed by the agent and not the open webui client, how would you recommend then for me to be able to display the agents tool execution inside of open webui when it streams back the ToolMessage object?
or how could I follow the suggested spec
split it into two generators (first yields content+tool_calls and stops; after tool result comes back, second yields "Done.")?@Classic298 commented on GitHub (Apr 21, 2026):
Good context — if the LangChain agent is executing tools internally, you should not emit finish_reason: "tool_calls" at all. That signal tells the Open WebUI client "take over, execute the tool, then request a continuation" — but in your case the tool is already done by the time you're streaming. Emitting it makes OWUI try to do the tool-call dance on top of what your agent already did, which is the root of the duplication.
Two patterns that work well for self-contained agent pipelines:
<details>. If you want the tool result visible too, wrap it in a<details>block inside the content stream. Open WebUI renders these as collapsible inline blocks:Mapping from your LangChain loop:
The key rule: when the agent owns tool execution, finish_reason appears exactly once, at the end, and it's "stop" — not "tool_calls".
@jayteaftw commented on GitHub (Apr 21, 2026):
@Classic298 thanks for the information! So I updated to v0.9.1 used the 1st example as a test pipeline
However I am getting similar results

@Classic298 commented on GitHub (Apr 21, 2026):
My previous Pattern 1 advice was wrong, apologies for the runaround. Looking at
backend/open_webui/utils/middleware.py, Open WebUI processesdelta.tool_callsinto its execution loop (around line 4369:while len(tool_calls) > 0 and tool_call_retries < CHAT_RESPONSE_MAX_TOOL_CALL_RETRIES) regardless offinish_reason. Anydelta.tool_callsthe pipeline emits gets picked up, handed to the tool executor, and a continuation request is fired back at the same pipeline — which produces exactly the loop you're seeing (capped byCHAT_RESPONSE_MAX_TOOL_CALL_RETRIES, ~30 iterations in your screenshot).Correct approach for a self-contained agent: don't emit
delta.tool_callsat all. Instead, emit the visualization as content using the same<details type="tool_calls">block Open WebUI itself renders internally after tool execution (seemiddleware.py:498). The UI will show the exact same collapsible "View Result from ..." chip.Minimal example:
Mapped to your LangChain loop:
Rule of thumb:
delta.tool_callsalways means "please execute this for me, client." If your agent has already executed the tool, use content-embedded<details>blocks instead. That's exactly what Open WebUI's own server-side tool path emits after execution — you're producing the same output shape directly, skipping the execute-and-continue loop that doesn't apply when the agent owns tool execution.@jayteaftw commented on GitHub (Apr 22, 2026):
Thank you! I dont know if this is a bug but
yield {"choices": [{"delta": {"content": details}, "finish_reason": None}]}did not seem to work butyield detailsdid