Here is what Claude’s code execution tool actually provides to you.
Claude code execution runs Python in a closed Linux container with tight limits, fixed packages, no network, 30-day expiry, and usage-based billing.
Key Takeaways
- Claude’s code execution tool runs Python 3.11 in a tiny, isolated Linux container with 1 CPU core, 5 GiB RAM, 5 GiB disk, no internet access, and file access limited to the workspace.
- The sandbox’s preinstalled package list is a hard limit: common libraries such as pandas, numpy, matplotlib, scikit-learn, and document-processing tools are available, but Claude cannot install new packages during a session.
- Containers are not instantly discarded: they checkpoint after about five minutes of inactivity and can be resumed with the same container ID, but all containers and stored files are deleted after 30 days.
- Code execution is free when paired with current web search or web fetch tools; otherwise it is billed by execution time, with 1,550 free hours per month, then $0.05 per hour per container and a five-minute minimum.
- Newer tool versions add REPL persistence and programmatic tool calling, but support depends on the model and API capabilities; the sandbox is best for self-contained data, file, and calculation tasks, not live API calls or long-running jobs.
Meta description: Anthropic's Claude code execution sandbox gives one CPU core, 5 GiB RAM, Python 3.11, no network, and billing rules after free web search pairing.
Tags: Claude, Anthropic, Code Execution, Python Sandbox
Featured image: abstract friendly illustration of a small locked Python sandbox, no real people, logos, or text.
When Claude needs spreadsheet math, such as the standard deviation of a column, it no longer has to talk itself through the arithmetic. Anthropic's code execution tool lets the model write Python, run it, and read the result back. The practical question is not whether it can run code, but where it runs: the Claude code execution sandbox is a very small, very closed Linux container.
A tiny Linux container for each request
The environment for each request is a dedicated Linux container with x86_64 architecture and Python 3.11. It has one CPU core, 5 GiB of RAM, and 5 GiB of disk for the workspace. A modest pandas job on a small comma-separated values file may fit. Larger data sets hit those limits quickly.
The sandbox has no internet. Outbound requests are blocked, and the container does not share access with the host or neighboring containers. It can only touch files inside the workspace directory, with the same request-level scoping used by the Files API for uploads. The box is meant for computation Claude can complete without trusting anything outside it. That contrasts with patterns in the Claude Agent SDK, where subagents often need to reach real services for a user.
The package list is the hard ceiling
Since the container cannot reach the network, Claude cannot fetch new packages during a session; it must rely on the installed library set. The preloaded list covers common analysis work: pandas, numpy, scipy, scikit-learn, and statsmodels. It includes matplotlib and seaborn for plots, plus openpyxl, pyarrow, pypdf, pdfplumber, python-docx, and python-pptx for files people usually exchange. Sympy supports symbolic math, and the command line tools include unzip, 7zip, ripgrep, fd, and sqlite.
If a task needs a library outside that set, the documentation does not provide an in-session workaround. A team that depends on a special scientific package, or on native bindings that are not shipped, should build its own sandboxed runtime. The limitation is not about choosing the right tool surface; the available imports are fixed before the conversation starts.
Five-minute checkpoints and a 30-day end date
A container does not disappear as soon as one response finishes. After about five minutes without activity, it checkpoints. A later request can restore it by passing the previous container identifier back to the API, so the session does not start from zero every turn.
The outer lifetime limit is 30 days from creation. After 30 days, the container and everything stored in it, including uploaded files, intermediate artifacts, and outputs, are gone. A request against an expired container identifier returns an error instead of quietly creating a replacement. Anthropic's reconnect example uses model claude-opus-5-5, max_tokens 4096, and the code_execution_20250825 tool to read /tmp/number.txt and calculate its square. If a pause_turn response is followed by a request that omits the container identifier, files written earlier in that turn are lost.
Cost after the web search pairing
Code execution is free when it is paired with web search or web fetch tools, provided those tools are version web_search_20260209, web_fetch_20260209, or later. Outside that pairing, it is billed separately from tokens by execution time, with a five-minute minimum per container.
Each organization gets 1,550 free hours of execution time per month. After that, Anthropic charges $0.05 per hour, per container. The five-minute minimum is most visible in patterns that create a fresh container for every request instead of reusing one. Small frequent jobs can add up faster than the hourly rate alone suggests, because tool-call overhead can make an agent loop cost more than the model price tag.
Tool versions and model support change the feature set
Three current versions exist. code_execution_20250825 covers bash commands and file operations. code_execution_20260120 adds state persistence for an interactive read-evaluate-print loop and lets code call other tools programmatically from inside the sandbox. That programmatic calling needs a current web search or web fetch version paired alongside it. code_execution_20260521 runs the identical sandbox but documents a 90-second wall-clock limit per Python cell for that programmatic calling.
Model support still matters. Claude Haiku 4.5 accepts the newer tool versions in a request, but programmatic tool calling and read-evaluate-print loop persistence do not activate. It falls back to behaving like the original code_execution_20250825 version. The reliable check is capabilities.server_tools.code_execution.supported in the Models API response for the model, not an assumption of parity across the lineup.
The sandbox is best treated as a disposable, well-fenced calculator for self-contained file and data work. It fits spreadsheet math, document parsing, quick plots, and short Python calculations. It is not the right place for live API calls, long-running jobs, or packages outside the preload list.

Comments (0)