Agent Sandboxesagentsandboxes.org
Sandbox profile · Cloud or model provider service

Claude code execution tool

Answer in brief

Server-side tool in the Claude API that runs Bash commands, Python and file edits inside an Anthropic-hosted container with no internet access. The simplest way to give Claude a scratch computer for analysis and file work, provided you can live without network access and custom environments.

By the Agent Sandboxes editors · Updated

Overview

The code execution tool is a server-side tool in the Claude API: add {"type": "code_execution_20250825", "name": "code_execution"} to a Messages request and Claude can run Bash commands, write and edit files and execute Python in a container that Anthropic hosts. The container is a Linux x86_64 environment with Python 3.11, 1 CPU, 5 GiB of RAM and 5 GiB of workspace storage, with a fixed set of pre-installed libraries (pandas, numpy, scipy, scikit-learn, matplotlib, seaborn, openpyxl, pypdf and others) and command-line tools such as ripgrep, sqlite and 7zip. Internet access is completely disabled. Files are passed in and out through the Files API using container_upload blocks and $OUTPUT_DIR.

Each request gets a fresh container unless you pass back the container.id from an earlier response, in which case files (and, with code_execution_20260120 or later, Python REPL state) persist. Containers are checkpointed after about five minutes of inactivity and expire 30 days after creation. Three tool versions are current: code_execution_20250825 (Bash and file operations), code_execution_20260120 (adds REPL state persistence and programmatic tool calling) and code_execution_20260521 (same runtime, with the 90-second per-cell limit described to the model); the legacy Python-only code_execution_20250522 is documented for migration. The feature is marked stable and no beta header is required. Pricing is by execution time: 1,550 free container-hours per organisation per month, then $0.05 per container-hour with a five-minute minimum, and no charge when the request also uses the web search or web fetch tools. This record covers the hosted API tool only; Claude Code's local sandbox is a separate product.

Notable

  • Marked stable in the Claude API docs; the three current tool versions are dated 2025-08-25, 2026-01-20 and 2026-05-21, and none requires a beta header
  • Each organisation receives 1,550 free container-hours per month; usage beyond that is $0.05 per container-hour
  • Images, video and audio that Claude produces in the container carry C2PA Content Credentials when downloaded through the Files API

Claude code execution tool specifications

AttributeDetails
IsolationAnthropic-hosted Linux container per request ("secure, sandboxed container"); the docs state full isolation from the host and other containers but do not name the container runtime or hypervisor
DeploymentCloud or model provider service
Open sourceNo
SDKs and interfacesPython, JavaScript/TypeScript, Go, Java, C#, PHP, Ruby, REST API, CLI
Cold start (vendor claim)Not documented
Max session lengthContainers expire 30 days after creation; after about 5 minutes of inactivity a container is checkpointed and restored when its ID is sent again; each tool call has a maximum execution time and each REPL cell in programmatic tool calling has a 90-second wall-clock limit
PersistenceFiles written to the container persist across requests when you pass the container ID back; with code_execution_20260120 or later the Python REPL state (variable bindings) also persists; generated files are returned through the Files API
GPUNo — each container has 1 CPU, 5 GiB RAM and 5 GiB of workspace storage
NetworkingInternet access is completely disabled and no outbound connections are allowed; packages cannot be installed at runtime, only the pre-installed libraries are available
PricingBilled by execution time, separate from tokens: 1,550 free container-hours per organisation per month, then $0.05 per hour per container, with a 5-minute minimum per execution; free of additional charge in requests that also use the web search or web fetch tools (web_search_20260209 / web_fetch_20260209 or later)
Free tier1,550 free container-hours per organisation per month
ComplianceNot eligible for zero data retention (container data retained up to 30 days)
RegionsAvailable on the Claude API, the Claude Platform on AWS, Claude Models on Google Cloud (Anthropic managed) and Microsoft Foundry (hosted on Anthropic); no region selection documented

