From 48334b10c2569308176b4d7b3105c7341b4543eb Mon Sep 17 00:00:00 2001 From: c <37263590+Aphroq@users.noreply.github.com> Date: Fri, 30 Jan 2026 07:49:30 +0000 Subject: [PATCH] fix: DEFAULT_SANDBOX_WORKSPACE_ROOT respects STATE_DIR Fixes #4368 Previously DEFAULT_SANDBOX_WORKSPACE_ROOT was hardcoded to ~/.openclaw/sandboxes, ignoring the MOLTBOT_STATE_DIR environment variable. Now it uses the same resolvedStateDir as other sandbox paths for consistency. --- src/agents/sandbox/constants.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/agents/sandbox/constants.ts b/src/agents/sandbox/constants.ts index 80a5e0fe0..7f058edee 100644 --- a/src/agents/sandbox/constants.ts +++ b/src/agents/sandbox/constants.ts @@ -4,7 +4,8 @@ import path from "node:path"; import { CHANNEL_IDS } from "../../channels/registry.js"; import { STATE_DIR } from "../../config/config.js"; -export const DEFAULT_SANDBOX_WORKSPACE_ROOT = path.join(os.homedir(), ".openclaw", "sandboxes"); +const resolvedStateDir = STATE_DIR ?? path.join(os.homedir(), ".openclaw"); +export const DEFAULT_SANDBOX_WORKSPACE_ROOT = path.join(resolvedStateDir, "sandboxes"); export const DEFAULT_SANDBOX_IMAGE = "openclaw-sandbox:bookworm-slim"; export const DEFAULT_SANDBOX_CONTAINER_PREFIX = "openclaw-sbx-"; @@ -48,7 +49,6 @@ export const DEFAULT_SANDBOX_BROWSER_AUTOSTART_TIMEOUT_MS = 12_000; export const SANDBOX_AGENT_WORKSPACE_MOUNT = "/agent"; -const resolvedSandboxStateDir = STATE_DIR ?? path.join(os.homedir(), ".openclaw"); -export const SANDBOX_STATE_DIR = path.join(resolvedSandboxStateDir, "sandbox"); +export const SANDBOX_STATE_DIR = path.join(resolvedStateDir, "sandbox"); export const SANDBOX_REGISTRY_PATH = path.join(SANDBOX_STATE_DIR, "containers.json"); export const SANDBOX_BROWSER_REGISTRY_PATH = path.join(SANDBOX_STATE_DIR, "browsers.json");