What sandbox and tool-policy baseline would you set for an OpenClaw agent that answers strangers in public groups, and what risk does it still leave?
answer
- a separate agent, not a flag
- mode, scope, workspace access
- deny runtime, fs, automation
- delegation and cross-chat sends
- one trust boundary remains
basics
~20 sGive public traffic its own agent: sandbox mode all, workspaceAccess none, no network, a deny list covering shell, file, automation and delegation tools, and elevated off. One Gateway is still one trust boundary, so messaging and session reach remain the residual risk.
solid answer
~40 sI would route public groups to a **dedicated agent** rather than tune my personal one. Its sandbox: `mode: "all"`, `scope: "agent"` or `"session"`, `workspaceAccess: "none"`, Docker's default `network: "none"`. Its tool policy: the `messaging` profile, then deny `group:runtime`, `group:fs`, `group:automation`, `browser`, `nodes` and `sessions_spawn`, with `tools.elevated.enabled: false` for that agent. Then I would close the reach the defaults leave open: session visibility (`tools.sessions.visibility`), agent-to-agent messaging (`tools.agentToAgent`) and cross-conversation sends. What remains is that the agent still talks, holds whatever its own sessions contain, and shares a Gateway with trusted agents. OpenClaw's trust model is one operator per Gateway, so participants who are mutually adversarial need a separate Gateway, ideally a separate OS user or host.
code
json · 20 lines{
"agents": {
"entries": {
"public": {
"workspace": "~/.openclaw/workspace-public",
"sandbox": { "mode": "all", "scope": "agent", "workspaceAccess": "none" },
"tools": {
"profile": "messaging",
"deny": ["group:runtime", "group:fs", "group:automation", "browser", "nodes", "sessions_spawn"],
"elevated": { "enabled": false },
"message": { "crossContext": { "allowWithinProvider": false, "allowAcrossProviders": false } }
}
}
}
},
"tools": {
"sessions": { "visibility": "tree" },
"agentToAgent": { "enabled": false }
}
}go deeper
Recall the building blocks: a separate agent, sandbox mode all, workspaceAccess none, and a deny list for shell and file tools.
Explain each setting's effect: scope agent versus session versus shared, network none, and why denying exec matters even inside a sandbox.
Close the reach that defaults leave open: session visibility, agent-to-agent messaging, cross-conversation sends and delegation through sessions_spawn.
Own the trade-off: how much usefulness the public agent loses, what upkeep the containers cost, and when the answer is a separate Gateway rather than a better config.
## The decision An assistant that answers in public rooms reads text from people you have never met. Its model can be steered, so the design question is not "how do I stop injection" (that belongs to the prompt-injection material) but **"what is the worst this agent can do on a bad day, and is that acceptable?"** OpenClaw gives you the levers; choosing the setting for each is the judgment call. ## Lever 1: a separate agent The documentation's own pattern is a **public agent** with its own workspace, sandbox and tool policy, next to a personal agent with full access. Tuning one agent for both audiences forces a compromise either way. A separate agent lets the personal one keep host access while the public one gets almost nothing; routing groups to it is done with the multi-agent bindings. ## Lever 2: the sandbox settings | Setting | Choice for a public agent | Trade-off | | --- | --- | --- | | `sandbox.mode` | `all` | `non-main` would leave its main session on the host | | `sandbox.scope` | `agent` or `session` | `session` isolates chats from each other but creates more containers | | `workspaceAccess` | `none` | `ro` exposes workspace files; `rw` lets a chat rewrite them | | `docker.network` | leave `none` | opening it gives web access and an exfiltration path | Keep `scope` away from `shared`, which puts every sandboxed session in one container and ignores per-agent binds. ## Lever 3: tool policy - Start from `tools.profile: "messaging"` for that agent. - Deny `group:runtime` (`exec`, `process`, `code_execution`) and `group:fs`. With `exec` gone, file denies cannot be bypassed through the shell. - Deny `group:automation`, so a stranger cannot create a scheduled job that outlives the conversation, plus `browser` and `nodes`. - Deny `sessions_spawn`: a delegated child can land on another agent with looser tools, and `sandbox: "require"` on spawn is opt-in (the default is `inherit`). - Set the agent's `tools.elevated.enabled` to `false`; elevated is meaningless for an agent with no `exec`, but this removes the temptation. ## Lever 4: reach the defaults leave open 1. **Session visibility** is Gateway-wide by default; `tools.sessions.visibility: "tree"` or `"self"` limits what session tools can read. 2. **Agent-to-agent messaging** is on by default; set `tools.agentToAgent.enabled: false` or keep an explicit allow list. 3. **Cross-conversation sends**: `tools.message.crossContext.allowAcrossProviders` and `allowWithinProvider` both default to `true`, so an agent with the message tool can post to other chats. Set both to `false` for this agent. ## What still remains - **It still talks.** Anything in its own sessions, memory or workspace can be quoted back; workspace access `none` limits that, but conversation history is not secret from the model. - **Model quality is a layer.** The docs recommend the strongest tier for any agent that reads untrusted content. - **One trust boundary.** OpenClaw supports one operator, or a mutually trusting team, per Gateway. Per-agent sandboxes and DM scopes reduce leakage inside that boundary; they do not make the Gateway multi-tenant. Mutually adversarial participants need separate Gateways, ideally separate OS users or hosts. - **Upkeep.** Containers need images, recreation after config changes and Docker on the host, and every denied tool is a feature users will ask for. ## Alternatives a lead should weigh - **No tools at all.** A chat-only agent with the messaging profile and nothing else needs no sandbox to be safe from shell abuse, and is the cheapest to run. It cannot do anything useful beyond conversation. - **Read-only helpers.** If the public agent must look things up, allow narrow read tools inside the sandbox with `workspaceAccess: "ro"` rather than reopening `exec`, and keep the network closed unless a specific tool needs it. - **A reader agent.** The docs describe a read-only or tool-disabled agent that summarizes untrusted content and hands the summary to a trusted one; it costs a second agent and an extra hop. - **A separate Gateway.** The strongest separation and the highest upkeep: another process, another state directory, another set of credentials. ## How to defend the choice Write the baseline down, run `openclaw sandbox explain --agent <id>` to prove the effective policy, and re-check it after upgrades: tool groups and profiles gain members over releases, so a deny list by group ages better than an allow list by name.
- Why deny sessions_spawn on the public OpenClaw agent when it is already fully sandboxed?Delegation can hand work to another agent whose own sandbox and tools are looser. A spawned child inherits by default, and `sandbox: "require"` on `sessions_spawn` is opt-in. Denying the tool, or restricting the allowed sub-agent targets, keeps the public agent's limits from being bypassed through a more trusted agent.
- When is one OpenClaw Gateway with per-agent sandboxes not enough?When the people involved are mutually adversarial. OpenClaw's trust model is one operator or one mutually trusting team per Gateway; per-agent sandboxes, tool policy and DM scopes reduce leakage within that boundary. The docs recommend separate Gateways, ideally on separate OS users or hosts, for hostile participants.
- Sandbox mode non-main is enough because the public agent has no main session.
- A deny on exec is unnecessary once the agent runs in a sandbox.
- Per-agent sandboxes make one Gateway safe for mutually untrusted users.
- A public agent cannot post into other conversations unless you allow it.
- Scope shared is the most isolated choice because everything sits in one container.