docs/gateway/openshell.md
OpenShell is a managed sandbox backend for OpenClaw. Instead of running Docker
containers locally, OpenClaw delegates sandbox lifecycle to the openshell CLI,
which provisions remote environments with SSH-based command execution.
The OpenShell plugin reuses the same core SSH transport and remote filesystem
bridge as the generic SSH backend. It adds
OpenShell-specific lifecycle (sandbox create/get/delete, sandbox ssh-config)
and an optional mirror workspace mode.
openshell CLI installed and on PATH (or set a custom path via
plugins.entries.openshell.config.command){
agents: {
defaults: {
sandbox: {
mode: "all",
backend: "openshell",
scope: "session",
workspaceAccess: "rw",
},
},
},
plugins: {
entries: {
openshell: {
enabled: true,
config: {
from: "openclaw",
mode: "remote",
},
},
},
},
}
Restart the Gateway. On the next agent turn, OpenClaw creates an OpenShell sandbox and routes tool execution through it.
Verify:
openclaw sandbox list
openclaw sandbox explain
This is the most important decision when using OpenShell.
mirrorUse plugins.entries.openshell.config.mode: "mirror" when you want the local
workspace to stay canonical.
Behavior:
exec, OpenClaw syncs the local workspace into the OpenShell sandbox.exec, OpenClaw syncs the remote workspace back to the local workspace.Best for:
Tradeoff: extra sync cost before and after each exec.
remoteUse plugins.entries.openshell.config.mode: "remote" when you want the
OpenShell workspace to become canonical.
Behavior:
exec, read, write, edit, and apply_patch operate
directly against the remote OpenShell workspace.Best for:
mirror | remote | |
|---|---|---|
| Canonical workspace | Local host | Remote OpenShell |
| Sync direction | Bidirectional (each exec) | One-time seed |
| Per-turn overhead | Higher (upload + download) | Lower (direct remote ops) |
| Local edits visible? | Yes, on next exec | No, until recreate |
| Best for | Development workflows | Long-running agents, CI |
All OpenShell config lives under plugins.entries.openshell.config:
| Key | Type | Default | Description |
|---|---|---|---|
mode | "mirror" or "remote" | "mirror" | Workspace sync mode |
command | string | "openshell" | Path or name of the openshell CLI |
from | string | "openclaw" | Sandbox source for first-time create |
gateway | string | — | OpenShell gateway name (--gateway) |
gatewayEndpoint | string | — | OpenShell gateway endpoint URL (--gateway-endpoint) |
policy | string | — | OpenShell policy ID for sandbox creation |
providers | string[] | [] | Provider names to attach when sandbox is created |
gpu | boolean | false | Request GPU resources |
autoProviders | boolean | true | Pass --auto-providers during sandbox create |
remoteWorkspaceDir | string | "/sandbox" | Primary writable workspace inside the sandbox |
remoteAgentWorkspaceDir | string | "/agent" | Agent workspace mount path (for read-only access) |
timeoutSeconds | number | 120 | Timeout for openshell CLI operations |
Sandbox-level settings (mode, scope, workspaceAccess) are configured under
agents.defaults.sandbox as with any backend. See
Sandboxing for the full matrix.
{
agents: {
defaults: {
sandbox: {
mode: "all",
backend: "openshell",
},
},
},
plugins: {
entries: {
openshell: {
enabled: true,
config: {
from: "openclaw",
mode: "remote",
},
},
},
},
}
{
agents: {
defaults: {
sandbox: {
mode: "all",
backend: "openshell",
scope: "agent",
workspaceAccess: "rw",
},
},
},
plugins: {
entries: {
openshell: {
enabled: true,
config: {
from: "openclaw",
mode: "mirror",
gpu: true,
providers: ["openai"],
timeoutSeconds: 180,
},
},
},
},
}
{
agents: {
defaults: {
sandbox: { mode: "off" },
},
list: [
{
id: "researcher",
sandbox: {
mode: "all",
backend: "openshell",
scope: "agent",
workspaceAccess: "rw",
},
},
],
},
plugins: {
entries: {
openshell: {
enabled: true,
config: {
from: "openclaw",
mode: "remote",
gateway: "lab",
gatewayEndpoint: "https://lab.example",
policy: "strict",
},
},
},
},
}
OpenShell sandboxes are managed through the normal sandbox CLI:
# List all sandbox runtimes (Docker + OpenShell)
openclaw sandbox list
# Inspect effective policy
openclaw sandbox explain
# Recreate (deletes remote workspace, re-seeds on next use)
openclaw sandbox recreate --all
For remote mode, recreate is especially important: it deletes the canonical
remote workspace for that scope. The next use seeds a fresh remote workspace from
the local workspace.
For mirror mode, recreate mainly resets the remote execution environment because
the local workspace remains canonical.
Recreate after changing any of these:
agents.defaults.sandbox.backendplugins.entries.openshell.config.fromplugins.entries.openshell.config.modeplugins.entries.openshell.config.policyopenclaw sandbox recreate --all
OpenShell pins the workspace root fd and rechecks sandbox identity before each read, so symlink swaps or a remounted workspace cannot redirect reads out of the intended remote workspace.
sandbox.docker.binds does not apply to OpenShell.sandbox.docker.* apply only to the Docker
backend.openshell sandbox create (with --from, --gateway,
--policy, --providers, --gpu flags as configured).openshell sandbox ssh-config <name> to get SSH connection
details for the sandbox.mirror mode: sync local to remote before exec, run, sync back after exec.remote mode: seed once on create, then operate directly on the remote
workspace.openclaw sandbox commands