mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 03:18:23 -05:00
[GH-ISSUE #21371] issue: Built-in search_web tool ignores WEB_SEARCH_RESULT_COUNT admin setting (hardcoded count=5) #34987
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 @sewasti on GitHub (Feb 13, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/21371
Check Existing Issues
Installation Method
Docker
Open WebUI Version
0.8.0
Ollama Version (if applicable)
No response
Operating System
Linux (Debian 11 bullseye)
Browser (if applicable)
Version 144.0.7559.133
Confirmation
README.md.Expected Behavior
The built-in
search_webtool (used in Native Function Calling mode) should respectthe admin setting
WEB_SEARCH_RESULT_COUNT(Admin → Settings → Web Search →Search Result Count). When set to 10, web searches should return 10 results.
Actual Behavior
The built-in
search_webtool always returns exactly 5 results, regardless ofthe admin
WEB_SEARCH_RESULT_COUNTsetting.Confirmed via API that the admin setting IS correctly stored:
But in Native Function Calling mode, only 5 sources are ever returned.
Steps to Reproduce
10in Admin → Settings → Web Search.curl -H "Authorization: Bearer " http://localhost:8080/api/v1/retrieval/config | jq '.web.WEB_SEARCH_RESULT_COUNT'
→ should return
10.Admin → Chat Controls → Function Calling Mode → "Native".
"Search the web for the latest news about AI regulation in the EU"
Logs & Screenshots
No runtime errors in browser console or Docker logs. The bug is in the source code.
Root Cause in
open_webui/tools/builtin.py(lines ~148-173):The underlying
_search_web()inrouters/retrieval.pycorrectly uses the admin settingrequest.app.state.config.WEB_SEARCH_RESULT_COUNTfor the search engine API call(e.g. Tavily receives
max_results=10and returns 10 results).But then
builtin.pyre-truncates withresults[:count], wherecountdefaults to 5because LLMs typically call
search_web(query="...")without passing thecountparameter.This is a double-truncation bug: the backend fetches the correct number, but the
tool function silently discards the extra results.
Additional Information
Suggested Fix
Option A (simplest): Remove the
[:count]truncation inbuiltin.py, since_search_web()already applies the admin limit via the search engine API:Option B: Use the admin config as the effective default:
Scope
builtin.py).chat_web_search_handler) correctly uses the admin setting.Workaround
Add a system prompt instruction: "When using the search_web tool, always pass count=10."
This forces the LLM to explicitly pass the parameter instead of using the hardcoded default.
@Classic298 commented on GitHub (Feb 13, 2026):
the model decides the amount of sources it wants to retrieve. when the model doesnt specify a number it defaults to 5. the model can also say it wants 10 or 15.
@Classic298 commented on GitHub (Feb 13, 2026):
may add an additional check to use the admin config value if configured and only then default back to 5.
@Classic298 commented on GitHub (Feb 13, 2026):
https://github.com/open-webui/open-webui/pull/21373
@Ithanil commented on GitHub (Feb 13, 2026):
Personally, I would have preferred that the admin setting is enforced, i.e. not offered as an option to the LLM. This would make the native/non-native search consistent and depending on the setup, one might have to limit search results (with content snippets) to make sure it fits the context windows.
But of course there is also the argument to be made to keep the option for flexible control via user/system prompting.
@Classic298 commented on GitHub (Feb 13, 2026):
@Ithanil the snippets are quite short by default and i think open webui even has a hardcoded maximum cutoff for web fetch and the snippets length.
@Classic298 commented on GitHub (Feb 13, 2026):
And the setups don't necessarily have to be consistent
The entire point is to give the LLM a bit more control over how it uses these tools to get better results :)
@Classic298 commented on GitHub (Feb 13, 2026):
The default tool calling exists for weak task models that don't even see the full chat context and shouldn't and can't decide how much to search
Native tool calling, strong models that have the full context in mind can decide how much to search for
@Ithanil commented on GitHub (Feb 13, 2026):
It's OK. I'm using modified Tavily search that returns full chunks of relevant content. But I'm also able to change this feature as I see fit. ;-)
@Ithanil commented on GitHub (Feb 13, 2026):
@Classic298 Ummm... wait a second. Looking at the code, the builtin search_web tool uses the search_web router (without passing the count option), which in turn uses the admin-configured result count. Thus, the result count specified by the model will only serve as an upper limit.
Not sure if that's the intended behavior, but my arguments are pointless in that case.