Facts from Claude code execution tool’s public documentation, verified November 9, 2026. Performance numbers are vendor claims.

Strengths and trade-offs

Strengths

  • You want Claude to analyse uploaded files or produce charts and documents without operating a sandbox yourself
  • You need the execution environment to be fully offline for data-handling reasons
  • You are already on the Claude API (or its AWS, Google Cloud or Microsoft Foundry distributions) and want a one-line opt-in
  • You want REPL state and files to survive across turns by reusing a container ID

Trade-offs

  • No internet access at all, so no package installation, git clones or API calls from inside the container
  • Fixed resources: 1 CPU, 5 GiB RAM, 5 GiB disk, no GPU and no custom images
  • Only usable through Claude; the container is not addressable as a general-purpose sandbox from your own code
  • Container data is retained for up to 30 days, so the tool is not eligible for zero data retention

Good fit for: Data analysis, file generation and multi-step scripting inside a Claude API conversation without running your own sandbox.

Use cases Claude code execution tool fits

  • Code interpreters: A hosted container for Python and shell inside a Claude API conversation: data analysis, file generation and multi-step scripting with no sandbox to run.

How Claude code execution tool compares

SandboxIsolationOpen sourceSelf-host / BYOCCold start (vendor)Max sessionSnapshots / pauseGPUSDKs
Claude code execution toolHosted Linux containerNoNo / NoNot documented30 days (container)No / Not documentedNoPython, JavaScript/TypeScript, Go, Java, C#, PHP, Ruby, REST API, CLI
OpenAI Code Interpreter & Hosted ShellVM (unspecified)NoNo / NoNot documented20 min idleNo / NoNoOpenAI Responses API, Containers API, OpenAI SDKs
Gemini API code executionHosted Python runtimeNoNo / NoNot documented30 s per executionNo / NoNoPython, JavaScript/TypeScript, Go, Java, REST API
Mistral code interpreterIsolated containerNoNo / NoNot documentedNot documentedNot documented / Not documentedNot documentedPython, JavaScript/TypeScript, REST API
AWS Bedrock AgentCoreMicroVM (Runtime)NoNo / NoNot documentedUp to 8 hNot documented / Not documentedNoPython (AgentCore SDK), AWS SDKs, AWS CLI
Azure Container Apps dynamic sessionsHyper-V VMNoNo / NoSub-second (pooled)220 s / execNo / NoNoREST API, Azure CLI, LangChain, LlamaIndex, Semantic Kernel

See all Claude code execution tool alternatives →

Frequently asked questions

What is Claude code execution tool?
Server-side tool in the Claude API that runs Bash commands, Python and file edits inside an Anthropic-hosted container with no internet access. The simplest way to give Claude a scratch computer for analysis and file work, provided you can live without network access and custom environments.
How does Claude code execution tool isolate code?
Claude code execution tool documents its isolation as: Anthropic-hosted Linux container per request ("secure, sandboxed container"); the docs state full isolation from the host and other containers but do not name the container runtime or hypervisor.
Is Claude code execution tool open source?
No, Claude code execution tool is not open source.
How much does Claude code execution tool cost?
Billed by execution time, separate from tokens: 1,550 free container-hours per organisation per month, then $0.05 per hour per container, with a 5-minute minimum per execution; free of additional charge in requests that also use the web search or web fetch tools (web_search_20260209 / web_fetch_20260209 or later) Check the official pricing page for current rates.
What are the alternatives to Claude code execution tool?

Sources

  1. platform.claude.com/docs/en/agents-and-tools/tool-use/code-execution-tool

Cite this page

Agent Sandboxes. (2026). Claude code execution tool. agentsandboxes.org. Last reviewed November 9, 2026. https://agentsandboxes.org/sandboxes/anthropic-code-execution/

Found an error or a missing sandbox? Submit a correction — every entry links to the sources it relies on.