Claude — code_execution tool
Anthropic’s Messages API exposes a hosted code_execution tool. You
can replace the hosted execution with your own sandbox — same tool
spec, your compute. The handle_code_execution_tool_use helper
consumes a tool_use block and returns the matching tool_result
block.
When to reach for this
- You already use Anthropic and want the native tool contract.
- You need data-plane isolation — Anthropic’s hosted code_execution runs on their infra; with Podflare it runs on yours.
- Per-customer quota / billing attribution lives on your API key, not Anthropic’s.
OpenAI Agents SDK
The Agents SDK accepts any function tool.podflare_code_interpreter()
(Python) and podflareCodeInterpreter() (TypeScript) return one.
Vercel AI SDK
podflareRunCode() returns a shape compatible with tool() from the
ai package.
TypeScript
Persistent REPL pattern
State survives betweenrun_code calls — filesystem and Python
variables. This is how you build a “chat with a notebook” UX:
Pitfalls
- Don’t share a sandbox across users. One per session is the right granularity. Fork if you need parallel branches within one user’s session.
- Install packages once, reuse many. A
pip installis cheap but not free (~100–500 ms). Cache the sandbox and install on first run; subsequent turns hit the already-installed version. - Close sandboxes when done. Idle timeout catches forgotten
ones but you’ll burn budget until it fires. SDK’s
with/usingsemantics do this automatically.

