一键导入
deepagents-filesystem
Using FilesystemMiddleware with virtual filesystems, backends (State, Store, Filesystem, Composite), and context management for Deep Agents.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Using FilesystemMiddleware with virtual filesystems, backends (State, Store, Filesystem, Composite), and context management for Deep Agents.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Using the Deep Agents CLI - terminal interface, persistent memory with AGENTS.md, project conventions, skills directories, and CLI commands.
Understanding Deep Agents framework - what they are, how to create them with createDeepAgent, and the agent harness architecture with built-in middleware for planning, filesystems, and subagents.
Creating and using custom skills with progressive disclosure, SKILL.md format, and the Agent Skills protocol in Deep Agents.
Using the Deep Agents CLI - terminal interface, persistent memory with AGENTS.md, project conventions, skills directories, and CLI commands.
Using FilesystemMiddleware with virtual filesystems, backends (State, Store, Filesystem, Composite), and context management for Deep Agents.
Implementing human-in-the-loop approval workflows with interruptOn parameter for sensitive tool operations in Deep Agents.
| name | deepagents-filesystem |
| description | Using FilesystemMiddleware with virtual filesystems, backends (State, Store, Filesystem, Composite), and context management for Deep Agents. |
| language | js |
FilesystemMiddleware solves context engineering challenges by providing file operations through a pluggable backend system. Tools include: ls, read_file, write_file, edit_file, glob, grep.
Ephemeral storage in agent state - persists within a thread only.
import { createDeepAgent } from "deepagents";
const agent = await createDeepAgent({});
// Default StateBackend - files exist only within thread
import { createDeepAgent, FilesystemBackend } from "deepagents";
const agent = await createDeepAgent({
backend: new FilesystemBackend({
rootDir: ".",
virtualMode: true // Security: restrict paths
})
});
import { createDeepAgent, StoreBackend } from "deepagents";
import { InMemoryStore } from "@langchain/langgraph";
const store = new InMemoryStore();
const agent = await createDeepAgent({
backend: (config) => new StoreBackend(config),
store
});
import { createDeepAgent, CompositeBackend, StateBackend, StoreBackend } from "deepagents";
import { InMemoryStore } from "@langchain/langgraph";
const store = new InMemoryStore();
const agent = await createDeepAgent({
backend: (config) => new CompositeBackend(
new StateBackend(config),
{ "/memories/": new StoreBackend(config) }
),
store
});
| Use Case | Backend | Why |
|---|---|---|
| Temporary files | StateBackend | Default, no setup |
| Local development | FilesystemBackend | Direct disk access |
| Cross-session memory | StoreBackend | Persists across threads |
| Hybrid storage | CompositeBackend | Mix ephemeral + persistent |
const agent = await createDeepAgent({});
const result = await agent.invoke({
messages: [{
role: "user",
content: "Search for TypeScript best practices and save results for analysis"
}]
});
// Agent: search -> write_file -> compact context -> read_file when needed
import { createDeepAgent, CompositeBackend, StateBackend, StoreBackend } from "deepagents";
import { InMemoryStore } from "@langchain/langgraph";
const store = new InMemoryStore();
const agent = await createDeepAgent({
backend: (config) => new CompositeBackend(
new StateBackend(config),
{ "/memories/": new StoreBackend(config) }
),
store
});
// Thread 1: Save preferences
await agent.invoke({
messages: [{ role: "user", content: "Save my preference: concise explanations to /memories/prefs.txt" }]
}, { configurable: { thread_id: "thread-1" } });
// Thread 2: Access preferences
await agent.invoke({
messages: [{ role: "user", content: "Read my preferences and explain async/await" }]
}, { configurable: { thread_id: "thread-2" } });
import { createAgent, createFilesystemMiddleware } from "langchain";
const agent = createAgent({
model: "claude-sonnet-4-5-20250929",
middleware: [
createFilesystemMiddleware({
systemPrompt: "Save intermediate results to /workspace/",
customToolDescriptions: {
read_file: "Read files you've previously written. Use offset/limit for large files.",
write_file: "Save data to avoid context overflow.",
}
}),
],
});
✅ Backend type and configuration
✅ Custom tool descriptions
✅ File paths and organization
✅ Human-in-the-loop for file operations
❌ Tool names
❌ Disable filesystem tools
❌ Access outside virtual_mode restrictions
// ❌ Files lost when thread changes
await agent.invoke({messages: [{role: "user", content: "Write /notes.txt"}]},
{configurable: {thread_id: "thread-1"}});
await agent.invoke({messages: [{role: "user", content: "Read /notes.txt"}]},
{configurable: {thread_id: "thread-2"}});
// File not found!
// ✅ Use same thread_id OR StoreBackend
// ❌ Insecure
new FilesystemBackend({ rootDir: "/project", virtualMode: false })
// ✅ Secure
new FilesystemBackend({ rootDir: "/project", virtualMode: true })
// ❌ Missing store
await createDeepAgent({ backend: (config) => new StoreBackend(config) });
// ✅ Provide store
await createDeepAgent({
backend: (config) => new StoreBackend(config),
store: new InMemoryStore()
});