quiet robot

Sandboxes

Agent frameworks, E2B and CI

Sandbox tools for the Vercel AI SDK, OpenAI Agents SDK, LangChain, Mastra and ComputeSDK, a one-import switch from E2B, a GitHub Action and starter templates.

View as Markdown

Sandboxes is in early access. It is free to try, some parts are still in testing, and details may change. Sign up free

Agent frameworks

@quietrobot/sandboxes-ai gives your agent six tools on one sandbox, started the first time the model uses one: run_command, run_code, read_file, write_file, list_files and expose_port. Every command goes through your policy.

Terminal
npm install @quietrobot/sandboxes-ai zod

Each adapter's sandboxTools(options) returns { tools, session }. Call session.close() when the agent is done to destroy the sandbox.

Vercel AI SDK

TypeScript
import { generateText, stepCountIs } from "ai";
import { sandboxTools } from "@quietrobot/sandboxes-ai/vercel-ai";

const { tools, session } = sandboxTools();
try {
  const r = await generateText({ model, tools, stopWhen: stepCountIs(20), prompt: "Write and run a script that prints the first 10 primes." });
  console.log(r.text);
} finally {
  await session.close();
}

OpenAI Agents SDK

TypeScript
import { Agent, run } from "@openai/agents";
import { sandboxTools } from "@quietrobot/sandboxes-ai/openai-agents";

const { tools, session } = sandboxTools();
const agent = new Agent({ name: "coder", instructions: "Use the sandbox to run code.", tools });
console.log((await run(agent, "How many lines does /etc/passwd have?")).finalOutput);
await session.close();

LangChain and Mastra: import sandboxTools from @quietrobot/sandboxes-ai/langchain (returns DynamicStructuredTool[]) or @quietrobot/sandboxes-ai/mastra, and pass tools to your agent the usual way.

ComputeSDK

TypeScript
import { quietrobot } from "@quietrobot/sandboxes-ai/computesdk";

const provider = quietrobot({ apiKey: process.env.QR_API_KEY });
const sbx = await provider.instances.create();
console.log((await sbx.runCommand("echo hi")).stdout);
await sbx.destroy();

Options

TypeScript
sandboxTools({
  create: { egress: { mode: "allowlist", allow: ["pypi.org", "github.com"] }, timeoutSec: 3600 },
  tools: ["run_command", "read_file", "write_file"], // a subset
  noWaitForApproval: true, // tell the model a command is waiting instead of waiting for the decision
  sandbox,                 // or work in a sandbox you already have (close() leaves it alone)
});

Python has the same six tools for the OpenAI Agents SDK and LangChain, or as plain functions:

python
from agents import Agent
from quietrobot_sandboxes.integrations.openai_agents import openai_agents_tools
agent = Agent(name="coder", tools=openai_agents_tools())

from quietrobot_sandboxes.integrations.langchain import langchain_tools
tools = langchain_tools()

from quietrobot_sandboxes.integrations import SandboxTools
with SandboxTools(create={"egress": {"mode": "allowlist", "allow": ["pypi.org"]}}) as box:
    fns = box.functions()

For Claude Code, Cursor and other MCP clients, use the MCP server instead.

Coming from E2B

Change one import. The E2B-style API is a layer over the same client, so your policy, approvals and audit log apply to it too. Set QR_API_KEY instead of E2B_API_KEY.

TypeScript
// import { Sandbox } from "e2b";
// import { Sandbox } from "@e2b/code-interpreter";
import { Sandbox } from "@quietrobot/sandboxes/e2b";

const sbx = await Sandbox.create();
const r = await sbx.commands.run("echo hi");
const cell = await sbx.runCode("1 + 1");
await sbx.files.write("notes.txt", "hello");
console.log(`https://${sbx.getHost(3000)}`);
await sbx.kill();
python
# from e2b_code_interpreter import Sandbox
from quietrobot_sandboxes.e2b import Sandbox

with Sandbox() as sbx:
    print(sbx.commands.run("echo hi").stdout)
    print(sbx.run_code("1 + 1").text)

Covered: Sandbox.create, connect, list, kill, setTimeout, commands.run (foreground and background, with CommandHandle), commands.connect, kill, sendStdin and list, files.read, write, list, exists, makeDir, remove and rename, getHost, runCode, pause, isRunning and getInfo. Not covered yet: E2B's template builds (use your own templates instead) and watching folders for changes.

GitHub Action

Run tests, a build or an agent task in a fresh sandbox instead of on the runner. The action copies your checkout in, runs the command, copies results back and destroys the sandbox. The step fails with the command's exit code.

yaml
on: [pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: Quiet-Robot/sandboxes-sdk/action@v0
        with:
          api-key: ${{ secrets.QR_API_KEY }}
          setup: pip install -r requirements.txt
          run: pytest -q --junitxml=report.xml
          allow: pypi.org, files.pythonhosted.org
          download: work/report.xml:report.xml

To let an agent call a model without seeing its key, store the key as a secret and name it in secrets:. Every input is listed in the action's README.

Starter templates

Working examples to copy, in the SDK repository:

  • Coding agent (TypeScript): an agent works on a copy of your repository in a sandbox and hands back a patch.
  • Browser agent (Python): an agent drives a real Chromium that runs in the sandbox, not on your machine.
  • Data notebook (Python): an agent analyzes a CSV one cell at a time in the notebook kernel.