Repository navigation
Description
Bug type
Behavior bug (incorrect output/state without crash)
Summary
Sandbox prune removes Docker containers but leaves workspace directories behind, causing disk space leak over time
Steps to reproduce
- Configure an agent with sandbox.prune.idleHours or sandbox.prune.maxAgeDays (e.g., idleHours: 168)
- Wait for the sandbox to expire (or trigger prune manually via openclaw sandbox prune)
- Check ~/.openclaw/sandboxes/ - old directories remain
- Docker containers are removed, but the agent--xxxx directories persist
Expected behavior
Both Docker containers AND workspace directories (~/.openclaw/sandboxes/agent--xxxx) should be cleaned up when sandbox expires due to idleHours or maxAgeDays
Actual behavior
Only Docker containers are removed (via docker rm -f). The workspace directories in ~/.openclaw/sandboxes/ persist after prune. This causes disk space leak over time.
OpenClaw version
2026.3.8
Operating system
macOS 25.2.0 (arm64)
Install method
No response
Model
minimax/MiniMax-M2.5
Provider / routing chain
minimax-portal (direct)
Config file / key location
No response
Additional provider/model setup details
No response
Logs, screenshots, and evidence
Impact and severity
Affected: Users with sandbox-enabled agents using prune settings
Severity: Medium (disk space leak)
Frequency: Always when sandbox expires
Consequence: Over time, ~/.openclaw/sandboxes/ fills up with orphaned directories, wasting disk space
Additional information
Source code location: src/agents/sandbox/prune.ts - the pruneSandboxRegistryEntries function only removes Docker containers and registry entries, but does not delete the workspace directory (~/.openclaw/sandboxes/agent--xxxx). Suggested fix: add fs.rm() to remove the sandbox workspace directory after container removal.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
climbran commentedon Mar 12, 2026
Additional context: This issue also affects configuration updates. Because the sandbox persists the workspace directory (~/.openclaw/sandboxes/agent--xxxx), changes to files like SOUL.md don't take effect even after gateway restart. Even manually removing Docker containers doesn't help - users must manually delete the sandbox directory to pick up config changes.
This suggests we need either:
openclaw sandbox rm --force <agentId>)fix(sandbox): prune should also clean up workspace directories
fix(sandbox): cleanup workspace directories during prune
fix(sandbox): cleanup workspace directories during prune
fix(sandbox): cleanup workspace directories during prune
fix(sandbox): cleanup workspace directories during prune
openclaw-barnacle commentedon Apr 27, 2026
This issue has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.
clawsweeper commentedon Apr 27, 2026
Codex review: this still needs some work.
Summary
Keep open: current main and v2026.10.5 still retain copied local workspaces after runtime pruning, while related lifecycle work leaves existing agent-scoped retention unresolved.
Reproducibility: Source establishes retained directories and reuse of existing bootstrap files; no live sandbox reproduction was run, and the reported sandbox prune subcommand does not exist in current CLI registration.
Root-cause cluster
Relationship:
canonicalCanonical: #43797
Summary: This issue remains the focused tracker for copied workspace retention after runtime pruning; the open managed-lifecycle proposal overlaps only part of that behavior.
Members:
same_root_cause: fix(sandbox): cleanup workspace directories during prune #43835 - Closed unmerged attempt to remove copied workspace directories during prune.partial_overlap: [Feature]: Managed ephemeral sandbox lifecycle for session-owned work #98516 - Open proposal adds opt-in session-owned terminal cleanup rather than settling all existing agent-scoped retention.partial_overlap: feat: add managed sandbox lifecycle #98766 - Open draft implements the session-owned lifecycle proposal and is not a merged fix for this issue.Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Maintainer decision needed
Next step
Decide existing agent-scoped workspace retention alongside #98766 before implementing automatic deletion.
Review details
Best possible solution:
Define workspace retention explicitly, preserve durable work, and provide owner-controlled cleanup or reset with a prune-and-recreate regression.
Do we have a high-confidence way to reproduce the issue?
Source establishes retained directories and reuse of existing bootstrap files; no live sandbox reproduction was run, and the reported sandbox prune subcommand does not exist in current CLI registration.
Is this the best way to solve the issue?
Unconditional fs.rm after runtime removal is insufficient because runtime expiry does not establish that copied workspace contents are disposable.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning medium; reviewed against 7f902d4b3873.
Label changes
Label changes:
clawsweeper:needs-maintainer-review: Current issue advisory state no longer selects this label.Label justifications:
P2: Retained sandbox directories are a bounded operator problem without evidence of an urgent outage.impact:session-state: Recreated runtimes can reuse copied bootstrap files and workspace state from the previous runtime.impact:other: Retained copied workspace directories continue consuming local disk space.Evidence reviewed
What I checked:
src/agents/sandbox/prune.ts:79, 7f902d4b3873)src/agents/sandbox/docker-backend.ts:417, 7f902d4b3873)src/agents/sandbox/shared.ts:104, 7f902d4b3873)src/agents/workspace-bootstrap-copy.ts:36, 7f902d4b3873)docs/cli/sandbox.md:28, 7f902d4b3873)src/agents/sandbox/prune.ts:79, 1b58cb9a1b4f)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.Reviewed October 19, 2026, 2:24 PM ET / 18:24 UTC.
60 remaining items
jinngimk-lang commentedon Aug 17, 2026
steipete commentedon Oct 22, 2026
Thanks for filing this. We're closing issues opened before April 2026 that no longer look actionable on current
main.Sandbox runtimes and their pruning have been reworked since this was filed, and the
openclaw sandbox prunecommand from the report no longer exists. Agent-scoped workspaces are intentionally kept so durable files survive runtime pruning. If disposable sandbox workspaces still pile up on a current release, please open a fresh issue with the config and the directories left behind.