From 368b4a5b2279bbf9968a85b3b94d26d375d02afc Mon Sep 17 00:00:00 2001 From: alvarellos Date: Mon, 29 Jun 2026 07:56:44 +0200 Subject: [PATCH] solve-valves-icon-disappear-issue (#26256) --- backend/open_webui/models/tools.py | 1 + backend/open_webui/routers/tools.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/models/tools.py b/backend/open_webui/models/tools.py index d575cc1439..4362f81216 100644 --- a/backend/open_webui/models/tools.py +++ b/backend/open_webui/models/tools.py @@ -35,6 +35,7 @@ class Tool(Base): # database table definition class ToolMeta(BaseModel): description: str | None = None manifest: dict | None = {} + has_user_valves: bool = False class ToolModel(BaseModel): diff --git a/backend/open_webui/routers/tools.py b/backend/open_webui/routers/tools.py index a085d2be01..ca23d17f7c 100644 --- a/backend/open_webui/routers/tools.py +++ b/backend/open_webui/routers/tools.py @@ -75,11 +75,15 @@ async def get_tools( tools_cache = get_tools_cache(request) for tool in await Tools.get_tools(defer_content=True, db=db): tool_module = tools_cache.get(tool.id) + has_user_valves = ( + hasattr(tool_module, 'UserValves') if tool_module + else (tool.meta.has_user_valves if tool.meta else False) + ) tools.append( ToolUserResponse( **{ **tool.model_dump(), - 'has_user_valves': (hasattr(tool_module, 'UserValves') if tool_module else False), + 'has_user_valves': has_user_valves, } ) ) @@ -370,6 +374,7 @@ async def create_new_tools( form_data.content = replace_imports(form_data.content) tool_module, frontmatter = await load_tool_module_by_id(form_data.id, content=form_data.content) form_data.meta.manifest = frontmatter + form_data.meta.has_user_valves = hasattr(tool_module, 'UserValves') TOOLS = get_tools_cache(request) TOOLS[form_data.id] = tool_module @@ -507,6 +512,7 @@ async def update_tools_by_id( form_data.content = replace_imports(form_data.content) tool_module, frontmatter = await load_tool_module_by_id(id, content=form_data.content) form_data.meta.manifest = frontmatter + form_data.meta.has_user_valves = hasattr(tool_module, 'UserValves') TOOLS = get_tools_cache(request) TOOLS[id] = tool_module