diff --git a/.env.example b/.env.example
index df63e08e0e..55bf5d386f 100644
--- a/.env.example
+++ b/.env.example
@@ -13,6 +13,9 @@ OPENAI_API_KEY=''
# CORS_ALLOW_ORIGIN='http://localhost:5173;http://localhost:8080'
CORS_ALLOW_ORIGIN='*'
+# Set to false to keep memory tools enabled without adding memory context to the system context.
+ENABLE_MEMORY_SYSTEM_CONTEXT=true
+
# For production you should set this to match the proxy configuration (127.0.0.1)
FORWARDED_ALLOW_IPS='*'
diff --git a/backend/open_webui/config.py b/backend/open_webui/config.py
index 7cadde33fe..058348365b 100644
--- a/backend/open_webui/config.py
+++ b/backend/open_webui/config.py
@@ -394,6 +394,7 @@ CODE_EXECUTION_JUPYTER_TIMEOUT = int(os.getenv('CODE_EXECUTION_JUPYTER_TIMEOUT',
ENABLE_CODE_INTERPRETER = os.getenv('ENABLE_CODE_INTERPRETER', 'True').lower() == 'true'
ENABLE_MEMORIES = os.getenv('ENABLE_MEMORIES', 'True').lower() == 'true'
+ENABLE_MEMORY_SYSTEM_CONTEXT = os.getenv('ENABLE_MEMORY_SYSTEM_CONTEXT', 'True').lower() == 'true'
ENABLE_MEMORY_BACKGROUND_REVIEW = os.getenv('ENABLE_MEMORY_BACKGROUND_REVIEW', 'False').lower() == 'true'
MEMORIES_REVIEW_INTERVAL_TURNS = int(os.getenv('MEMORIES_REVIEW_INTERVAL_TURNS', '10'))
MEMORIES_USER_CHAR_LIMIT = int(os.getenv('MEMORIES_USER_CHAR_LIMIT', '2000'))
@@ -2741,6 +2742,7 @@ DEFAULT_CONFIG = {
'code_execution.jupyter.timeout': CODE_EXECUTION_JUPYTER_TIMEOUT,
'code_interpreter.enable': ENABLE_CODE_INTERPRETER,
'memories.enable': ENABLE_MEMORIES,
+ 'memories.system_context.enable': ENABLE_MEMORY_SYSTEM_CONTEXT,
'memories.background_review.enable': ENABLE_MEMORY_BACKGROUND_REVIEW,
'memories.review_interval_turns': MEMORIES_REVIEW_INTERVAL_TURNS,
'memories.user_char_limit': MEMORIES_USER_CHAR_LIMIT,
diff --git a/backend/open_webui/routers/auths.py b/backend/open_webui/routers/auths.py
index 9f71ecafb8..660b9e7d96 100644
--- a/backend/open_webui/routers/auths.py
+++ b/backend/open_webui/routers/auths.py
@@ -105,6 +105,7 @@ ADMIN_CONFIG_KEYS = {
'ENABLE_CHANNELS': 'channels.enable',
'ENABLE_CALENDAR': 'calendar.enable',
'ENABLE_MEMORIES': 'memories.enable',
+ 'ENABLE_MEMORY_SYSTEM_CONTEXT': 'memories.system_context.enable',
'ENABLE_NOTES': 'notes.enable',
'ENABLE_USER_WEBHOOKS': 'ui.enable_user_webhooks',
'ENABLE_USER_STATUS': 'users.enable_status',
@@ -1142,6 +1143,7 @@ class AdminConfig(BaseModel):
ENABLE_CHANNELS: bool
ENABLE_CALENDAR: bool
ENABLE_MEMORIES: bool
+ ENABLE_MEMORY_SYSTEM_CONTEXT: bool
ENABLE_NOTES: bool
ENABLE_USER_WEBHOOKS: bool
ENABLE_USER_STATUS: bool
diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py
index fc8802a683..c9121120f7 100644
--- a/backend/open_webui/utils/middleware.py
+++ b/backend/open_webui/utils/middleware.py
@@ -2427,7 +2427,7 @@ async def process_chat_payload(request, form_data, user, metadata, model):
form_data['messages'],
)
- if 'memory' in features and features['memory']:
+ 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)
if 'web_search' in features and features['web_search']:
diff --git a/src/lib/components/admin/Settings/General.svelte b/src/lib/components/admin/Settings/General.svelte
index 44c4f44628..3d0a916a1b 100644
--- a/src/lib/components/admin/Settings/General.svelte
+++ b/src/lib/components/admin/Settings/General.svelte
@@ -297,6 +297,16 @@