[GH-ISSUE #203] VfsSandbox: initialFiles example from README doesn't work on macOS #45

Closed
opened 2026-02-16 06:16:57 -05:00 by yindo · 3 comments
Owner

Originally created by @enteve on GitHub (Feb 8, 2026).
Original GitHub issue: https://github.com/langchain-ai/deepagentsjs/issues/203

Originally assigned to: @christian-bromann on GitHub.

VfsSandbox: initialFiles example from README doesn't work on macOS

Summary

The basic example from the @langchain/node-vfs README doesn't work. Files created with initialFiles are not accessible when running commands via execute().

Expected Behavior

import { VfsSandbox } from "@langchain/node-vfs";

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

const result = await sandbox.execute("node /src/index.js");
console.log(result.output); // Expected: "Hello from VFS!"

Actual Behavior

Error: Cannot find module '/src/index.js'
    at Module._resolveFilename (node:internal/modules/cjs_loader:1383:15)

Workaround

Use relative paths without leading slash:

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

const result = await sandbox.execute("node src/index.js");
// This might work depending on the working directory。

However, this workaround is problematic when using with ls and read_file tools from deepagents, because these tools cannot read files in this format either. The path mismatch issue persists across all file access methods.

Environment

  • @langchain/node-vfs: ^0.1.1
  • Node.js: v22.21.1
  • OS: macOS (Darwin 24.5.0)
Originally created by @enteve on GitHub (Feb 8, 2026). Original GitHub issue: https://github.com/langchain-ai/deepagentsjs/issues/203 Originally assigned to: @christian-bromann on GitHub. # VfsSandbox: initialFiles example from README doesn't work on macOS ## Summary The basic example from the `@langchain/node-vfs` README doesn't work. Files created with `initialFiles` are not accessible when running commands via `execute()`. ## Expected Behavior ```typescript import { VfsSandbox } from "@langchain/node-vfs"; const sandbox = await VfsSandbox.create({ initialFiles: { "/src/index.js": "console.log('Hello from VFS!')", }, }); const result = await sandbox.execute("node /src/index.js"); console.log(result.output); // Expected: "Hello from VFS!" ``` ## Actual Behavior ``` Error: Cannot find module '/src/index.js' at Module._resolveFilename (node:internal/modules/cjs_loader:1383:15) ``` ## Workaround Use relative paths without leading slash: ```typescript const sandbox = await VfsSandbox.create({ initialFiles: { "src/index.js": "console.log('Hello from VFS!')", }, }); const result = await sandbox.execute("node src/index.js"); // This might work depending on the working directory。 ``` **However**, this workaround is problematic when using with `ls` and `read_file` tools from `deepagents`, because these tools cannot read files in this format either. The path mismatch issue persists across all file access methods. ## Environment - `@langchain/node-vfs`: ^0.1.1 - Node.js: v22.21.1 - OS: macOS (Darwin 24.5.0) -
yindo closed this issue 2026-02-16 06:16:57 -05:00
Author
Owner

@christian-bromann commented on GitHub (Feb 9, 2026):

Thanks for raising this issue. A fix has been published in deepagents@v1.7.3. Please let me know in case you still experience this problem.

@christian-bromann commented on GitHub (Feb 9, 2026): Thanks for raising this issue. A fix has been published in `deepagents@v1.7.3`. Please let me know in case you still experience this problem.
yindo changed title from VfsSandbox: initialFiles example from README doesn't work on macOS to [GH-ISSUE #203] VfsSandbox: initialFiles example from README doesn't work on macOS 2026-06-05 17:21:08 -04:00
Author
Owner

@enteve commented on GitHub (Feb 28, 2026):

Hi, thanks for the fix! The sandboxing now works correctly for ls, read_file, and write_file tools.

However, there's still an issue with the execute tool. When agent runs execute("touch /a.txt"), it tries to execute the command in the host's root directory instead of the sandbox directory, resulting in a "Read-only file system" error.

It seems the execute tool's command execution doesn't properly set the working directory to the sandbox path. Could you please take a look?

<!-- gh-comment-id:3976630950 --> @enteve commented on GitHub (Feb 28, 2026): Hi, thanks for the fix! The sandboxing now works correctly for ls, read_file, and write_file tools. However, there's still an issue with the execute tool. When agent runs execute("touch /a.txt"), it tries to execute the command in the host's root directory instead of the sandbox directory, resulting in a "Read-only file system" error. It seems the execute tool's command execution doesn't properly set the working directory to the sandbox path. Could you please take a look?
Author
Owner

@christian-bromann commented on GitHub (Mar 2, 2026):

Thanks for flagging, taking a look!

<!-- gh-comment-id:3986790387 --> @christian-bromann commented on GitHub (Mar 2, 2026): Thanks for flagging, taking a look!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagentsjs#45