fix: stop injecting memories and memory tools when memory is switched off (#30228)

This commit is contained in:
G30 2026-09-21 01:00:08 -04:00 • committed by GitHub
parent 85146206f6
commit 702da1e471
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View file

@ -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', ''),

View file

@ -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')