← Back to PRs

#4467: fix: DEFAULT_SANDBOX_WORKSPACE_ROOT respects STATE_DIR

by Aphroq open 2026-01-30 07:51 View on GitHub →
agents
## Summary Fixes #4368 `DEFAULT_SANDBOX_WORKSPACE_ROOT` was hardcoded to `~/.openclaw/sandboxes`, ignoring the `MOLTBOT_STATE_DIR` environment variable. This caused `~/.clawdbot/sandboxes/` to be recreated even when `MOLTBOT_STATE_DIR=~/.moltbot` was set. ## Changes - Moved the `resolvedStateDir` variable to the top of the file (before `DEFAULT_SANDBOX_WORKSPACE_ROOT`) - Updated `DEFAULT_SANDBOX_WORKSPACE_ROOT` to use `resolvedStateDir` instead of hardcoded path - Removed the duplicate `resolvedSandboxStateDir` variable (now reuses `resolvedStateDir`) ## Testing - Lint: ✅ passed - Build: ✅ passed - Awaiting CI for full test suite <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR updates sandbox path constants so the default workspace root now derives from the resolved global state directory (`STATE_DIR`) rather than always using `~/.openclaw`. It also removes a duplicate “resolved sandbox state dir” variable and reuses the shared resolved state dir for both `DEFAULT_SANDBOX_WORKSPACE_ROOT` and `SANDBOX_STATE_DIR`, aligning sandbox storage with the configured state directory behavior in the rest of the codebase. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk. - The change is a small refactor in a single constants file: it switches the default sandbox workspace root to be derived from the already-established `STATE_DIR` resolution logic and removes a redundant variable. The new behavior is consistent with how state directory overrides are resolved elsewhere (`src/config/paths.ts`), and there are no new control flows or I/O introduced. - src/agents/sandbox/constants.ts <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs