Node.js VFS backend for deepagents.
Provides an in-memory virtual file system for agent operations, allowing agents to read/write files without affecting the real filesystem.
This implementation uses node-vfs-polyfill which implements the upcoming Node.js VFS feature. Files are stored entirely in-memory using the VFS.
import { VfsBackend } from "@langchain/node-vfs";
// Create and initialize a VFS backend
const backend = await VfsBackend.create({
initialFiles: {
"/src/index.js": "console.log('Hello')",
},
});
try {
// Read files directly
const result = await backend.read("/src/index.js");
console.log(result.content);
} finally {
await backend.stop();
}
import { createDeepAgent } from "deepagents";
import { VfsBackend } from "@langchain/node-vfs";
const backend = await VfsBackend.create();
const agent = createDeepAgent({
model: new ChatAnthropic({ model: "claude-sonnet-4-20250514" }),
systemPrompt: "You are a coding assistant with VFS access.",
backend,
});