Skip to content
Markdown

Use Runtime with your AI framework

Keep your framework's model and agent loop, and run the code it writes in a Runtime sandbox.

Every integration below is ready to install. Each one runs in its framework's own agent loop. Each was tested against real sandboxes. Each keeps your model, prompts and application as they are.

Framework Language What you add
OpenAI Agents SDK Python, TypeScript A sandbox client for SandboxAgent, or four function tools
Vercel AI SDK TypeScript runtimeTools(sbx) from withruntime/ai
Claude Agent SDK TypeScript runtimeMcpServer(sbx) from withruntime/claude-agent-sdk
LangChain and LangGraph Python sandbox_tools(sbx) as LangChain tools
Deep Agents Python RuntimeSandbox(sbx) as the agent's backend
Mastra TypeScript runtimeTools(sbx), which Mastra agents take as they are
CrewAI Python sandbox_tools(sbx) wrapped with CrewAI's tool
Google ADK Python sandbox_tools(sbx) as the agent's tools
LlamaIndex Python sandbox_tools(sbx) as FunctionTools
Pydantic AI Python sandbox_tools(sbx) as the agent's tools
Any other framework Python, TypeScript withruntime.tools or withruntime/tools: a name, a schema, a function
Claude Code, Codex, Cursor and more Any Runtime's MCP server: npx -y withruntime mcp

Six integrations have a guide of their own:

Guide Language What it does
Harbor and Terminal-Bench Python RuntimeEnvironment runs each trial in its own microVM, from the task's Dockerfile
Inspect AI Python A sandbox named runtime runs each sample from its Dockerfile or compose.yaml
LangChain, LangGraph and Deep Agents Python langchain-withruntime: a Deep Agents backend, and the four tools for LangChain and LangGraph
Vercel AI SDK harness agents TypeScript createRuntimeSandbox() runs Claude Code, Codex, OpenCode or Pi under HarnessAgent
ComputeSDK TypeScript @computesdk/runtime, a provider that runs your compute.sandbox code unchanged
Claude Managed Agents Any Runtime's remote MCP server gives a Managed Agent sandboxes beside its own session container

The four tools are the same in every framework: runtime_exec runs a command, runtime_read_file and runtime_write_file move text, and runtime_list_files lists a directory. Relative paths are under /workspace, and output is capped so one noisy command cannot flood the model's context.

  • Your application creates the sandbox, binds the tools to it and deletes it when the work ends. The model chooses commands and paths, never the sandbox or the account.
  • A framework's own local shell and file tools keep running on your machine; switch those off when the sandbox tools replace them.
  • Check exit codes, not only that a call succeeded.

Updated

On this page

OpenAI Agents SDK#

RuntimeCloudSandboxClient runs a SandboxAgent in a Runtime sandbox: its shell with PTY sessions and stdin, its file edits and image views, and its manifest. The agent definition does not change. The OpenAI Agents SDK guide covers every option.

Pythonfrom agents import Runnerfrom agents.run import RunConfigfrom agents.sandbox import SandboxAgent, SandboxRunConfigfrom withruntime.openai_agents import RuntimeCloudSandboxClient, RuntimeCloudSandboxClientOptionsagent = SandboxAgent(name="Coder", instructions="Fix the failing test, then run the suite.")run_config = RunConfig(    sandbox=SandboxRunConfig(        client=RuntimeCloudSandboxClient(),        options=RuntimeCloudSandboxClientOptions(),    ))result = Runner.run_sync(agent, "The tests are in tests/.", run_config=run_config)print(result.final_output)

Install with pip install "withruntime[openai-agents]". In TypeScript:

TypeScriptimport { run } from "@openai/agents";import { SandboxAgent } from "@openai/agents/sandbox";import { RuntimeCloudSandboxClient } from "withruntime/openai-agents";export async function fixTests() {  const agent = new SandboxAgent({ name: "Coder", instructions: "Fix the failing test." });  const client = new RuntimeCloudSandboxClient();  const result = await run(agent, "The tests are in tests/.", { sandbox: { client } });  return result.finalOutput;}

