permissions= and the agent’s built-in filesystem tools respect them.
Permissions only apply to the built-in filesystem tools (ls, read_file, glob, grep, write_file, edit_file). Custom tools and MCP tools that access the filesystem are not covered. Permissions also do not apply to sandbox backends, which support arbitrary command execution via the execute tool.
Basic usage
Pass a list ofFilesystemPermission rules to create_deep_agent. Rules are evaluated in declaration order. The first matching rule wins. If no rule matches, the operation is allowed.
Rule structure
EachFilesystemPermission has three fields:
| Field | Type | Description |
|---|---|---|
operations | list["read" | "write"] | Operations this rule applies to. "read" covers ls, read_file, glob, grep. "write" covers write_file, edit_file. |
paths | list[str] | Glob patterns for matching file paths (e.g., ["/workspace/**"]). Supports ** for recursive matching and {a,b} for alternation. |
mode | "allow" | "deny" | Whether to allow or deny matching operations. Defaults to "allow". |
operations and paths match the current call determines the outcome. If no rule matches, the call is allowed (permissive default).
Examples
Isolate to a workspace directory
Allow reads and writes only under/workspace/ and deny everything else:
Protect specific files
Read-only memory
Allow the agent to read memory files but prevent it from modifying them. This is useful for organization-wide policies or shared knowledge bases that should only be updated by application code. See read-only vs writable memory for more context.Deny all access
Block all reads and writes. This is a restrictive baseline you can layer more specific allow rules on top of:Rule ordering
Because of first-match-wins, rule order matters. Place more specific rules before broader ones:Subagent permissions
Subagents inherit the parent agent’s permissions by default. To give a subagent different permissions, set thepermissions field in its spec. This replaces the parent’s rules entirely.
Composite backends
When using aCompositeBackend with a sandbox default, every permission path must be scoped under a known route prefix. Sandboxes support arbitrary command execution, so path-based restrictions alone cannot prevent filesystem access through shell commands. Scoping permissions to route-specific backends avoids this conflict.
NotImplementedError:
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

