diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 1c6f1fc510..5a10db3386 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -2538,7 +2538,13 @@ async def process_chat_payload(request, form_data, user, metadata, model): ) if 'memory' in features and features['memory'] and await Config.get('memories.system_context.enable'): - form_data = await add_memory_context(request, form_data, user, model) + # 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', ''), + 'features.memories', + await Config.get('user.permissions'), + ): + form_data = await add_memory_context(request, form_data, user, model) if 'web_search' in features and features['web_search']: # features is client-supplied; re-check the permission the native FC path enforces.