Introducing Run SDK: secure eval for your agents
Vercel released the Run SDK, a JavaScript and TypeScript sandbox for executing untrusted code with restricted access to host functions, enabling secure agent workflows with authentication and human-in-the-loop approvals.
Agents frequently generate TypeScript programs to coordinate tools and process data, but executing this code with eval risks exposing application secrets and internal services. The newly released Run SDK addresses this by evaluating untrusted JavaScript or TypeScript in an isolated QuickJS context within a worker thread, preventing direct access to Node.js or the network. Applications expose only specific operations through host functions, which are regular functions callable from within the sandbox, ensuring sensitive credentials and clients remain in the trusted application layer.
The Run SDK allows applications to define narrow interfaces for agent-generated code, such as store.listOrders(), while keeping database clients and credentials secure. Host functions can return promises, enabling existing service clients to integrate without being passed into the sandbox. Developers can test the SDK in a playground where code execution is limited to exposed host functions on the page, demonstrating its practical use in agent workflows that require controlled access to internal services.
The Run SDK powers code mode tool execution in Vercel’s AI SDK, shifting the unit of work from individual API calls to entire programs. This enables agents to perform complex tasks, such as combining search results or inspecting accounts, without returning unnecessary data to the application. The same package can also support code interpreters or customer-defined transformations, with applications controlling the available data and operations through host functions tailored to product-specific actions like refunding orders.
The SDK includes mechanisms for pausing execution at sensitive operations, such as issuing refunds, by interrupting the run and generating a signed token for later resumption. Resuming a paused run replays the program but skips completed host function calls, ensuring efficiency. The Run SDK supports Node.js 22.13+ and Bun, requiring a package manager like pnpm for local development. It is designed for JavaScript computation within applications, while workloads needing operating system access or process isolation should use Vercel Sandbox instead.