For an ordinary Agent, runtimeFunctionTools(sbx) (TypeScript) or [function_tool(f) for f in sandbox_tools(sbx)] (Python) gives it the four tools.

Vercel AI SDK#

runtimeTools(sbx) returns the four tools as AI SDK tools, for generateText, streamText and agents.

TypeScriptimport { generateText, stepCountIs, type LanguageModel } from "ai";import { Sandbox } from "withruntime";import { runtimeTools } from "withruntime/ai";export async function solve(model: LanguageModel, prompt: string) {  await using sbx = await Sandbox.create();  const { text } = await generateText({    model,    tools: runtimeTools(sbx),    stopWhen: stepCountIs(20),    prompt,  });  return text;}

It needs the ai package, version 5 or later. To run a whole harness agent in the sandbox instead, see the Vercel AI SDK guide.

Claude Agent SDK#

runtimeMcpServer(sbx) is an in-process MCP server with the four tools. RUNTIME_TOOL_NAMES lists them for allowedTools.

TypeScriptimport { query } from "@anthropic-ai/claude-agent-sdk";import { Sandbox } from "withruntime";import { RUNTIME_TOOL_NAMES, runtimeMcpServer } from "withruntime/claude-agent-sdk";export async function solve(prompt: string) {  await using sbx = await Sandbox.create();  let answer = "";  for await (const message of query({    prompt,    options: {      mcpServers: { runtime: runtimeMcpServer(sbx) },      allowedTools: RUNTIME_TOOL_NAMES,      disallowedTools: ["Bash", "Read", "Write", "Edit"],    },  })) {    if (message.type === "result" && message.subtype === "success") answer = message.result;  }  return answer;}

disallowedTools keeps the agent's work off your machine. It needs zod beside the SDK. An agent that should create and manage sandboxes itself can connect Runtime's own MCP server instead, as in coding agents.

LangChain#

sandbox_tools(sbx) returns the four tools as plain Python functions with type hints and docstrings, which LangChain's tool turns into LangChain tools. They work in create_agent, a LangGraph ToolNode and anywhere else LangChain takes tools.

Pythonfrom langchain.agents import create_agentfrom langchain_core.tools import toolfrom withruntime import Sandboxfrom withruntime.tools import sandbox_toolsdef solve(model, task: str) -> str:    with Sandbox.create() as sbx:        agent = create_agent(model, tools=[tool(f) for f in sandbox_tools(sbx)])        result = agent.invoke({"messages": [{"role": "user", "content": task}]})        return result["messages"][-1].content

The LangChain guide covers langchain-withruntime, the package LangChain lists.

Deep Agents#

RuntimeSandbox(sbx) is a Deep Agents sandbox backend: the agent's execute, ls, read_file, write_file, edit_file, glob and grep all run in the sandbox.

Pythonfrom deepagents import create_deep_agentfrom withruntime import Sandboxfrom withruntime.deepagents import RuntimeSandboxdef solve(task: str) -> str:    with Sandbox.create() as sbx:        agent = create_deep_agent(backend=RuntimeSandbox(sbx))        result = agent.invoke({"messages": [{"role": "user", "content": task}]})        return result["messages"][-1].content

Install with pip install "withruntime[deepagents]".

Mastra#

Mastra agents take AI SDK tools as they are, so runtimeTools(sbx) from withruntime/ai is the whole integration: new Agent({ id: "coder", name: "Coder", instructions, model, tools: runtimeTools(sbx) }).

CrewAI#

Pythonfrom crewai import Agent, Crew, Taskfrom crewai.tools import toolfrom withruntime import Sandboxfrom withruntime.tools import sandbox_toolsdef fix_tests() -> str:    with Sandbox.create() as sbx:        engineer = Agent(            role="Engineer",            goal="Make the test suite pass",            backstory="You work in a Linux sandbox.",            tools=[tool(f) for f in sandbox_tools(sbx)],        )        task = Task(description="Run the tests and fix what fails.", expected_output="A summary", agent=engineer)        return str(Crew(agents=[engineer], tasks=[task]).kickoff())

Google ADK#

ADK wraps plain functions as tools, so the four tools go straight in.

