podflare_code_interpreter() helper returns an OpenAI Agents SDK-compatible tool that lazily creates a Podflare sandbox on the first invocation and reuses it for every subsequent code execution in the same run. You install two packages, pass the tool to your Agent, and call close_podflare_sandbox() when you’re done.
Install
Quickstart
Create the tool
Import
podflare_code_interpreter and call it to get a ready-to-use tool
object. No sandbox is created yet — it spins up on the first agent invocation.Run the agent
Run the agent with
Runner.run. The tool intercepts run_code calls,
executes the code inside a Podflare sandbox, and returns stdout,
stderr, and exit_code to the model.Full example
How it works
On eachrun_code invocation the tool calls sandbox.run_code(code, language) on the underlying Sandbox and returns a dict with three keys:
| Key | Type | Description |
|---|---|---|
stdout | str | Captured standard output |
stderr | str | Captured standard error |
exit_code | int | Process exit code |
Options
Pass keyword arguments topodflare_code_interpreter() to override the host or select a specific sandbox template:
If
host is not provided, the SDK reads the PODFLARE_HOST environment
variable and falls back to http://127.0.0.1:7070 for local development.Cleanup
The tool object exposesclose_podflare_sandbox(). Call it after every agent run to destroy the VM and release the slot back to the pool.