Skip to main content
If your agent is going to run code written by an LLM, you need a sandbox. Podflare ships small adapters for the three frameworks most teams use. Each one is ~30 lines of glue; you don’t write the glue yourself.

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 between run_code calls — filesystem and Python variables. This is how you build a “chat with a notebook” UX:
Set a generous idle_timeout_seconds so the sandbox survives between user messages. Paid tiers let you go up to 2 h — enough for long interactive sessions.

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 install is 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 / using semantics do this automatically.