Permissions
Every tool call an agent makes passes a permission gate before it runs. policy() matches calls against allow / ask / deny rule sets — by tool name glob, or by the call's actual input — so you decide which actions run silently, which need a human, and which never happen. Precedence is always deny > ask > allow: a mis-ordered allow can never shadow a deny. This is how you keep an autonomous agent inside the lines you drew, with an audit trail to prove it.
Enable it
Pass a policy (and optionally an approval handler) to createLiteAgent:
Name matching uses globs (Task* matches TaskCreate, TaskUpdate, …). A call that matches no rule falls through to default ("allow" unless you set it). Without a policy, everything is allowed.
Content-level rules
Beyond tool names, policy({ rules }) matches on call input via a when spec — conditions over dot-paths into the input like command or path. The SDK ships ready-made specifiers for its own tools:
A rule is a PermissionRule:
Bash command matching is best-effort — shell quoting and chaining can bypass prefix rules. The permission gate is defense-in-depth; the sandbox is the real containment.
Auditing and dry-run
permissionAudit: trueappends a redactedpermission_decisionevent to the session log for every decision, including who made it (policy/user/auto). Secrets in tool input are masked bydefaultRedactor(override withredact).permissionMode: "dry-run"computes and records verdicts without blocking anything — point a candidate policy at real traffic to see what it would deny before enforcing it.
Composing policies
composePolicies(...)merges policies deny-wins — a managed layer (e.g. your org's baseline) downstream users cannot loosen.strictPolicy({ allow })gives a deny-by-default posture: only what you list is permitted.
Subagents run without the parent's permission gate and onApproval handler by default — an interactive approval handler cannot service parallel children. The sandbox still wraps every command. Pass subagentPermission (allow/deny rules, not ask) to gate subagent runs. See Subagents.
Options
Related exports: policy, strictPolicy, composePolicies, bashCommand, filePath, permissionFilePolicy, defaultRedactor.
See also
- Sandbox — OS-level containment that composes with the gate.
- Observability — reading
permission_decisionevents out of the event stream. - Subagents — how
subagentPermissiongates child agents. - Core strategies — the
PermissionPolicystrategy interface.