In OpenClaw, why can't a per-agent `tools.allow` bring back a tool that the global `tools.deny` removes?
answer
- a filter chain, not a merge
- profile, global, agent, sandbox
- each layer only narrows
- deny always wins
- sandbox mode overrides, lists intersect
basics
~10 sOpenClaw filters tools through a chain (profile, global allow/deny, provider, per-agent, sandbox, subagent) where each layer can only narrow the set. A per-agent allow cannot re-grant a globally denied tool; deny always wins.
solid answer
~30 sTool availability is computed as a chain: the tool profile (`tools.profile` or the agent's own), the provider profile, global `tools.allow`/`tools.deny`, provider policy, the agent's `agents.entries.<id>.tools.allow`/`deny`, the agent's provider policy, the sandbox tool policy, then subagent policy. Every layer intersects with the earlier ones and can only remove tools, so a per-agent allow cannot restore what a global deny removed; deny always wins. Some per-agent settings do replace the global value instead: `agents.entries.<id>.tools.profile`, `sandbox.mode` and `scope`, and the agent's `skills` list. To give one agent a tool others lack, deny it per agent on the others instead of globally.
go deeper
Remember that per-agent tool settings live under agents.entries and that a deny anywhere earlier in the chain cannot be undone later.
Walk the filter order from profile through global, agent, sandbox and subagent policy, and say which keys replace rather than narrow.
Fix a misconfigured fleet: move a global deny onto the agents that need it, override sandbox mode per agent, and catch the empty-allowlist stop.
Choose a baseline that keeps the global layer permissive enough for the most trusted agent and pushes restrictions per agent, and justify that against central denies.
## The setup that surprises people A household server runs a `home` agent and a `coding` agent on one OpenClaw Gateway. The owner adds `exec` to the global `tools.deny` to keep the family agent safe, then adds `exec` to `agents.entries.coding.tools.allow` expecting the coding agent to get it back. It does not. The reason is how OpenClaw composes tool policy. ## Tool policy is a filter chain OpenClaw applies tool restrictions in a fixed order: 1. **Tool profile**: `tools.profile`, or `agents.entries.<id>.tools.profile` for that agent. 2. **Provider tool profile**: `tools.byProvider[provider].profile` or the agent's equivalent. 3. **Global tool policy**: `tools.allow` and `tools.deny`. 4. **Provider tool policy**: `tools.byProvider[provider].allow`/`deny`. 5. **Agent tool policy**: `agents.entries.<id>.tools.allow`/`deny`. 6. **Agent provider policy**: `agents.entries.<id>.tools.byProvider[provider].allow`/`deny`. 7. **Sandbox tool policy**: `tools.sandbox.tools` or `agents.entries.<id>.tools.sandbox.tools`. 8. **Subagent tool policy**: `tools.subagents.tools`, where it applies. The docs state the rule plainly: each level can further restrict tools but cannot grant back tools denied at an earlier level. Every restrictive layer intersects with the ones before it, and **deny always wins**. A per-agent `allow` is therefore a narrower allowlist inside what survived the global layer, not a grant. ## Which per-agent settings replace instead of narrow Not every per-agent key behaves like the allow/deny lists: | Per-agent key | Relation to the global value | |---|---| | `agents.entries.<id>.tools.allow` / `deny` | narrows the set left by earlier layers | | `agents.entries.<id>.tools.profile` | overrides `tools.profile` for that agent | | `agents.entries.<id>.tools.sandbox.tools` | replaces `tools.sandbox.tools` for that agent | | `agents.entries.<id>.sandbox.mode`, `scope`, `docker.*` | override `agents.defaults.sandbox.*` (the `docker` block is ignored when scope resolves to `shared`) | | `agents.entries.<id>.skills` | replaces `agents.defaults.skills`; entries do not merge | | `agents.entries.<id>.model` | sets that agent's model | | `agents.entries.<id>.tools.elevated` | can only further restrict the global elevated gate | ## Fixing the scenario - Remove `exec` from the global `tools.deny`. - Add `exec` to `agents.entries.home.tools.deny` (or give `home` a narrow `allow` list) so only the family agent loses it. - Optionally run `home` sandboxed with `agents.entries.home.sandbox.mode: "all"`, so the tools it does keep run sandboxed rather than directly on the host. ## Why the chain only narrows - **A global deny is a guarantee.** Because no later layer can re-grant, an operator can read `tools.deny` alone and know no agent, provider or sandbox setting undoes it. - **Per-agent lists stay small.** Each agent can state just what it gives up relative to the shared baseline. - **MCP tools follow the same rules.** Configured MCP tools use canonical names of the form `<server>__<tool>`, can be targeted with globs such as `docs__*`, and pass through the same chain; an MCP server left with no allowed tool is omitted. - **Shorthands.** Policies accept `group:*` shorthands that expand to several tools. ## Two traps on the same surface - **An allowlist that leaves nothing.** If an explicit allowlist anywhere in the chain leaves the run with no callable tools, OpenClaw stops before sending the prompt to the model. An agent allowed only a tool whose plugin is not enabled fails loudly instead of running as a text-only agent. - **Global `non-main` sandbox mode.** `agents.defaults.sandbox.mode: "non-main"` compares the session key with the main session key, not the agent id. Group and channel sessions always have their own keys, so they are sandboxed. To keep one agent off the sandbox entirely, set its own `sandbox.mode` to `"off"`. ## Verifying the effective policy - `openclaw agents list --bindings` confirms which agent a channel reaches, so you test the right one. - Send a message that needs the restricted tool and confirm the agent cannot call it. - `openclaw logs --follow`, filtered for routing, sandbox and tool lines, shows what happened during the run. The sandbox modes themselves, and how tool policy, sandboxing and elevated exec interact in depth, belong with the sandbox material; here the point is only that per-agent overrides live under `agents.entries.<id>` and that allow/deny layers narrow.
- An OpenClaw agent has `sandbox.mode: "all"` but `agents.defaults.sandbox.mode` is `"off"`. Is it sandboxed?Yes. Sandbox settings are overrides, not intersections: `agents.entries.<id>.sandbox.mode` beats `agents.defaults.sandbox.mode` for that agent. The same holds for `scope`, `workspaceAccess` and the `docker`, `browser` and `prune` blocks, though per-agent `docker` settings are ignored when the resolved scope is `shared`.
- What happens if an OpenClaw agent's `tools.allow` names only a tool that no enabled plugin registers?The run stops before the prompt reaches the model. If any explicit allowlist in the chain leaves no callable tools, OpenClaw refuses to continue as a text-only agent, so a missing plugin shows up as a failure rather than a silently weaker agent. Enable the plugin or fix the allowlist.
- A per-agent tools.allow overrides a global tools.deny for that agent.
- Per-agent tool lists merge with the global lists into one union.
- A per-agent skills list adds to agents.defaults.skills.
- Global sandbox mode non-main exempts a whole named agent from the sandbox.
- An empty allowlist just leaves the agent running without tools.
Assumes OpenClaw 2026.9.9, where per-agent overrides live under the keyed agents.entries.<id>; older configs held the same fields in an agents.list array.