[PR #163] [MERGED] feat: add VFS sandbox #170

Closed
opened 2026-02-16 06:17:20 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagentsjs/pull/163
Author: @christian-bromann
Created: 2/1/2026
Status: Merged
Merged: 2/5/2026
Merged by: @christian-bromann

Base: mainHead: cb/vfs-sandbox


📝 Commits (10+)

📊 Changes

16 files changed (+2603 additions, -2 deletions)

View changed files

📝 examples/package.json (+2 -1)
examples/sandbox/vfs-sandbox.ts (+139 -0)
libs/providers/node-vfs/.npmignore (+22 -0)
libs/providers/node-vfs/README.md (+204 -0)
libs/providers/node-vfs/package.json (+72 -0)
libs/providers/node-vfs/src/index.ts (+58 -0)
libs/providers/node-vfs/src/node-vfs-polyfill.d.ts (+513 -0)
libs/providers/node-vfs/src/sandbox.int.test.ts (+495 -0)
libs/providers/node-vfs/src/sandbox.test.ts (+326 -0)
libs/providers/node-vfs/src/sandbox.ts (+565 -0)
libs/providers/node-vfs/src/types.ts (+123 -0)
libs/providers/node-vfs/tsconfig.json (+8 -0)
libs/providers/node-vfs/tsdown.config.ts (+12 -0)
libs/providers/node-vfs/vitest.config.ts (+22 -0)
📝 package.json (+1 -1)
📝 pnpm-lock.yaml (+41 -0)

📄 Description

Adds a new sandbox provider package @langchain/vfs-sandbox that enables agents to execute code in an isolated in-memory Virtual File System, requiring no Docker, cloud services, or external dependencies.

Features

  • In-memory file storage using node-vfs-polyfill (polyfill for upcoming Node.js VFS feature nodejs/node#61478)
  • Full shell command execution via automatic temp directory sync
  • Pre-populate sandbox with initial files at creation
  • Zero setup - works out of the box with no external dependencies

How It Works

  1. Files are stored in-memory using VirtualFileSystem
  2. When commands execute, files sync to a temp directory
  3. Command runs in the temp directory
  4. Changes sync back to VFS

This hybrid approach provides in-memory isolation while maintaining full shell command compatibility.

Usage

import { VfsSandbox } from "@langchain/vfs-sandbox";
import { createDeepAgent } from "deepagents";

const sandbox = await VfsSandbox.create({
  initialFiles: {
    "/src/index.js": "console.log('Hello!')",
  },
});

const agent = createDeepAgent({
  model: new ChatAnthropic({ model: "claude-sonnet-4-20250514" }),
  systemPrompt: "You are a coding assistant.",
  backend: sandbox,
});

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/deepagentsjs/pull/163 **Author:** [@christian-bromann](https://github.com/christian-bromann) **Created:** 2/1/2026 **Status:** ✅ Merged **Merged:** 2/5/2026 **Merged by:** [@christian-bromann](https://github.com/christian-bromann) **Base:** `main` ← **Head:** `cb/vfs-sandbox` --- ### 📝 Commits (10+) - [`5820cad`](https://github.com/langchain-ai/deepagentsjs/commit/5820cadf83e5976fa9debdcaaddad95cb4cde4bb) feat: add support for Vercel sandbox - [`8de0c16`](https://github.com/langchain-ai/deepagentsjs/commit/8de0c165101f7d6561577ccebd139c836e03fce4) format - [`6a4c864`](https://github.com/langchain-ai/deepagentsjs/commit/6a4c864c8492b2e2bfcaf61fe2c234ae6f8c9087) switch to deno - [`3dfce48`](https://github.com/langchain-ai/deepagentsjs/commit/3dfce485838657b91d99c4e31960c6bd855a30e8) cr - [`e3237fe`](https://github.com/langchain-ai/deepagentsjs/commit/e3237fef67aa7310a319d14782b900e787fa1795) format - [`cf3eee0`](https://github.com/langchain-ai/deepagentsjs/commit/cf3eee00d12c10ed7c482cb58e5669dcd32e73a2) feat: add support for Vercel sandbox - [`619749e`](https://github.com/langchain-ai/deepagentsjs/commit/619749eb95a0c4282254b7b0206b7a5eaa85d7ed) feat: add VFS sandbox - [`8f7a721`](https://github.com/langchain-ai/deepagentsjs/commit/8f7a721a1c35dd5e68c46576063aa01020eb13cd) format - [`57a582b`](https://github.com/langchain-ai/deepagentsjs/commit/57a582b920cce956560b639cea2f8c67ad29c62c) rm vercel - [`5289cc1`](https://github.com/langchain-ai/deepagentsjs/commit/5289cc10456248882c23622ac8122505c41c31d5) rename ### 📊 Changes **16 files changed** (+2603 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `examples/package.json` (+2 -1) ➕ `examples/sandbox/vfs-sandbox.ts` (+139 -0) ➕ `libs/providers/node-vfs/.npmignore` (+22 -0) ➕ `libs/providers/node-vfs/README.md` (+204 -0) ➕ `libs/providers/node-vfs/package.json` (+72 -0) ➕ `libs/providers/node-vfs/src/index.ts` (+58 -0) ➕ `libs/providers/node-vfs/src/node-vfs-polyfill.d.ts` (+513 -0) ➕ `libs/providers/node-vfs/src/sandbox.int.test.ts` (+495 -0) ➕ `libs/providers/node-vfs/src/sandbox.test.ts` (+326 -0) ➕ `libs/providers/node-vfs/src/sandbox.ts` (+565 -0) ➕ `libs/providers/node-vfs/src/types.ts` (+123 -0) ➕ `libs/providers/node-vfs/tsconfig.json` (+8 -0) ➕ `libs/providers/node-vfs/tsdown.config.ts` (+12 -0) ➕ `libs/providers/node-vfs/vitest.config.ts` (+22 -0) 📝 `package.json` (+1 -1) 📝 `pnpm-lock.yaml` (+41 -0) </details> ### 📄 Description Adds a new sandbox provider package `@langchain/vfs-sandbox` that enables agents to execute code in an isolated in-memory Virtual File System, requiring no Docker, cloud services, or external dependencies. ## Features - **In-memory file storage** using [node-vfs-polyfill](https://github.com/vercel-labs/node-vfs-polyfill) (polyfill for upcoming Node.js VFS feature [nodejs/node#61478](https://github.com/nodejs/node/pull/61478)) - **Full shell command execution** via automatic temp directory sync - **Pre-populate sandbox** with initial files at creation - **Zero setup** - works out of the box with no external dependencies ## How It Works 1. Files are stored in-memory using `VirtualFileSystem` 2. When commands execute, files sync to a temp directory 3. Command runs in the temp directory 4. Changes sync back to VFS This hybrid approach provides in-memory isolation while maintaining full shell command compatibility. ## Usage ```typescript import { VfsSandbox } from "@langchain/vfs-sandbox"; import { createDeepAgent } from "deepagents"; const sandbox = await VfsSandbox.create({ initialFiles: { "/src/index.js": "console.log('Hello!')", }, }); const agent = createDeepAgent({ model: new ChatAnthropic({ model: "claude-sonnet-4-20250514" }), systemPrompt: "You are a coding assistant.", backend: sandbox, }); ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 06:17:20 -05:00
yindo closed this issue 2026-02-16 06:17:20 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagentsjs#170