From 702da1e471abd9444143114debfd511d45aa8214 Mon Sep 17 00:00:00 2001 From: G30 <50341825+silentoplayz@users.noreply.github.com> Date: Mon, 21 Sep 2026 01:00:08 -0400 Subject: [PATCH] fix: stop injecting memories and memory tools when memory is switched off (#30228) --- backend/open_webui/utils/middleware.py | 7 ++++++- backend/open_webui/utils/tools.py | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 4c2711668d..ad784658c8 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -2683,7 +2683,12 @@ async def process_chat_payload(request, form_data, user, metadata, model): form_data['messages'], ) - if 'memory' in features and features['memory'] and await Config.get('memories.system_context.enable'): + if ( + 'memory' in features + and features['memory'] + and await Config.get('memories.enable') + and await Config.get('memories.system_context.enable') + ): # features is client-supplied; re-check the permission the native FC path enforces. if getattr(user, 'role', None) == 'admin' or await has_permission( getattr(user, 'id', ''), diff --git a/backend/open_webui/utils/tools.py b/backend/open_webui/utils/tools.py index 31485112a9..7bd6a8dd69 100644 --- a/backend/open_webui/utils/tools.py +++ b/backend/open_webui/utils/tools.py @@ -542,6 +542,7 @@ async def get_builtin_tools( # Helper to check user-level feature permission (admins always pass) user = extra_params.get('__user__', {}) config = await Config.get_many( + 'memories.enable', 'web.search.enable', 'image_generation.enable', 'images.edit.enable', @@ -655,6 +656,7 @@ async def get_builtin_tools( # Add memory tools when memory is enabled and the model allows this builtin category. if ( is_builtin_tool_enabled('memory') + and config.get('memories.enable') and features.get('memory') and get_model_capability('memory') and await has_user_permission('memories')