Skip to content

Commit 4042c8e

Browse files
Deepagents JS docs (#1310)
## Overview Add code snippets for deepagentsjs and update Python snippets and docs as well that were out of date ## Type of change **Type:** Update existing documentation ## Checklist <!-- Put an 'x' in all boxes that apply --> - [x] I have read the [contributing guidelines](README.md) - [x] I have tested my changes locally using `docs dev` - [x] All code examples have been tested and work correctly - [x] I have used **root relative** paths for internal links - [x] I have updated navigation in `src/docs.json` if needed - I have gotten approval from the relevant reviewers - (Internal team members only / optional) I have created a preview deployment using the [Create Preview Branch workflow](https://github.com/langchain-ai/docs/actions/workflows/create-preview-branch.yml) --------- Co-authored-by: Christian Bromann <git@bromann.dev>
1 parent d1c3245 commit 4042c8e

File tree

9 files changed

+1023
-178
lines changed

9 files changed

+1023
-178
lines changed

src/docs.json

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,30 @@
583583
}
584584
]
585585
},
586+
{
587+
"tab": "Deep Agents",
588+
"pages": [
589+
"oss/javascript/deepagents/overview",
590+
{
591+
"group": "Get started",
592+
"pages": [
593+
"oss/javascript/deepagents/quickstart",
594+
"oss/javascript/deepagents/customization"
595+
]
596+
},
597+
{
598+
"group": "Core capabilities",
599+
"pages": [
600+
"oss/javascript/deepagents/harness",
601+
"oss/javascript/deepagents/backends",
602+
"oss/javascript/deepagents/subagents",
603+
"oss/javascript/deepagents/human-in-the-loop",
604+
"oss/javascript/deepagents/long-term-memory",
605+
"oss/javascript/deepagents/middleware"
606+
]
607+
}
608+
]
609+
},
586610
{
587611
"tab": "Integrations",
588612
"pages": [
@@ -709,7 +733,8 @@
709733
"group": "Reference",
710734
"pages": [
711735
"oss/javascript/reference/langchain-javascript",
712-
"oss/javascript/reference/langgraph-javascript"
736+
"oss/javascript/reference/langgraph-javascript",
737+
"oss/javascript/reference/deepagents-javascript"
713738
]
714739
},
715740
{

src/oss/deepagents/backends.mdx

Lines changed: 87 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@ agent = create_deep_agent(
3737
```
3838
:::
3939

40+
:::js
41+
```typescript
42+
import { createDeepAgent, StateBackend } from "deepagents";
43+
44+
// By default we provide a StateBackend
45+
const agent = createDeepAgent();
46+
47+
// Under the hood, it looks like
48+
const agent2 = createDeepAgent({
49+
backend: (rt) => new StateBackend(rt), // Note that the tools access State through the runtime.state
50+
});
51+
```
52+
:::
53+
4054
**How it works:**
4155
- Stores files in LangGraph agent state for the current thread.
4256
- Persists across multiple agent turns on the same thread via checkpoints.
@@ -47,17 +61,28 @@ agent = create_deep_agent(
4761

4862
### FilesystemBackend (local disk)
4963

64+
:::python
5065
```python
5166
from deepagents.backends import FilesystemBackend
5267

5368
agent = create_deep_agent(
54-
backend=FilesystemBackend(root_dir="/Users/nh/Desktop/")
69+
backend=FilesystemBackend(root_dir=".", virtual_mode=True)
5570
)
5671
```
72+
:::
73+
74+
:::js
75+
```typescript
76+
import { createDeepAgent, FilesystemBackend } from "deepagents";
77+
78+
const agent = createDeepAgent({
79+
backend: new FilesystemBackend({ rootDir: ".", virtualMode: true }),
80+
});
81+
```
82+
:::
5783

5884
**How it works:**
5985
- Reads/writes real files under a configurable `root_dir`.
60-
- Note: `root_dir` must be an absolute path.
6186
- You can optionally set `virtual_mode=True` to sandbox and normalize paths under `root_dir`.
6287
- Uses secure path resolution, prevents unsafe symlink traversal when possible, can use ripgrep for fast `grep`.
6388

@@ -68,13 +93,30 @@ agent = create_deep_agent(
6893

6994
### StoreBackend (LangGraph Store)
7095

96+
:::python
7197
```python
98+
from langgraph.store.memory import InMemoryStore
7299
from deepagents.backends import StoreBackend
73100

74101
agent = create_deep_agent(
75-
backend=(lambda rt: StoreBackend(rt)) # Note that the tools access Store through the runtime.store
102+
backend=(lambda rt: StoreBackend(rt)), # Note that the tools access Store through the runtime.store
103+
store=InMemoryStore()
76104
)
77105
```
106+
:::
107+
108+
:::js
109+
```typescript
110+
import { createDeepAgent, StoreBackend } from "deepagents";
111+
import { InMemoryStore } from "@langchain/langgraph";
112+
113+
const store = new InMemoryStore()
114+
const agent = createDeepAgent({
115+
backend: (rt) => new StoreBackend(rt),
116+
store
117+
});
118+
```
119+
:::
78120

79121
**How it works:**
80122
- Stores files in a LangGraph `BaseStore` provided by the runtime, enabling cross‑thread durable storage.
@@ -89,18 +131,37 @@ agent = create_deep_agent(
89131
:::python
90132
```python
91133
from deepagents import create_deep_agent
92-
from deepagents.backends import FilesystemBackend
93-
from deepagents.backends.composite import build_composite_state_backend
134+
from deepagents.backends import CompositeBackend, StateBackend, StoreBackend
135+
from langgraph.store.memory import InMemoryStore
94136

95137
composite_backend = lambda rt: CompositeBackend(
96-
default=StateBackend(rt)
138+
default=StateBackend(rt),
97139
routes={
98140
"/memories/": StoreBackend(rt),
99-
"/docs/": CustomBackend()
100141
}
101142
)
102143

103-
agent = create_deep_agent(backend=composite_backend)
144+
agent = create_deep_agent(
145+
backend=composite_backend,
146+
store=InMemoryStore() # Store passed to create_deep_agent, not backend
147+
)
148+
```
149+
:::
150+
151+
:::js
152+
```typescript
153+
import { createDeepAgent, CompositeBackend, StateBackend, StoreBackend } from "deepagents";
154+
import { InMemoryStore } from "@langchain/langgraph";
155+
156+
const compositeBackend = (rt) => new CompositeBackend(
157+
new StateBackend(rt),
158+
{
159+
"/memories/": new StoreBackend(rt),
160+
}
161+
);
162+
163+
const store = new InMemoryStore()
164+
const agent = createDeepAgent({ backend: compositeBackend, store });
104165
```
105166
:::
106167

@@ -129,19 +190,34 @@ Route parts of the namespace to different backends. Commonly used to persist `/m
129190
:::python
130191
```python
131192
from deepagents import create_deep_agent
132-
from deepagents.backends import FilesystemBackend
133-
from deepagents.backends.composite import build_composite_state_backend
193+
from deepagents.backends import CompositeBackend, StateBackend, FilesystemBackend
134194

135195
composite_backend = lambda rt: CompositeBackend(
196+
default=StateBackend(rt),
136197
routes={
137-
"/memories/": FilesystemBackend(root_dir="/deepagents/myagent"),
198+
"/memories/": FilesystemBackend(root_dir="/deepagents/myagent", virtual_mode=True),
138199
},
139200
)
140201

141202
agent = create_deep_agent(backend=composite_backend)
142203
```
143204
:::
144205

206+
:::js
207+
```typescript
208+
import { createDeepAgent, CompositeBackend, FilesystemBackend, StateBackend } from "deepagents";
209+
210+
const compositeBackend = (rt) => new CompositeBackend(
211+
new StateBackend(rt),
212+
{
213+
"/memories/": new FilesystemBackend({ rootDir: "/deepagents/myagent", virtualMode: true }),
214+
},
215+
);
216+
217+
const agent = createDeepAgent({ backend: compositeBackend });
218+
```
219+
:::
220+
145221
Behavior:
146222
- `/workspace/plan.md` → StateBackend (ephemeral)
147223
- `/memories/agent.md` → FilesystemBackend under `/deepagents/myagent`

src/oss/deepagents/customization.mdx

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,25 @@ agent = create_deep_agent(
2424

2525
:::js
2626
```typescript
27-
// TODO: Add JS implementation
27+
import { ChatAnthropic } from "@langchain/anthropic";
28+
import { ChatOpenAI } from "@langchain/openai";
29+
import { createDeepAgent } from "deepagents";
30+
31+
// Using Anthropic
32+
const agent = createDeepAgent({
33+
model: new ChatAnthropic({
34+
model: "claude-sonnet-4-20250514",
35+
temperature: 0,
36+
}),
37+
});
38+
39+
// Using OpenAI
40+
const agent2 = createDeepAgent({
41+
model: new ChatOpenAI({
42+
model: "gpt-5",
43+
temperature: 0,
44+
}),
45+
});
2846
```
2947
:::
3048

@@ -51,7 +69,13 @@ agent = create_deep_agent(
5169

5270
:::js
5371
```typescript
54-
// TODO: Add JS implementation
72+
import { createDeepAgent } from "deepagents";
73+
74+
const researchInstructions = `You are an expert researcher. Your job is to conduct thorough research, and then write a polished report.`;
75+
76+
const agent = createDeepAgent({
77+
systemPrompt: researchInstructions,
78+
});
5579
```
5680
:::
5781

@@ -90,7 +114,49 @@ agent = create_deep_agent(
90114

91115
:::js
92116
```typescript
93-
// TODO: Add JS implementation
117+
import { tool } from "langchain";
118+
import { TavilySearch } from "@langchain/tavily";
119+
import { createDeepAgent } from "deepagents";
120+
import { z } from "zod";
121+
122+
const internetSearch = tool(
123+
async ({
124+
query,
125+
maxResults = 5,
126+
topic = "general",
127+
includeRawContent = false,
128+
}: {
129+
query: string;
130+
maxResults?: number;
131+
topic?: "general" | "news" | "finance";
132+
includeRawContent?: boolean;
133+
}) => {
134+
const tavilySearch = new TavilySearch({
135+
maxResults,
136+
tavilyApiKey: process.env.TAVILY_API_KEY,
137+
includeRawContent,
138+
topic,
139+
});
140+
return await tavilySearch._call({ query });
141+
},
142+
{
143+
name: "internet_search",
144+
description: "Run a web search",
145+
schema: z.object({
146+
query: z.string().describe("The search query"),
147+
maxResults: z.number().optional().default(5),
148+
topic: z
149+
.enum(["general", "news", "finance"])
150+
.optional()
151+
.default("general"),
152+
includeRawContent: z.boolean().optional().default(false),
153+
}),
154+
},
155+
);
156+
157+
const agent = createDeepAgent({
158+
tools: [internetSearch],
159+
});
94160
```
95161
:::
96162

0 commit comments

Comments
 (0)