What it does
When enabled, the agent can call OpenAI’s hosted python tool to write and run Python in an ephemeral container. Use it when you need exact results that language models alone cannot guarantee — for example splitting spreadsheet rows into precise batches, computing statistics, or transforming tabular data. Important: Prefer File Tools (write_file) for deliverable PDF/DOCX/XLSX/CSV when the model can print text content. If the model still saves files inside the sandbox and cites them, Fetch Hive automatically downloads those container files and stores them as workspace assets (rewriting sandbox: links to real download URLs).
Requirements
- Agent provider must be OpenAI.
- The tool is not enabled by default — add it from the tool picker.
Adding the tool to an agent
- Open an agent in the editor.
- Click the button with the tooltip Add MCP Tool or Sub Agent.
- In MCP Tools, click OpenAI Code Interpreter.
How it works with File Tools
Typical flow for spreadsheet slicing:- Document attachments (csv/xlsx/pdf/docx/txt/md) on the turn are auto-mounted into the Code Interpreter sandbox at
/mnt/data/<name>for both hosted and BYOK OpenAI keys (up to 10 files, 50 MB each). The sandbox has no internet access — the agent should read mounted files directly, not fetch URLs. - Code Interpreter runs Python to slice or transform the data and prints CSV/JSON.
- The agent calls
write_filewith that text to create downloadable XLSX/CSV assets.
/mnt/data and links them with sandbox: URLs, Fetch Hive captures those container files via OpenAI’s Containers API and promotes them to real workspace assets (same storage path as write_file). Prefer write_file when possible. Mounted input files are re-uploaded to OpenAI each turn (1-hour expiry) and do not persist across turns.
Limitations (v1)
- OpenAI only — Anthropic and xAI code-execution tools are not wired yet.
- No multi-turn Python state — each agent turn starts a fresh container; variables from a previous turn do not persist.
- Fixed 1 GB memory — higher OpenAI memory tiers are not exposed yet.
- Attachment mount caps — at most 10 document attachments / 50 MB each are mounted per turn; larger or excess files are skipped (File Tools
read_fileremains available). - Each Code Interpreter call counts as 1 task credit (same pattern as GPT Search). Container-minute spend is tracked only as estimated operator metadata (
estimated: true) on the completion — not a separate user-facing USD line item. On hosted keys, OpenAI container minutes are absorbed by Fetch Hive. Mounting attachments via the Files API does not add extra task credits.
Use cases
- Exact row slicing (rows 1–50, 51–100, …) before exporting XLSX batches.
- Numerical / statistical calculations that must be precise.
- Parsing or reshaping tabular data before writing a file.
Notes
- Use Testing with Chat to watch Code Interpreter and File Tools calls during a conversation.
- To add or remove tools from an agent, see Creating and Configuring.
- See also File Tools for creating downloadable assets.

