From a775fc9b5087a06bb3b5d765cde4654d201f6861 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Wed, 8 Apr 2026 13:34:23 -0700 Subject: [PATCH] refac --- backend/open_webui/functions.py | 13 +------------ backend/open_webui/utils/middleware.py | 5 ++++- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/backend/open_webui/functions.py b/backend/open_webui/functions.py index 9bfe77c41..6a1fe2214 100644 --- a/backend/open_webui/functions.py +++ b/backend/open_webui/functions.py @@ -34,7 +34,6 @@ from open_webui.utils.plugin import ( load_function_module_by_id, get_function_module_from_cache, ) -from open_webui.utils.tools import get_tools from open_webui.env import GLOBAL_LOG_LEVEL @@ -255,17 +254,7 @@ async def generate_function_chat_completion(request, form_data, user, models: di '__oauth_token__': oauth_token, '__request__': request, } - extra_params['__tools__'] = await get_tools( - request, - tool_ids, - user, - { - **extra_params, - '__model__': models.get(form_data['model'], None), - '__messages__': form_data['messages'], - '__files__': files, - }, - ) + extra_params['__tools__'] = metadata.get('tools', {}) if model_info: if model_info.base_model_id: diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 54df422c4..0dedd7f2f 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -2680,9 +2680,12 @@ async def process_chat_payload(request, form_data, user, metadata, model): tools_dict[name] = tool_dict if tools_dict: + # Always store resolved tools in metadata so downstream consumers + # (e.g. pipe functions) can access all tools including MCP and builtins. + metadata['tools'] = tools_dict + if metadata.get('params', {}).get('function_calling') == 'native': # If the function calling is native, then call the tools function calling handler - metadata['tools'] = tools_dict form_data['tools'] = [ {'type': 'function', 'function': tool.get('spec', {})} for tool in tools_dict.values() ]