typescript-utcp icon indicating copy to clipboard operation
typescript-utcp copied to clipboard

Why use Node.js vm module instead of `isolated-vm` for sandboxed LLM code execution?

Open Jason-CKY opened this issue 11 months ago • 1 comments

Question: Why use Node.js vm module instead of isolated-vm for sandboxing?

While the implementation in packages/code-mode/src/code_mode_utcp_client.ts leverages Node.js's native vm module for executing LLM-generated TypeScript code in a sandboxed environment, I'm curious about the decision not to use isolated-vm instead. The isolated-vm library is widely regarded for its stronger isolation guarantees, being designed specifically to prevent untrusted code from escaping its sandbox and interfering with the host process or other sandboxes.

Context:

  • The vm module executes code in a V8 context, but shares the same thread and some global objects with the parent Node.js process.
  • isolated-vm creates true isolates in V8, preventing most forms of escape and providing much tighter separation, which is especially critical for running untrusted or LLM-generated code.

Questions:

  • What are the technical or practical reasons for preferring vm over isolated-vm in this codebase?
  • Are there limitations, compatibility issues, or performance concerns that led to this choice?
  • Are there plans or discussions to adopt isolated-vm in the future for enhanced security and isolation?

References:

This question is particularly relevant as LLM-generated code may be untrusted, and robust sandboxing is critical for security. Would appreciate insight from maintainers or those familiar with the design decisions here.

Jason-CKY avatar Dec 11 '25 16:12 Jason-CKY

The main issue with the isolated-vm implementation is that it's much more complicated to get the tools called in the code to execute in the main process. This is necessary for a consistent state for tools such as the PlayWrite MCP, which would not work directly in the isolated-vm.

That being said, we are looking to switch to isolated-vm and are welcoming any contributions in that direction!

h3xxit avatar Jan 14 '26 09:01 h3xxit