[PR #21066] [CLOSED] fix: web search not working in native FC mode when builtin_tools is disabled #48959

Closed
opened 2026-04-30 01:12:35 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/21066
Author: @ShikaiChen
Created: 1/31/2026
Status: Closed

Base: devHead: fix/web-search-native-fc-decoupling


📝 Commits (10+)

📊 Changes

1 file changed (+21 additions, -0 deletions)

View changed files

📝 backend/open_webui/utils/middleware.py (+21 -0)

📄 Description

Pull Request Checklist

Note to first-time contributors: Please open a discussion post in Discussions to discuss your idea/fix with the community before creating a pull request, and describe your changes before submitting a pull request.

Before submitting, make sure you've checked the following:

  • Target branch: Verify that the pull request targets the dev branch. Not targeting the dev branch will lead to immediate closure of the PR.
  • Description: Provide a concise description of the changes made in this pull request down below.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: No documentation update needed — this is a backend-only logic fix with no new environment variables or configuration changes.
  • Dependencies: No new dependencies.
  • Testing: Unit tested all 7 behavior matrix scenarios. Integration tested get_builtin_tools() to verify only search_web and fetch_url are kept while 20+ other tools are correctly filtered out.
  • Agentic AI Code: This PR has gone through human review and manual testing.
  • Code review: Self-reviewed; follows project coding patterns (e.g. (...get("capabilities") or {}) style consistent with surrounding code in dev branch).
  • Title Prefix: fix:

Changelog Entry

Description

When builtin_tools capability is disabled on a model, web search breaks in native function calling (FC) mode — even though web search has its own independent web_search capability toggle.

Root cause: In middleware.py, builtin_tools_enabled gates the entire get_builtin_tools() call. Disabling builtin_tools prevents web search tools (search_web + fetch_url) from being injected into the native FC tool set.

Fix: Add an elif fallback after the existing builtin tools block that injects only search_web and fetch_url when:

  • Native FC mode is active
  • builtin_tools is disabled
  • ENABLE_WEB_SEARCH config is true
  • Model's web_search capability is not explicitly disabled

Behavior matrix

builtin_tools web_search Result Change
ON ON All tools injected Unchanged
ON OFF All tools injected Unchanged
OFF ON Only web search tools injected Fixed
OFF OFF No tools Unchanged
non-native FC any RAG path Unaffected

This is an additive-only change (21 new lines, 0 modified lines).

Added

  • N/A

Changed

  • N/A

Deprecated

  • N/A

Removed

  • N/A

Fixed

  • Web search now works in native FC mode even when builtin_tools capability is disabled on the model

Security

  • N/A

Breaking Changes

  • N/A

Additional Information

  • Related issue: #20549 (builtin tools injected via API when builtin_tools is disabled)
  • Only backend/open_webui/utils/middleware.py is modified
  • The elif block reuses get_builtin_tools() to create tool callables, then filters to only search_web and fetch_url
  • These two tools are bundled as the web search tool set in tools.py (line 440)

Screenshots or Videos

Setting page:
setting_page
Fixed:
fixed

A Note from Me

Apologies for the earlier closed PRs. This is my first contribution to Open WebUI and I was still figuring out the PR process and template requirements. I really enjoy using this project and would love to be part of the community. Thanks for your patience!

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/21066 **Author:** [@ShikaiChen](https://github.com/ShikaiChen) **Created:** 1/31/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix/web-search-native-fc-decoupling` --- ### 📝 Commits (10+) - [`fe6783c`](https://github.com/open-webui/open-webui/commit/fe6783c16699911c7be17392596d579333fb110c) Merge pull request #19030 from open-webui/dev - [`fc05e0a`](https://github.com/open-webui/open-webui/commit/fc05e0a6c5d39da60b603b4d520f800d6e36f748) Merge pull request #19405 from open-webui/dev - [`e3faec6`](https://github.com/open-webui/open-webui/commit/e3faec62c58e3a83d89aa3df539feacefa125e0c) Merge pull request #19416 from open-webui/dev - [`9899293`](https://github.com/open-webui/open-webui/commit/9899293f050ad50ae12024cbebee7e018acd851e) Merge pull request #19448 from open-webui/dev - [`140605e`](https://github.com/open-webui/open-webui/commit/140605e660b8186a7d5c79fb3be6ffb147a2f498) Merge pull request #19462 from open-webui/dev - [`6f1486f`](https://github.com/open-webui/open-webui/commit/6f1486ffd0cb288d0e21f41845361924e0d742b3) Merge pull request #19466 from open-webui/dev - [`d95f533`](https://github.com/open-webui/open-webui/commit/d95f533214e3fe5beb5e41ec1f349940bc4c7043) Merge pull request #19729 from open-webui/dev - [`a727153`](https://github.com/open-webui/open-webui/commit/a7271532f8a38da46785afcaa7e65f9a45e7d753) 0.6.43 (#20093) - [`6adde20`](https://github.com/open-webui/open-webui/commit/6adde203cd292a9e3af9c64a2ae36b603fed096a) Merge pull request #20394 from open-webui/dev - [`f9b0534`](https://github.com/open-webui/open-webui/commit/f9b0534e0c442631d1cb7205169588b9b6204179) Merge pull request #20522 from open-webui/dev ### 📊 Changes **1 file changed** (+21 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/middleware.py` (+21 -0) </details> ### 📄 Description # Pull Request Checklist ### Note to first-time contributors: Please open a discussion post in [Discussions](https://github.com/open-webui/open-webui/discussions) to discuss your idea/fix with the community before creating a pull request, and describe your changes before submitting a pull request. **Before submitting, make sure you've checked the following:** - [x] **Target branch:** Verify that the pull request targets the `dev` branch. **Not targeting the `dev` branch will lead to immediate closure of the PR.** - [x] **Description:** Provide a concise description of the changes made in this pull request down below. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [x] **Documentation:** No documentation update needed — this is a backend-only logic fix with no new environment variables or configuration changes. - [x] **Dependencies:** No new dependencies. - [x] **Testing:** Unit tested all 7 behavior matrix scenarios. Integration tested `get_builtin_tools()` to verify only `search_web` and `fetch_url` are kept while 20+ other tools are correctly filtered out. - [x] **Agentic AI Code:** This PR has gone through human review and manual testing. - [x] **Code review:** Self-reviewed; follows project coding patterns (e.g. `(...get("capabilities") or {})` style consistent with surrounding code in dev branch). - [x] **Title Prefix:** `fix:` # Changelog Entry ### Description When `builtin_tools` capability is disabled on a model, web search breaks in native function calling (FC) mode — even though web search has its own independent `web_search` capability toggle. **Root cause:** In `middleware.py`, `builtin_tools_enabled` gates the entire `get_builtin_tools()` call. Disabling `builtin_tools` prevents web search tools (`search_web` + `fetch_url`) from being injected into the native FC tool set. **Fix:** Add an `elif` fallback after the existing builtin tools block that injects only `search_web` and `fetch_url` when: - Native FC mode is active - `builtin_tools` is disabled - `ENABLE_WEB_SEARCH` config is true - Model's `web_search` capability is not explicitly disabled #### Behavior matrix | builtin_tools | web_search | Result | Change | |:---:|:---:|---|---| | ON | ON | All tools injected | Unchanged | | ON | OFF | All tools injected | Unchanged | | **OFF** | **ON** | **Only web search tools injected** | **Fixed** | | OFF | OFF | No tools | Unchanged | | non-native FC | any | RAG path | Unaffected | This is an additive-only change (21 new lines, 0 modified lines). ### Added - N/A ### Changed - N/A ### Deprecated - N/A ### Removed - N/A ### Fixed - Web search now works in native FC mode even when `builtin_tools` capability is disabled on the model ### Security - N/A ### Breaking Changes - N/A --- ### Additional Information - Related issue: #20549 (builtin tools injected via API when `builtin_tools` is disabled) - Only `backend/open_webui/utils/middleware.py` is modified - The `elif` block reuses `get_builtin_tools()` to create tool callables, then filters to only `search_web` and `fetch_url` - These two tools are bundled as the web search tool set in `tools.py` (line 440) ### Screenshots or Videos Setting page: <img width="3024" height="1648" alt="setting_page" src="https://github.com/user-attachments/assets/e84127f1-5f40-42fc-b183-a54773ae83a6" /> Fixed: <img width="3024" height="1648" alt="fixed" src="https://github.com/user-attachments/assets/c731284a-35c7-4a03-b6e4-509355057d99" /> ### A Note from Me Apologies for the earlier closed PRs. This is my first contribution to Open WebUI and I was still figuring out the PR process and template requirements. I really enjoy using this project and would love to be part of the community. Thanks for your patience! ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-30 01:12:35 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#48959