Pythonfrom google.adk.agents import Agentfrom withruntime import Sandboxfrom withruntime.tools import sandbox_toolsdef coder(model: str, sbx: Sandbox) -> Agent:    return Agent(        name="coder",        model=model,        instruction="Run code in the sandbox to answer.",        tools=sandbox_tools(sbx),    )

LlamaIndex#

Pythonfrom llama_index.core.agent.workflow import FunctionAgentfrom llama_index.core.tools import FunctionToolfrom withruntime import Sandboxfrom withruntime.tools import sandbox_toolsdef coder(llm, sbx: Sandbox) -> FunctionAgent:    return FunctionAgent(tools=[FunctionTool.from_defaults(fn=f) for f in sandbox_tools(sbx)], llm=llm)

Pydantic AI#

Pythonfrom pydantic_ai import Agentfrom withruntime import Sandboxfrom withruntime.tools import sandbox_toolsdef solve(model, task: str) -> str:    with Sandbox.create() as sbx:        return Agent(model, tools=sandbox_tools(sbx)).run_sync(task).output

Any other framework#

sandbox_tools(sbx) gives any framework that takes typed, documented functions the four tools. Pass an AsyncSandbox and they are coroutines. Try them without a model:

Pythonfrom withruntime import Sandboxfrom withruntime.tools import sandbox_toolswith Sandbox.create() as sbx:    run, read, write, ls = sandbox_tools(sbx)    print(write("hello.py", "print(sum([125, 250, 375]))\n"))    print(run("python3 hello.py"))    print(ls("."))

In TypeScript, withruntime/tools gives each tool as a name, a description, a JSON Schema and a function, ready for any tool format:

TypeScriptimport { Sandbox } from "withruntime";import { sandboxTools } from "withruntime/tools";await using sbx = await Sandbox.create();for (const t of sandboxTools(sbx)) console.log(t.name, Object.keys(t.inputSchema.properties));const [exec] = sandboxTools(sbx);console.log(await exec.execute({ command: "python3 -c 'print(sum([125, 250, 375]))'" }));

Coding agents#

Claude Code, Codex, Cursor, Windsurf, VS Code, Gemini CLI and any other MCP client connect to Runtime's own MCP server, which offers every Runtime product as tools. The first call shows a link and a code to approve in the browser; there is no key to copy. MCP covers the tools and the remote endpoint.

Terminalclaude mcp add --scope user runtime -- npx -y withruntime mcpcodex mcp add runtime -- npx -y withruntime mcpgemini mcp add --scope user runtime npx -y withruntime mcp

Cursor (.cursor/mcp.json) and Windsurf (~/.codeium/windsurf/mcp_config.json) take the same file:

JSON{  "mcpServers": {    "runtime": { "command": "npx", "args": ["-y", "withruntime", "mcp"] }  }}

VS Code takes it in .vscode/mcp.json:

JSON{  "servers": {    "runtime": { "type": "stdio", "command": "npx", "args": ["-y", "withruntime", "mcp"] }  }}

What was verified#

  • Every sample on this page is typechecked or compiled against the current SDK on every build, and the samples that need no model run.
  • On 23 September 2026 each integration ran in its framework's own agent loop against real sandboxes without credit, driven by scripted models so no model was paid for: OpenAI Agents SDK 0.22.3 (Python) and 0.18.0 (TypeScript), AI SDK 7.0.87, Claude Agent SDK 0.3.277, LangChain 1.4, LangGraph 1.2, Deep Agents 0.7.18, Mastra 1.69.0, Pydantic AI 2.48, Google ADK 2.9, LlamaIndex 0.14 and CrewAI 1.15. The OpenAI sandbox client also passed PTY sessions with stdin, manifests, users, exposed ports, tar and snapshot persistence, pause and resume.
  • claude mcp list, codex mcp list and cursor-agent mcp list-tools each reached the MCP server from the configuration above.

Official references checked 25 October 2026: OpenAI Agents SDK sandbox clients, Vercel tools, Claude Agent SDK custom tools, LangChain tools, Mastra tools.

Try it on your own work. Sign up, then paste the setup prompt into your coding agent.

Start free, no card

Was this page right?