[ ABORT TO HUD ]
SEQ. 1

Built-in Code Execution & Web Fetch

⚙️ Code Execution & Web Tools20 min700 BASE XP

Built-in Tool Types

Anthropic provides built-in tools that run inside Claude's managed infrastructure — no external setup required. Unlike user-defined tools (which require your backend to execute), built-in tools are executed directly by Anthropic's servers. You enable them by adding their tool type to the tools array in your API request, just like the Web Search tool.

Code Execution Tool (code_execution_20260120)

The Code Execution tool gives Claude a sandboxed environment to write and run Python or Bash code during a conversation. This is ideal for tasks that require computation, data transformation, or validation — instead of asking Claude to "imagine" the output, it actually runs the code and returns real results.

  • Sandboxed Environment: Code runs in an isolated container with no network access and no persistent state between executions.
  • 90-Second Time Limit: Each execution is capped at 90 seconds. Long-running computations will be terminated.
  • Pre-installed Libraries: Common Python packages (numpy, pandas, matplotlib, etc.) are available out of the box.
  • Output Capture: stdout, stderr, and generated files (e.g., charts) are returned in the response.

Web Fetch Tool

The Web Fetch tool allows Claude to retrieve content from URLs during a conversation. Claude can fetch HTML pages, JSON APIs, or raw text and process the results inline. This is distinct from Web Search — fetch retrieves a specific URL you or Claude provides, while search discovers new URLs.

Enabling Built-in Tools

Built-in tools are enabled by adding them to the tools array with their specific type identifier. No input_schema is needed — Anthropic defines the schema internally.

// API call with Code Execution tool enabled
const response = await anthropic.messages.create({
  model: "claude-sonnet-4-6",
  max_tokens: 8192,
  tools: [
    { type: "code_execution_20260120", name: "code_execution" }
  ],
  messages: [{
    role: "user",
    content: "Calculate the first 20 Fibonacci numbers and plot them."
  }]
});
// Claude writes Python code, executes it in the sandbox,
// and returns the output (including any generated charts)

Combining Multiple Built-in Tools

You can combine multiple built-in tools in a single request. For example, enabling both code execution and web search allows Claude to fetch data from the web, then process it with Python — all in a single turn.

🔒 Security Note: The code execution sandbox has no network access and no persistent filesystem. Each execution starts fresh. This prevents data exfiltration and ensures deterministic, safe execution.
SYNAPSE VERIFICATION
QUERY 1 // 3
What is the tool type identifier for Claude's built-in code execution?
python_sandbox
code_execution_20260120
execute_code
sandbox_tool
Watch: 139x Rust Speedup
Built-in Code Execution & Web Fetch | Code Execution & Web Tools — Claude Academy