From 94bdfe77e480913a2599d7d4b13229849600e63e Mon Sep 17 00:00:00 2001 From: phernandez Date: Thu, 26 Mar 2026 14:53:12 -0500 Subject: [PATCH] fix: detect cloud mode in resolve_runtime_mode BASIC_MEMORY_CLOUD_MODE env var was never checked in resolve_runtime_mode(), so cloud deployments always ran as LOCAL mode. This caused file sync to start in the cloud container, which then failed with "DATABASE_URL must be set when using Postgres backend" because there's no local DB in cloud mode. Co-Authored-By: Claude Opus 4.6 (1M context) Signed-off-by: phernandez --- src/basic_memory/runtime.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/basic_memory/runtime.py b/src/basic_memory/runtime.py index 4868e98e..502761fe 100644 --- a/src/basic_memory/runtime.py +++ b/src/basic_memory/runtime.py @@ -7,6 +7,7 @@ Composition roots (containers) read ConfigManager and use this module to resolve the runtime mode, then pass the result downstream. """ +import os from enum import Enum, auto @@ -44,10 +45,16 @@ def resolve_runtime_mode( Returns: The resolved RuntimeMode """ - # Trigger: test environment is detected - # Why: tests need special handling (no file sync, isolated DB) - # Outcome: returns TEST mode, skipping cloud mode check if is_test_env: return RuntimeMode.TEST + # Trigger: BASIC_MEMORY_CLOUD_MODE env var is set + # Why: cloud deployments must not start local file sync — cloud handles + # file storage via S3/Tigris, and the local sync tries to open a + # SQLite/Postgres DB that doesn't exist in the cloud container + # Outcome: returns CLOUD mode, skipping file sync initialization + cloud_mode = os.getenv("BASIC_MEMORY_CLOUD_MODE", "").lower() in ("1", "true") + if cloud_mode: + return RuntimeMode.CLOUD + return RuntimeMode.LOCAL