Exec Tool — User Guide
Run shell commands from your agent session. Supports foreground and background execution.Parameters
command(required)workdir(defaults to cwd)env(key/value overrides)yieldMs(default 10000): auto-background after this delaybackground(bool): background immediatelytimeout(seconds, default 1800): kill on expirypty(bool): run in a pseudo-terminal (use for TTY-only CLIs, coding agents, terminal UIs)host(sandbox | gateway | node): where to executesecurity(deny | allowlist | full): enforcement mode forgateway/nodeask(off | on-miss | always): approval prompts forgateway/nodenode(string): node id/name forhost=nodeelevated(bool): request elevated host execution when sandboxed
When exec asks for approval
When exec runs on the gateway or a node host, it goes through the approval gate. Depending on your policy:- deny — host exec is blocked entirely.
- allowlist — approved only if the command matches an allowlisted path.
- on-miss — you get a prompt when no allowlist entry matches.
- always — you get a prompt for every command.
- Allow once — run now
- Always allow — add to allowlist and run
- Deny — block this command
Giving an agent full exec permission
To skip approval prompts entirely for an agent, setsecurity: "full" and ask: "off":
Trusting specific commands
Two ways to allow commands without full trust:Safe bins (narrow stdin filters)
Add small stream-filter utilities totools.exec.safeBins. These run without allowlist entries but only accept stdin — no file arguments.
jq, cut, uniq, head, tail, tr, wc.
Do not add interpreter/runtime binaries (python3, node, bash) to safeBins — use explicit allowlist entries for those.
Allowlist (exec-approvals.json)
Add patterns to~/.openclaw/exec-approvals.json under your agent’s allowlist. Patterns are case-insensitive globs matching the resolved binary path:
Per-session overrides (/exec)
Change exec behavior for your current session without touching config:/exec with no arguments to see current session values. Session overrides reset when the session ends; they don’t persist to config.
System events
Exec lifecycle appears as system messages in your session:Exec running— emitted if the command runs longer thanapprovalRunningNoticeMs(default 10 s)Exec finished— command completedExec denied— blocked by policy or explicit denial