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
{{ message }}
Repository navigation
Commit 87ac766
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/cli/sandbox.md
+25Lines changed: 25 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -150,6 +150,30 @@ openclaw sandbox recreate --agent family
150
150
openclaw sandbox recreate --agent alfred
151
151
```
152
152
153
+
### Managed ephemeral session sandboxes
154
+
155
+
For long-running task or thread owners, combine session scope with lifecycle cleanup:
156
+
157
+
```jsonc
158
+
{
159
+
"agents": {
160
+
"defaults": {
161
+
"sandbox": {
162
+
"mode":"all",
163
+
"scope":"session",
164
+
"prune": {
165
+
"idleHours":12,
166
+
"maxAgeDays":3,
167
+
"onSessionEnd":true,
168
+
},
169
+
},
170
+
},
171
+
},
172
+
}
173
+
```
174
+
175
+
OpenClaw reuses the same sandbox runtime for the same session/thread key while that owner is active. When the owning session is reset, deleted, or rolled over by idle/daily reset policy, OpenClaw removes the matching runtime, browser runtime, registry entries, and non-shared sandbox workspace. Idle and max-age prune remain the crash-recovery path for owners that never reach a clean lifecycle end, and remove stale session-scope workspaces after the runtime cleanup succeeds.
176
+
153
177
## Why this is needed
154
178
155
179
When you update sandbox configuration:
@@ -193,6 +217,7 @@ Sandbox settings live in `~/.openclaw/openclaw.json` under `agents.defaults.sand
193
217
"prune": {
194
218
"idleHours":24, // Auto-prune after 24h idle
195
219
"maxAgeDays":7, // Auto-prune after 7 days
220
+
"onSessionEnd":false, // Remove session-scoped resources on reset/delete/rollover
Copy file name to clipboardExpand all lines: docs/gateway/config-agents.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -861,6 +861,7 @@ Optional sandboxing for the embedded agent. See [Sandboxing](/gateway/sandboxing
861
861
prune: {
862
862
idleHours:24,
863
863
maxAgeDays:7,
864
+
onSessionEnd:false,
864
865
},
865
866
},
866
867
},
@@ -929,6 +930,12 @@ When `backend: "openshell"` is selected, runtime-specific settings move to
929
930
-`ro`: sandbox workspace at `/workspace`, agent workspace mounted read-only at `/agent`
930
931
-`rw`: agent workspace mounted read/write at `/workspace`
931
932
933
+
**Lifecycle cleanup:**
934
+
935
+
-`prune.idleHours`: remove idle sandbox runtimes after this many hours (`0` disables idle pruning)
936
+
-`prune.maxAgeDays`: remove sandbox runtimes older than this many days (`0` disables age pruning)
937
+
-`prune.onSessionEnd`: opt-in cleanup for `scope: "session"`; removes matching runtimes, browser runtimes, registry entries, and non-shared sandbox workspaces when the owning session is reset, deleted, or rolled over by idle/daily reset policy
Copy file name to clipboardExpand all lines: docs/gateway/sandboxing.md
+31Lines changed: 31 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -173,6 +173,37 @@ Use `backend: "ssh"` when you want OpenClaw to sandbox `exec`, file tools, and m
173
173
</Accordion>
174
174
</AccordionGroup>
175
175
176
+
### Managed ephemeral session lifecycle
177
+
178
+
Use `scope: "session"` when a task, thread, or spawned child session needs deterministic sandbox reuse while it is active. Add `prune.onSessionEnd: true` when that owner should be ephemeral:
179
+
180
+
```json5
181
+
{
182
+
agents: {
183
+
defaults: {
184
+
sandbox: {
185
+
mode:"all",
186
+
scope:"session",
187
+
prune: {
188
+
idleHours:12,
189
+
maxAgeDays:3,
190
+
onSessionEnd:true,
191
+
},
192
+
},
193
+
},
194
+
},
195
+
}
196
+
```
197
+
198
+
With this opt-in lifecycle, OpenClaw:
199
+
200
+
- creates and reuses one sandbox per session/thread key
201
+
- removes the matching runtime, browser runtime, registry entries, and non-shared sandbox workspace when the owning session is reset, deleted, or rolled over by idle/daily reset policy
202
+
- uses idle/max-age prune as crash recovery for owners that stop without a clean lifecycle end; after a stale session-scope runtime is removed, prune also removes that scope's sandbox workspace
203
+
- still lets operators force a rebuild with `openclaw sandbox recreate --session <key>`
204
+
205
+
This does not enable sandboxing globally, does not affect `scope: "agent"` or `scope: "shared"`, and does not tear down a still-active owner after every turn.
206
+
176
207
### OpenShell backend
177
208
178
209
Use `backend: "openshell"` when you want OpenClaw to sandbox tools in an OpenShell-managed remote environment. For the full setup guide, configuration reference, and workspace mode comparison, see the dedicated [OpenShell page](/gateway/openshell).
0 commit comments