Skip to content

Commit 94bdfe7

Browse files
phernandezclaude
andcommitted
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) <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
1 parent 4791e19 commit 94bdfe7

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/basic_memory/runtime.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
to resolve the runtime mode, then pass the result downstream.
88
"""
99

10+
import os
1011
from enum import Enum, auto
1112

1213

@@ -44,10 +45,16 @@ def resolve_runtime_mode(
4445
Returns:
4546
The resolved RuntimeMode
4647
"""
47-
# Trigger: test environment is detected
48-
# Why: tests need special handling (no file sync, isolated DB)
49-
# Outcome: returns TEST mode, skipping cloud mode check
5048
if is_test_env:
5149
return RuntimeMode.TEST
5250

51+
# Trigger: BASIC_MEMORY_CLOUD_MODE env var is set
52+
# Why: cloud deployments must not start local file sync — cloud handles
53+
# file storage via S3/Tigris, and the local sync tries to open a
54+
# SQLite/Postgres DB that doesn't exist in the cloud container
55+
# Outcome: returns CLOUD mode, skipping file sync initialization
56+
cloud_mode = os.getenv("BASIC_MEMORY_CLOUD_MODE", "").lower() in ("1", "true")
57+
if cloud_mode:
58+
return RuntimeMode.CLOUD
59+
5360
return RuntimeMode.LOCAL

0 commit comments

Comments
 (0)