You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Production agents running in OpenShell sandboxes accumulate critical state over time: workspace files (personality, memory, identity documents), config, auth profiles, and session history. Today there is no built-in mechanism to:
Continuously mirror sandbox state to the host — if the sandbox is destroyed (Docker restart, volume corruption, machine migration), agent persona and memory are lost
Push content into a running sandbox without SSH or manual openshell sandbox upload invocations
Maintain point-in-time snapshots for rollback if state gets corrupted
The existing sandbox upload / sandbox download commands are building blocks, but users must build their own cron + scripting layer on top. The gateway resume work in #487/#488 handles surviving restarts, but doesn't cover: (a) continuous backup during normal operation, (b) content delivery into sandboxes, or (c) recovery when a full rebuild is needed.
Real-world impact: We run 3+ always-on OpenClaw agents on Mac Minis (details in #487 comment). Every Docker restart destroys all agent state — personality, memory, conversation history, config. We built a host-side sync script as a workaround, but this belongs in the platform.
Proposed Design
New CLI command: openshell sandbox sync
openshell sandbox sync <NAME> [OPTIONS]
OPTIONS:
--push-dir <PATH> Local directory to push into sandbox (default: ~/sandbox-sync/<name>/push)
--push-dest <PATH> Sandbox destination for pushed files (default: /sandbox/sync)
--backup-dir <PATH> Local directory for pulled backups (default: ~/sandbox-sync/<name>/backup)
--backup-paths <PATHS> Comma-separated sandbox paths to back up (see defaults below)
--interval <DURATION> Sync interval for watch mode (default: 1h)
--watch Run continuously at --interval instead of one-shot
--snapshot Also create a timestamped snapshot after pull
--quiet Suppress non-error output
Default backup paths (agent-framework-aware)
The sync command should ship with sensible defaults for common agent frameworks:
# OpenClaw defaults (detected via /sandbox/.openclaw/)
- /sandbox/.openclaw/workspace/ # SOUL.md, IDENTITY.md, HEARTBEAT.md, USER.md, etc.
- /sandbox/.openclaw/openclaw.json # Gateway config
- /sandbox/.openclaw/agents/ # Auth profiles, session state# Generic defaults (always included)
- /sandbox/.bashrc
- /sandbox/.claude/ # Claude Code memory/settings if present
Users can override with --backup-paths or a .openshell-sync.yaml config file in the sync directory.
Behavior
One-shot mode (openshell sandbox sync agent):
If push/ has contents → sandbox upload them to --push-dest
For each path in --backup-paths → sandbox download to backup/
If --snapshot → copy backup to backup/snapshots/YYYY-MM-DD-HHMMSS/
Host-side shell script + cron (current workaround): Works but fragile — no sandbox health checks, no framework detection, no config file, each team reinvents it. Our implementation can serve as a reference.
Docker volume mounts: Would bypass the sandbox isolation model. Not compatible with OpenShell's security architecture.
Extend sandbox upload/download with --watch: Simpler but doesn't handle the bidirectional sync + backup + snapshot lifecycle. A dedicated sync command better communicates the intent.
sandbox upload and sandbox download use tar-over-SSH transport (crates/openshell-sandbox/src/ssh/)
Sandbox phase checking exists in sandbox get — sync should reuse this
The --sync flag on sandbox create already establishes the pattern of host↔sandbox file sync at the CLI level
No existing watch/interval mechanism in the CLI — would need a simple loop or tokio interval in the Rust implementation
The upload bug (destination treated as directory when file exists) documented in OpenClaw-init known issues affects sync reliability — should be fixed as a prerequisite or worked around
Checklist
I've reviewed existing issues and the architecture docs
This is a design proposal, not a "please build this" request
Problem Statement
Production agents running in OpenShell sandboxes accumulate critical state over time: workspace files (personality, memory, identity documents), config, auth profiles, and session history. Today there is no built-in mechanism to:
openshell sandbox uploadinvocationsThe existing
sandbox upload/sandbox downloadcommands are building blocks, but users must build their own cron + scripting layer on top. The gateway resume work in #487/#488 handles surviving restarts, but doesn't cover: (a) continuous backup during normal operation, (b) content delivery into sandboxes, or (c) recovery when a full rebuild is needed.Real-world impact: We run 3+ always-on OpenClaw agents on Mac Minis (details in #487 comment). Every Docker restart destroys all agent state — personality, memory, conversation history, config. We built a host-side sync script as a workaround, but this belongs in the platform.
Proposed Design
New CLI command:
openshell sandbox syncDefault backup paths (agent-framework-aware)
The sync command should ship with sensible defaults for common agent frameworks:
Users can override with
--backup-pathsor a.openshell-sync.yamlconfig file in the sync directory.Behavior
One-shot mode (
openshell sandbox sync agent):push/has contents →sandbox uploadthem to--push-dest--backup-paths→sandbox downloadtobackup/--snapshot→ copy backup tobackup/snapshots/YYYY-MM-DD-HHMMSS/Watch mode (
openshell sandbox sync agent --watch):--interval~/sandbox-sync/<name>/sync.logDirectory layout (created automatically)
Integration with existing commands
sandbox uploadandsandbox downloadinternally — no new transport mechanism needed.gitignorefiltering on push (existing--no-git-ignoreflag)Ready)sandbox create --restore-fromfor full lifecycleConfig file format (optional)
Alternatives Considered
Host-side shell script + cron (current workaround): Works but fragile — no sandbox health checks, no framework detection, no config file, each team reinvents it. Our implementation can serve as a reference.
Docker volume mounts: Would bypass the sandbox isolation model. Not compatible with OpenShell's security architecture.
Extend
sandbox upload/downloadwith--watch: Simpler but doesn't handle the bidirectional sync + backup + snapshot lifecycle. A dedicatedsynccommand better communicates the intent.Build into gateway resume (feat: gateway resume from existing state and persistent SSH handshake secret #487/feat(bootstrap): resume gateway from existing state and persist SSH handshake secret #488): Gateway resume handles restart survival but not continuous backup, content delivery, or cross-machine migration. These are complementary — sync runs during normal operation, resume handles the restart edge case.
Agent Investigation
Explored the existing CLI structure:
sandbox uploadandsandbox downloaduse tar-over-SSH transport (crates/openshell-sandbox/src/ssh/)sandbox get— sync should reuse this--syncflag onsandbox createalready establishes the pattern of host↔sandbox file sync at the CLI levelChecklist