Exec Tool — Developer Reference
Type definitions, policy precedence, and implementation details for the exec tool and its approval system.Source files
ExecToolConfig
approvalRunningNoticeMs is only accepted on agent-level exec config (AgentToolExecSchema), not the global ToolExecSchema.
AgentToolsConfig
FsToolsConfig
ExecApprovalsFile schema
ApprovalsConfig (approval forwarding)
Global vs agent-level precedence
Effective exec policy is the stricter of config (tools.exec.* / agents.list[].tools.exec.*) and exec-approvals.json. Omitted approvals fields fall back to the config value.
Global (tools.exec) sets the floor. Agent-level (agents.list[].tools.exec) overrides. exec-approvals.json overrides per-agent at runtime (hot-reloaded, not requiring gateway restart).
Config schema uses two separate shapes:
ToolExecSchema— global, noapprovalRunningNoticeMsAgentToolExecSchema— extends base withapprovalRunningNoticeMs
Tool policy filtering order
Tool availability is determined in this order (each level can only further restrict):- Tool profile (
tools.profileoragents.list[].tools.profile) - Provider tool profile (
tools.byProvider[provider].profile) - Global tool policy (
tools.allow/tools.deny) - Provider tool policy (
tools.byProvider[provider].allow/deny) - Agent-specific tool policy (
agents.list[].tools.allow/deny) - Agent provider policy (
agents.list[].tools.byProvider[provider].allow/deny) - Sandbox tool policy (
tools.sandbox.toolsoragents.list[].tools.sandbox.tools) - Subagent tool policy (
tools.subagents.tools)
deny always wins. A non-empty allow makes everything not listed implicitly blocked. Tool policy is the hard stop — /exec cannot override a denied exec tool.
If agents.list[].tools.sandbox.tools is set, it replaces tools.sandbox.tools for that agent.
Tool groups
Tool policies supportgroup:* shorthands:
Safe bin implementation
SafeBinProfileFixture defines the argv policy for a safe bin:
$VAR expansion). Long options are fail-closed: unknown flags and ambiguous abbreviations are rejected.
Default denied flags per bin:
grep:--dereference-recursive,--directories,--exclude-from,--file,--recursive,-R,-d,-f,-rjq:--argfile,--from-file,--library-path,--rawfile,--slurpfile,-L,-fsort:--compress-program,--files0-from,--output,--random-source,--temporary-directory,-T,-owc:--files0-from
&&, ||, ;) is allowed only when every top-level segment satisfies the allowlist (including safe bins). Redirections are unsupported in allowlist mode. Command substitution ($() / backticks) is rejected during allowlist parsing.
Safe bins must resolve from trusted directories (defaults: /bin, /usr/bin). PATH entries are never auto-trusted. Add package-manager paths via tools.exec.safeBinTrustedDirs.
safeBinProfiles — per-agent profile keys override global keys.
apply_patch subtool
apply_patch is a subtool of exec for structured multi-file edits (OpenAI models only):
allow: ["exec"] implicitly allows apply_patch. workspaceOnly defaults to true (workspace-contained). Config lives under tools.exec.applyPatch.
Shell environment notes
OPENCLAW_SHELL=execis set in the spawned command environment (including PTY and sandbox) so shell/profile rules can detect exec-tool context.- On non-Windows: uses
SHELL; ifSHELLisfish, prefersbash/shfromPATH, then falls back tofish. - On Windows: prefers PowerShell 7 (
pwsh), falls back to PowerShell 5.1. - Host execution (
gateway/node) rejectsenv.PATHand loader overrides (LD_*/DYLD_*). - Script preflight checks inspect only files inside the effective
workdirboundary; paths resolving outsideworkdirskip preflight.
elevatedDefault
/elevated directive is present for a session. "full" skips exec approvals entirely.
Related: Exec Tool (user) · Exec Tool (admin) · Sandboxing (developer)