Vercel Sandbox backend for agent-harness-experimental.
Use this package when you want createAgentSession to run hosted agent work in Vercel
Sandbox. It is the default hosted backend in agent-harness-experimental, and you can pass
it explicitly when you want to configure templates, resources, files, network
policy, or resume behavior in one place.
Pass sandbox.template to start from an existing Vercel Sandbox snapshot. The
adapter also supports the SDK image/template store used by adapter-managed
agent images.
import { createAgentSession } from "agent-harness-experimental";import { claudeCode } from "@agent-harness-experimental/adapter-claude-code";import { createVercelSandboxBackend } from "@agent-harness-experimental/sandbox-vercel";const vercelSandbox = createVercelSandboxBackend();const agent = createAgentSession({ adapter: claudeCode(), sessionId: "web-fix", sandbox: { backend: vercelSandbox, template: "snap_abc123", },});await agent.generate("Fix the failing UI test");await agent.close("stop");
Resume
Vercel Sandbox sessions are persistent. Use the same sessionId with
resumeAgentSession() to reconnect through the same configured backend.
import { resumeAgentSession } from "agent-harness-experimental";import { claudeCode } from "@agent-harness-experimental/adapter-claude-code";import { createVercelSandboxBackend } from "@agent-harness-experimental/sandbox-vercel";const vercelSandbox = createVercelSandboxBackend();const agent = resumeAgentSession({ adapter: claudeCode(), sessionId: "review-123", sandbox: { backend: vercelSandbox, },});const result = await agent.generate("Continue from the last checkpoint");console.log(result.text);await agent.
Network
Use sandbox.network to control outbound access for the agent run. Vercel
Sandbox supports native deny-all, host allow rules, CIDR rules, header
transforms, hosted ports, and dynamic updates.
You can omit sandbox.backend when the default Vercel backend is enough. Pass
createVercelSandboxBackend() explicitly when you want the configuration to be
obvious at the call site, or when you share the same backend object across
multiple agents.
Common createAgentSession({ sandbox }) fields:
Field
Description
backend
The Vercel Sandbox backend returned by createVercelSandboxBackend().
template
Existing Vercel Sandbox snapshot ID to create the session from.
resources
Hosted sandbox resources, such as { cpu: 2 }.
env
Environment variables available inside the sandbox.
files
Initial files written into the agent working directory.
network
Outbound network policy and host approval behavior.
timeoutMs
Sandbox creation timeout in milliseconds.
workingDirectory
Override for the agent working directory inside the sandbox.
});
const result = await agent.generate("Review the current changes");