In OpenClaw, how do tools.allow and tools.deny decide which tools an agent can call, and what do they not control?
answer
- filters by tool name
- which list wins a conflict
- group: shorthands
- applies with or without sandbox
- exec can still write files
basics
~20 sOpenClaw tool policy filters tools by name: deny always wins, and a non-empty allow blocks everything not listed. It applies with or without the sandbox and is the hard stop, but it does not inspect what an allowed exec command does.
solid answer
~40 sTool policy is a name filter over the tools a run may call. `tools.profile` sets a base set (`minimal`, `coding`, `messaging`, `full`), then `tools.allow` / `tools.deny` apply globally, with the same keys per agent under `agents.entries.<id>.tools` and per provider under `tools.byProvider`. **`deny` always wins**, a **non-empty `allow` blocks everything else**, entries are case-insensitive with `*` wildcards, and `group:` shorthands such as `group:runtime` (`exec`, `process`, `code_execution`) and `group:fs` (`read`, `write`, `edit`, `apply_patch`) expand to several tools. It applies even with the sandbox off, and neither `/exec` nor elevated mode can bring back a denied `exec`. What it does **not** do is inspect side effects: if `exec` is allowed, denying `write`, `edit` and `apply_patch` does not make the agent read-only.
code
json · 6 lines{
"tools": {
"profile": "messaging",
"deny": ["group:runtime", "group:fs", "gateway", "cron", "sessions_spawn"]
}
}go deeper
Recall the two rules that settle most cases: deny always wins, and a non-empty allow blocks everything not listed.
Walk through the layers: profile, provider profile, global and per-agent allow/deny, provider allow/deny, and the sandbox's own gate, with group shorthands.
Show that names are not side effects: an allowed exec can still write, so read-only means denying group:runtime or using a read-only sandbox mount.
Choose profile-plus-deny versus strict allow lists per agent, weighing safety against agents that silently lose tools after an upgrade.
## What tool policy is An OpenClaw agent acts through **tools**: `exec` for shell commands, `read`/`write`/`edit`/`apply_patch` for files, `browser`, `message`, `cron`, `sessions_spawn` and many more. **Tool policy** decides which of those tool names exist for a run at all. A tool the policy removes is never offered to the model, so no prompt, workspace file or chat command can make the model call it. That makes tool policy the **hard stop** in OpenClaw's layered controls. The sandbox decides where an allowed tool runs; exec approvals decide whether a particular host command may run; tool policy decides whether the tool is there to call. ## The layers, in order 1. **Profile**: `tools.profile` (or `agents.entries.<id>.tools.profile`) gives a base allowlist. `minimal`, `coding`, `messaging` and `full` exist; local onboarding sets `full` when no profile is configured. 2. **Provider profile**: `tools.byProvider[<provider>].profile` can narrow it for one model provider or `provider/model`. 3. **Global and per-agent allow/deny**: `tools.allow` / `tools.deny`, and `agents.entries.<id>.tools.allow` / `.deny`. 4. **Provider allow/deny**: `tools.byProvider[<provider>].allow` / `.deny`. 5. **Sandbox tool policy**, only for sandboxed sessions: `tools.sandbox.tools.allow` / `.deny`, a second gate with its own defaults. ## The rules of thumb - **Deny always wins.** A tool in any applicable deny list is gone, even if an allow list names it. - **A non-empty allow is exclusive.** Everything not listed is treated as blocked. - Entries are **case-insensitive** and support `*` wildcards. - `allow` and `alsoAllow` cannot both be set in one scope; config validation rejects it. - **Groups** expand to several tools: | Group | Tools | | --- | --- | | `group:runtime` | `exec`, `process`, `code_execution` (`bash` is an alias for `exec`) | | `group:fs` | `read`, `write`, `edit`, `apply_patch` | | `group:web` | `web_search`, `x_search`, `web_fetch` | | `group:memory` | `memory_search`, `memory_get` | - `write` and `apply_patch` are **separate ids**: denying `write` does not deny `apply_patch`, so deny `group:fs` or list each mutating tool. - Tool policy applies **even when the sandbox is off**; it does not depend on Docker. ## What it does not control - **The inside of `exec`.** Policy filters by name and does not look at what a shell command does. If `exec` is allowed, the agent can create, edit or delete files wherever the host or sandbox filesystem allows, whatever you denied in `group:fs`. For a read-only agent, deny `group:runtime` too, or rely on `workspaceAccess: "ro"` in a sandbox. The security audit has a dedicated warning for "file tools disabled but exec enabled". - **Where a tool runs.** That is the sandbox. - **Which host commands need a human.** That is exec approvals. - **Who sent the message.** For per-requester limits there is `tools.toolsBySender`, and the docs call it defense in depth, not authentication of everything in the prompt. ## Chat commands cannot override it - `/exec` changes per-session exec defaults (host, security, ask) for authorized senders; it does **not** grant tool access. - `/elevated` moves an allowed `exec` out of the sandbox; it does **not** override a deny. - Skills, `AGENTS.md` and other workspace files shape what the model tries; they enforce nothing. ## Seeing why a tool vanished The Gateway logs an `agents/tool-policy` entry whenever a policy step removes tools or the sandbox policy blocks a call. `openclaw logs` shows the rule label, the config key and the affected tool names, and `openclaw sandbox explain` shows the sandbox layer's effective allow and deny lists. ## Choosing allow lists or deny lists - A **deny list on top of a profile** (for example `messaging` plus denies) is easy to read and keeps working when you add trusted tools later, but anything a later release adds to that profile is available until you deny it. - A **strict allow list** fails closed: a tool you did not name is blocked, including new ones. The cost is breakage, because the agent silently loses tools that a release moved or renamed. - **Group entries age better than names.** Denying `group:runtime` keeps covering the runtime tools even when the group's membership grows, which a list of individual names would not. - Either way, keep **per-agent** policy for anything that reads untrusted content, so your personal agent and a public-facing one do not share one compromise.
- If I deny write, edit and apply_patch in OpenClaw, is the agent read-only?Not while `exec` is allowed. Tool policy filters names, not side effects, so a shell command can still write files. Deny `group:runtime` as well, or run the agent sandboxed with `workspaceAccess: "ro"`, which mounts the workspace read-only and disables the file-mutating tools.
- How do I find out which OpenClaw rule removed a tool from a run?Check `openclaw logs` for the `agents/tool-policy` entry: it records the rule label, the config key and the tool names it removed, and for sandboxed sessions the sandbox mode and whether allow or deny blocked the call. `openclaw sandbox explain` shows the sandbox layer's effective lists.
- An allow entry for a tool overrides a matching deny entry.
- tools.allow just adds tools; everything else stays available.
- Denying write also denies apply_patch.
- Denying the file tools makes exec read-only.
- Tool policy only takes effect when the sandbox is on.
- An authorized sender can re-enable a denied exec with /exec or /elevated.