Skip to main content
Anthropic’s Messages API supports a hosted code_execution tool. Podflare can replace the hosted execution with a Podflare microVM — same tool spec, your compute, your data plane.

Install

Use

What handle_code_execution_tool_use does

Takes an Anthropic tool_use block (SDK object or dict) with {type: "tool_use", id: ..., name: "code_execution", input: {code: "..."}} and returns the matching tool_result:
is_error: true when exit_code != 0, so Claude can pick up execution failures.

State across turns

Passing the same Sandbox into multiple handle_code_execution_tool_use calls gives Claude a persistent Python REPL across the whole conversation. That’s the single biggest win over Anthropic’s hosted container, where REPL state depends on tool version + model.

Fork-aware conversations

You can also parent.fork(n=...) between turns to let Claude explore multiple paths, pick a winner, and merge_into to commit — all transparently to the model.