Skip to content

Commit 583a567

Browse files
open-swe[bot]open-swenick-hollon-lc
authored
fix: update deepagents docs to reference permissions across pages (#3539)
## Description Updates deepagents docs pages to properly reference the new permissions system. **Permissions page improvements:** - Reordered examples: "Isolate to a workspace directory" first, "Deny all access" last - Renamed "Sandbox" to "Isolate" to avoid overloaded terminology - Added "Read-only memory" example protecting both `/memories/` and `/policies/` - Fixed "Protect specific files" example to include trailing deny-all rule **Cross-page references added:** - `going-to-production.mdx`: New "Filesystem permissions" subsection under Guardrails - `memory.mdx`: References permissions alongside policy hooks for read-only enforcement - `backends.mdx`: Tip before "Add policy hooks" pointing to permissions as a simpler alternative - `harness.mdx`: New "Filesystem permissions" section in the capabilities overview - `subagents.mdx`: Added `permissions` field to SubAgent spec tables (Python and JS) - `overview.mdx`: Added permissions to "When to use" list, Core capabilities cards, and Get started card groups ## Test Plan - [ ] Verify permissions page examples are reordered sensibly (isolate first, deny-all last) - [ ] Verify "Protect specific files" example has trailing deny-all - [ ] Verify "Read-only memory" example denies writes to both `/memories/` and `/policies/` - [ ] Verify going-to-production guardrails section mentions permissions - [ ] Verify memory read-only section references permissions - [ ] Verify backends page has tip before policy hooks section - [ ] Verify harness page has new filesystem permissions section - [ ] Verify subagents page lists `permissions` field in both Python and JS tables - [ ] Verify overview page has permissions in capabilities and card groups _Opened collaboratively by Nick Hollon and open-swe._ --------- Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> Co-authored-by: Nick Hollon <274035459+nick-hollon-lc@users.noreply.github.com> Co-authored-by: Nick Hollon <nick.hollon@langchain.dev>
1 parent 8a0458a commit 583a567

7 files changed

Lines changed: 118 additions & 14 deletions

File tree

src/oss/deepagents/backends.mdx

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ This page explains how to:
2727
- [choose a backend](#specify-a-backend),
2828
- [route different paths to different backends](#route-to-different-backends),
2929
- [implement your own virtual filesystem](#use-a-virtual-filesystem) (e.g., S3 or Postgres),
30+
- [set permissions](#permissions) on filesystem access,
3031
:::js
3132
- [add policy hooks](#add-policy-hooks),
3233
[work with binary and multimodal files](#multimodal-and-binary-files),
@@ -544,9 +545,42 @@ Postgres-style outline:
544545
- `grep` can fetch candidate rows by extension or last modified time, then scan lines (skip rows where `mime_type` is binary) → return `GrepResult`
545546
:::
546547

548+
## Permissions
549+
550+
Use [permissions](/oss/deepagents/permissions) to declaratively control which files and directories the agent can read or write. Permissions apply to the built-in filesystem tools and are evaluated before the backend is called.
551+
552+
:::python
553+
```python
554+
from deepagents import create_deep_agent, FilesystemPermission
555+
556+
agent = create_deep_agent(
557+
backend=CompositeBackend(
558+
default=StateBackend(),
559+
routes={
560+
"/memories/": StoreBackend(
561+
namespace=lambda rt: (rt.server_info.user.identity,),
562+
),
563+
"/policies/": StoreBackend(
564+
namespace=lambda rt: (rt.context.org_id,),
565+
),
566+
},
567+
),
568+
permissions=[
569+
FilesystemPermission(
570+
operations=["write"],
571+
paths=["/policies/**"],
572+
mode="deny",
573+
),
574+
],
575+
)
576+
```
577+
:::
578+
579+
For the full set of options including rule ordering, subagent permissions, and composite backend interactions, see the [permissions guide](/oss/deepagents/permissions).
580+
547581
## Add policy hooks
548582

549-
Enforce enterprise rules by subclassing or wrapping a backend.
583+
For custom validation logic beyond path-based allow/deny rules (rate limiting, audit logging, content inspection), enforce enterprise rules by subclassing or wrapping a backend.
550584

551585
Block writes/edits under selected prefixes (subclass):
552586

src/oss/deepagents/going-to-production.mdx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Memory is always persistent across conversations. The main question is how it's
184184
| **Global** | `(org_id)` | Read-only policies for all users and assistants | "Never disclose internal pricing" |
185185

186186
<Warning>
187-
Shared memory (assistant, user, or organization scope) is a vector for prompt injection. If one user can write to memory that another user's conversation reads, a malicious user could inject instructions into that shared state. Enforce read-only access where appropriate. For example, make organization-wide policies writable only through application code, not by the agent itself.
187+
Shared memory (assistant, user, or organization scope) is a vector for prompt injection. If one user can write to memory that another user's conversation reads, a malicious user could inject instructions into that shared state. Enforce read-only access where appropriate. For example, make organization-wide policies writable only through application code, not by the agent itself. Use [permissions](/oss/deepagents/permissions) to declaratively deny writes to shared paths, or [backend policy hooks](/oss/deepagents/backends#add-policy-hooks) for custom validation logic.
188188
</Warning>
189189

190190
### Configuration
@@ -878,7 +878,10 @@ Avoid passing secrets into sandboxes via environment variables or file uploads.
878878

879879
## Guardrails
880880

881-
Agents in production run autonomously, which means they can loop indefinitely, hit rate limits, or process user data that contains sensitive information. Deep Agents support [middleware](/oss/langchain/middleware/built-in) that wraps model and tool calls to handle these concerns.
881+
Agents in production run autonomously, which means they can loop indefinitely, hit rate limits, or process user data that contains sensitive information. Deep Agents provide two layers of protection:
882+
883+
- **[Permissions](/oss/deepagents/permissions)**: declarative allow/deny rules that control which files and directories the agent can read or write. Use permissions to isolate the agent to a working directory, protect sensitive files, or enforce read-only memory.
884+
- **[Middleware](/oss/langchain/middleware/built-in)**: hooks that wrap model and tool calls for rate limiting, error handling, and data privacy.
882885

883886
### Rate limiting
884887

src/oss/deepagents/harness.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ An agent harness is a combination of several different capabilities that make bu
77

88
- [Planning capabilities](#planning-capabilities)
99
- [Virtual filesystem](#virtual-filesystem-access)
10+
- [Filesystem permissions](#filesystem-permissions)
1011
- [Task delegation (subagents)](#task-delegation-subagents)
1112
- [Context and token management](#context-management)
1213
- [Code execution](#code-execution)
@@ -55,6 +56,24 @@ You can also use the file system when building custom tools and middleware for D
5556

5657
For more information, see [backends](/oss/deepagents/backends).
5758

59+
## Filesystem permissions
60+
61+
The harness supports declarative permission rules that control which files and directories the agent can read or write. Permissions apply to the built-in filesystem tools listed above and are evaluated in declaration order with first-match-wins semantics.
62+
63+
**How it works:**
64+
- Pass a list of rules to `permissions=` when creating the agent
65+
- Each rule specifies `operations` (`"read"`, `"write"`), `paths` (glob patterns), and `mode` (`"allow"` or `"deny"`)
66+
- The first matching rule wins. If no rule matches, the operation is allowed.
67+
68+
**Why it's useful:**
69+
- Restrict agents to specific directories (e.g., `/workspace/`)
70+
- Protect sensitive files (e.g., `.env`, credentials)
71+
- Give subagents narrower access than the parent agent
72+
73+
Permissions do not apply to [sandbox backends](/oss/deepagents/sandboxes), which support arbitrary command execution via the `execute` tool. For custom validation logic, use [backend policy hooks](/oss/deepagents/backends#add-policy-hooks).
74+
75+
For the full rule structure, examples, and subagent inheritance, see [Permissions](/oss/deepagents/permissions).
76+
5877
## Task delegation (subagents)
5978

6079
The harness allows the main agent to create ephemeral "subagents" for isolated multi-step tasks.

src/oss/deepagents/memory.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ await client.store.putItem(
629629
```
630630
:::
631631

632-
Use [policy hooks](/oss/deepagents/backends#add-policy-hooks) to enforce that org-level memory is read-only.
632+
Use [permissions](/oss/deepagents/permissions) to enforce that org-level memory is read-only, or [policy hooks](/oss/deepagents/backends#add-policy-hooks) for custom validation logic.
633633

634634
### Background consolidation
635635

@@ -827,15 +827,15 @@ By default, the agent can both read and write memory files. For shared state lik
827827
| Permission | Use case | How it works |
828828
|---|---|---|
829829
| **Read-write** (default) | User preferences, agent self-improvement, learned [skills](/oss/deepagents/skills) | Agent updates files via `edit_file` tool |
830-
| **Read-only** | Organization policies, compliance rules, shared knowledge bases, developer-defined [skills](/oss/deepagents/skills) | Populate via application code or the [Store API](/langsmith/custom-store). Use [policy hooks](/oss/deepagents/backends#add-policy-hooks) to block agent writes. |
830+
| **Read-only** | Organization policies, compliance rules, shared knowledge bases, developer-defined [skills](/oss/deepagents/skills) | Populate via application code or the [Store API](/langsmith/custom-store). Use [permissions](/oss/deepagents/permissions) to deny writes to specific paths, or [policy hooks](/oss/deepagents/backends#add-policy-hooks) for custom validation logic. |
831831

832832
**Security considerations:** If one user can write to memory that another user reads, a malicious user could inject instructions into shared state. To mitigate this:
833833

834834
- **Default to user scope** `(user_id)` unless you have a specific reason to share
835835
- Use **read-only memory** for shared policies (populate via application code, not the agent)
836836
- Add **human-in-the-loop** validation before the agent writes to shared memory. Use an [interrupt](/oss/langgraph/interrupts) to require human approval for writes to sensitive paths.
837837

838-
To enforce read-only memory, use [policy hooks](/oss/deepagents/backends#add-policy-hooks) on the backend to reject write operations to specific paths.
838+
To enforce read-only memory, use [permissions](/oss/deepagents/permissions) to declaratively deny writes to specific paths. For custom validation logic (rate limiting, audit logging, content inspection), use [backend policy hooks](/oss/deepagents/backends#add-policy-hooks).
839839

840840
### Concurrent writes
841841

src/oss/deepagents/overview.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ Use the **Deep Agents SDK** when you want to build agents that can:
9595
- **Execute shell commands** via the `execute` tool when using a [sandbox backend](/oss/deepagents/sandboxes)
9696
- **Delegate work** to specialized subagents for context isolation
9797
- **Persist memory** across conversations and threads
98+
- **Control filesystem access** with declarative [permission rules](/oss/deepagents/permissions) that restrict which files agents can read or write
9899
- **Require human approval** for sensitive operations with [human-in-the-loop](/oss/deepagents/human-in-the-loop) workflows
99100
- **Use any model** that supports tool calling — [provider agnostic](/oss/deepagents/models) across frontier and open models
100101

@@ -126,6 +127,9 @@ For building simpler agents, consider using LangChain's [`createAgent`](/oss/lan
126127
<Card title="Long-term memory" icon="database">
127128
Extend agents with persistent memory across threads using LangGraph's [Memory Store](/oss/langgraph/persistence#memory-store). Agents can save and retrieve information from previous conversations.
128129
</Card>
130+
<Card title="Filesystem permissions" icon="lock">
131+
Declare [permission rules](/oss/deepagents/permissions) that control which files and directories agents can read or write. Subagents can inherit or override the parent's rules.
132+
</Card>
129133
<Card title="Human-in-the-loop" icon="user-check">
130134
Configure [human approval](/oss/deepagents/human-in-the-loop) for sensitive tool operations using LangGraph's interrupt capabilities. Control which tools require confirmation before execution.
131135
</Card>
@@ -155,6 +159,9 @@ For building simpler agents, consider using LangChain's [`createAgent`](/oss/lan
155159
<Card title="Sandboxes" icon="cube" href="/oss/deepagents/sandboxes">
156160
Execute code in isolated environments
157161
</Card>
162+
<Card title="Permissions" icon="lock" href="/oss/deepagents/permissions">
163+
Control filesystem access with permission rules
164+
</Card>
158165
<Card title="Human-in-the-loop" icon="user-check" href="/oss/deepagents/human-in-the-loop">
159166
Configure approval for sensitive operations
160167
</Card>
@@ -184,6 +191,9 @@ For building simpler agents, consider using LangChain's [`createAgent`](/oss/lan
184191
<Card title="Backends" icon="plug" href="/oss/deepagents/backends">
185192
Choose and configure pluggable filesystem backends
186193
</Card>
194+
<Card title="Permissions" icon="lock" href="/oss/deepagents/permissions">
195+
Control filesystem access with permission rules
196+
</Card>
187197
<Card title="Human-in-the-loop" icon="user-check" href="/oss/deepagents/human-in-the-loop">
188198
Configure approval for sensitive operations
189199
</Card>

src/oss/deepagents/permissions.mdx

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,20 @@ Rules use first-match-wins evaluation: the first rule whose `operations` and `pa
5656

5757
:::python
5858

59-
### Deny all access
59+
### Isolate to a workspace directory
60+
61+
Allow reads and writes only under `/workspace/` and deny everything else:
6062

6163
```python
6264
agent = create_deep_agent(
6365
model=model,
6466
backend=backend,
6567
permissions=[
68+
FilesystemPermission(
69+
operations=["read", "write"],
70+
paths=["/workspace/**"],
71+
mode="allow",
72+
),
6673
FilesystemPermission(
6774
operations=["read", "write"],
6875
paths=["/**"],
@@ -72,13 +79,18 @@ agent = create_deep_agent(
7279
)
7380
```
7481

75-
### Sandbox to a workspace directory
82+
### Protect specific files
7683

7784
```python
7885
agent = create_deep_agent(
7986
model=model,
8087
backend=backend,
8188
permissions=[
89+
FilesystemPermission(
90+
operations=["read", "write"],
91+
paths=["/workspace/.env", "/workspace/examples/**"],
92+
mode="deny",
93+
),
8294
FilesystemPermission(
8395
operations=["read", "write"],
8496
paths=["/workspace/**"],
@@ -93,22 +105,47 @@ agent = create_deep_agent(
93105
)
94106
```
95107

96-
### Protect specific files
108+
### Read-only memory
109+
110+
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](/oss/deepagents/memory#read-only-vs-writable-memory) for more context.
97111

98112
```python
99113
agent = create_deep_agent(
100114
model=model,
101-
backend=backend,
115+
backend=CompositeBackend(
116+
default=StateBackend(),
117+
routes={
118+
"/memories/": StoreBackend(
119+
namespace=lambda rt: (rt.server_info.user.identity,),
120+
),
121+
"/policies/": StoreBackend(
122+
namespace=lambda rt: (rt.context.org_id,),
123+
),
124+
},
125+
),
102126
permissions=[
103127
FilesystemPermission(
104-
operations=["read", "write"],
105-
paths=["/workspace/.env", "/workspace/examples/**"],
128+
operations=["write"],
129+
paths=["/memories/**", "/policies/**"],
106130
mode="deny",
107131
),
132+
],
133+
)
134+
```
135+
136+
### Deny all access
137+
138+
Block all reads and writes. This is a restrictive baseline you can layer more specific allow rules on top of:
139+
140+
```python
141+
agent = create_deep_agent(
142+
model=model,
143+
backend=backend,
144+
permissions=[
108145
FilesystemPermission(
109146
operations=["read", "write"],
110-
paths=["/workspace/**"],
111-
mode="allow",
147+
paths=["/**"],
148+
mode="deny",
112149
),
113150
],
114151
)

src/oss/deepagents/subagents.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ For most use cases, define subagents as dictionaries matching the @[`SubAgent`]
6060
| `middleware` | `list[Middleware]` | Optional. Additional middleware for custom behavior, logging, or rate limiting.<br></br>Does not inherit from main agent. |
6161
| `interrupt_on` | `dict[str, bool]` | Optional. Configure [human-in-the-loop](/oss/deepagents/human-in-the-loop) for specific tools. Subagent value overrides main agent. Requires checkpointer.<br></br>Inherits from main agent by default. Subagent value overrides the default. |
6262
| `skills` | `list[str]` | Optional. [Skills](/oss/deepagents/skills) source paths. When specified, the subagent will load skills from these directories (e.g., `["/skills/research/", "/skills/web-search/"]`). This allows subagents to have different skill sets than the main agent.<br></br>Does not inherit from main agent. Only the general-purpose subagent inherits the main agent's skills. When a subagent has skills, it runs its own independent @[`SkillsMiddleware`] instance. Skill state is fully isolated—a subagent's loaded skills are not visible to the parent, and vice versa. |
63+
| `permissions` | `list[FilesystemPermission]` | Optional. [Filesystem permission rules](/oss/deepagents/permissions) for the subagent. When set, **replaces** the parent agent's permissions entirely.<br></br>Inherits from main agent by default. |
6364

6465
:::
6566

0 commit comments

Comments
 (0)