[PR #19118] [CLOSED] fix: __user__['valves'] should reflect current tool's UserValves when using multiple tools #96133

Closed
opened 2026-05-15 22:21:45 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/19118
Author: @Podden
Created: 11/11/2025
Status: Closed

Base: devHead: fix-uservalves-multiple-tools


📝 Commits (1)

  • 23b639a fix: user['valves'] should reflect current tool's UserValves when using multiple tools

📊 Changes

1 file changed (+6 additions, -6 deletions)

View changed files

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

📄 Description

I noticed UserValves we're incorrect when custom pipe and multiple tools are used in a request:
All Tool are getting the same __user__["valves"], namely the valves from the last tool in the list, resulting in errors when calling methods who need uservalves.

I've pinpoint the root of the problem in tool.py, where extra_params is used in conjunction with functool.partial, which copies the dict but only references the content. When extra_params["user"]["valves"] gets overwritten by the next tool, it changes it for all tools, resulting in wrong uservalves per tool. Setting extra_params per method instead of per tool solved this problem.

Problem Example:

# Tool A - Function 1
extra_params["__user__"]["valves"] = UserValvesA()  # New Instance
partial_a1 = partial(func_a1, __user__=extra_params["__user__"])  # Saves reference to {"valves": UserValvesA}

# Tool B - Funktion 1
extra_params["__user__"]["valves"] = UserValvesB()  # Overwrites the value!
# extra_params["__user__"] dict is still the same object!
# partial_a1 is still pointing the this dics, but now it contains {"valves": UserValvesB}!
partial_b1 = partial(func_b1, __user__=extra_params["__user__"])

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/19118 **Author:** [@Podden](https://github.com/Podden) **Created:** 11/11/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix-uservalves-multiple-tools` --- ### 📝 Commits (1) - [`23b639a`](https://github.com/open-webui/open-webui/commit/23b639a8ad32aa0d207e938fee524882568a52e7) fix: __user__['valves'] should reflect current tool's UserValves when using multiple tools ### 📊 Changes **1 file changed** (+6 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/tools.py` (+6 -6) </details> ### 📄 Description I noticed UserValves we're incorrect when custom pipe and multiple tools are used in a request: All Tool are getting the same `__user__["valves"]`, namely the valves from the last tool in the list, resulting in errors when calling methods who need uservalves. I've pinpoint the root of the problem in `tool.py`, where `extra_params` is used in conjunction with `functool.partial`, which copies the dict but only references the content. When extra_params["__user__"]["valves"] gets overwritten by the next tool, it changes it for all tools, resulting in wrong uservalves per tool. Setting extra_params per method instead of per tool solved this problem. Problem Example: ``` python # Tool A - Function 1 extra_params["__user__"]["valves"] = UserValvesA() # New Instance partial_a1 = partial(func_a1, __user__=extra_params["__user__"]) # Saves reference to {"valves": UserValvesA} # Tool B - Funktion 1 extra_params["__user__"]["valves"] = UserValvesB() # Overwrites the value! # extra_params["__user__"] dict is still the same object! # partial_a1 is still pointing the this dics, but now it contains {"valves": UserValvesB}! partial_b1 = partial(func_b1, __user__=extra_params["__user__"]) ``` 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-05-15 22:21:45 -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#96133