[PR #20729] [CLOSED] fix: respect built-in tool toggles in native function calling mode #129408

Closed
opened 2026-05-21 12:39:23 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/20729
Author: @Classic298
Created: 1/16/2026
Status: Closed

Base: devHead: fix-chat-tools


📝 Commits (1)

  • d59aa8e fix: respect built-in tool toggles in native function calling mode

📊 Changes

1 file changed (+19 additions, -12 deletions)

View changed files

📝 backend/open_webui/utils/tools.py (+19 -12)

📄 Description

fix: built-in tool toggles ignored in native function calling mode

Fixes: https://github.com/open-webui/open-webui/issues/20641

Problem

When using Native function calling mode with Built-in Tools capability enabled on a model, the chat interface toggles (web search ON/OFF, image generation ON/OFF, code interpreter ON/OFF) were completely ignored. All built-in tools were injected into the model's tool list regardless of the toggle state.

Impact

User Control Broken:

  • Users explicitly turning OFF web search still had web search tools available to the model
  • Users could not prevent the model from performing unwanted actions (web searches, image generation, code execution)
  • The toggle UI in the chat interface was effectively non-functional in Native mode

Admin Control Broken:

  • Admins using inlet() filters to programmatically disable tools (e.g., disabling web search when documents are attached) had no effect
  • Security and compliance policies could not be enforced via tool control in Native mode

Inconsistent Behavior:

  • Default mode correctly respected toggles (toggles control whether task model is prompted about each tool)
  • Native mode ignored toggles entirely
  • This created confusion where the same UI behaved differently depending on function calling mode

Reproduction Steps

  1. Configure a model with Native function calling enabled and Built-in Tools capability ON
  2. Start a new chat
  3. Turn OFF the web search toggle in the chat interface
  4. Send a message like "Search the web for the latest AI news"
  5. Observe that the model still has search_web in its tool list and can perform searches

Root Cause

In the get_builtin_tools function, the pattern for checking whether to inject a tool was inconsistent:

Memory tools (correct pattern):

  • Checked features.get("memory") — the toggle state from the chat interface
  • Tools only injected when toggle is ON

Web search, image generation, code interpreter (broken pattern):

  • Only checked global config (e.g., ENABLE_WEB_SEARCH) and model capability
  • Did NOT check the toggle state from features dict
  • Tools injected whenever global config and model capability allowed, regardless of toggle
    The features dict is populated from form_data after inlet() filters run, so this also meant inlet() filter modifications to toggle state had no effect on Native mode tool injection.

Solution

Added the missing feature toggle checks to align with the memory tools pattern:
Web search tools:

  • Added: and features.get("web_search")
    Image generation/edit tools:
  • Added: and features.get("image_generation")
    Code interpreter tool:
  • Added: and features.get("code_interpreter")
    Now all built-in tools follow the same three-layer control model:
  1. Global config must enable the feature (admin-level master switch)
  2. Model capability must allow it (per-model configuration)
  3. Per-chat toggle must be ON (user control / inlet() filter control)

Behavior After Fix

Global Config Model Capability Chat Toggle Tool Injected?
OFF Any Any No
ON OFF Any No
ON ON OFF No
ON ON ON Yes

Backward Compatibility

  • Default mode behavior is completely unchanged (this code path is only for Native function calling)
  • No changes to API contracts or data structures
  • Existing configurations will work — users who had toggles ON will continue to have tools available

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.

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 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/20729 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 1/16/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix-chat-tools` --- ### 📝 Commits (1) - [`d59aa8e`](https://github.com/open-webui/open-webui/commit/d59aa8ee84b3031569bfbe25fc237f9e60aba2d2) fix: respect built-in tool toggles in native function calling mode ### 📊 Changes **1 file changed** (+19 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/tools.py` (+19 -12) </details> ### 📄 Description # fix: built-in tool toggles ignored in native function calling mode Fixes: https://github.com/open-webui/open-webui/issues/20641 ## Problem When using Native function calling mode with Built-in Tools capability enabled on a model, the chat interface toggles (web search ON/OFF, image generation ON/OFF, code interpreter ON/OFF) were completely ignored. All built-in tools were injected into the model's tool list regardless of the toggle state. ### Impact **User Control Broken:** - Users explicitly turning OFF web search still had web search tools available to the model - Users could not prevent the model from performing unwanted actions (web searches, image generation, code execution) - The toggle UI in the chat interface was effectively non-functional in Native mode **Admin Control Broken:** - Admins using inlet() filters to programmatically disable tools (e.g., disabling web search when documents are attached) had no effect - Security and compliance policies could not be enforced via tool control in Native mode **Inconsistent Behavior:** - Default mode correctly respected toggles (toggles control whether task model is prompted about each tool) - Native mode ignored toggles entirely - This created confusion where the same UI behaved differently depending on function calling mode ### Reproduction Steps 1. Configure a model with Native function calling enabled and Built-in Tools capability ON 2. Start a new chat 3. Turn OFF the web search toggle in the chat interface 4. Send a message like "Search the web for the latest AI news" 5. Observe that the model still has search_web in its tool list and can perform searches ## Root Cause In the get_builtin_tools function, the pattern for checking whether to inject a tool was inconsistent: **Memory tools (correct pattern):** - Checked features.get("memory") — the toggle state from the chat interface - Tools only injected when toggle is ON **Web search, image generation, code interpreter (broken pattern):** - Only checked global config (e.g., ENABLE_WEB_SEARCH) and model capability - Did NOT check the toggle state from features dict - Tools injected whenever global config and model capability allowed, regardless of toggle The features dict is populated from form_data after inlet() filters run, so this also meant inlet() filter modifications to toggle state had no effect on Native mode tool injection. ## Solution Added the missing feature toggle checks to align with the memory tools pattern: **Web search tools:** - Added: `and features.get("web_search")` **Image generation/edit tools:** - Added: `and features.get("image_generation")` **Code interpreter tool:** - Added: `and features.get("code_interpreter")` Now all built-in tools follow the same three-layer control model: 1. Global config must enable the feature (admin-level master switch) 2. Model capability must allow it (per-model configuration) 3. Per-chat toggle must be ON (user control / inlet() filter control) ## Behavior After Fix | Global Config | Model Capability | Chat Toggle | Tool Injected? | |---------------|------------------|-------------|----------------| | OFF | Any | Any | No | | ON | OFF | Any | No | | ON | ON | OFF | No | | ON | ON | ON | Yes | ## Backward Compatibility - Default mode behavior is completely unchanged (this code path is only for Native function calling) - No changes to API contracts or data structures - Existing configurations will work — users who had toggles ON will continue to have tools available ### 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. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <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-05-21 12:39:23 -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#129408