Use case
You have a dataset and want an agent to do the analysis — load, summarize, visualize, report — without the analysis tooling ever running on your host machine. The agent gets a fresh microVM with pandas and matplotlib, a locked-down network (only the OpenAI API plus one dataset host), and PII redaction on every outbound call.Template
python — ships with Python 3.11, pip, common scientific packages
on request. PII scanner and injection defense run at the sandbox’s
edge proxy.
Run it
Security policy
rehydrate_response=True matters here: the analyst’s pandas output
may echo back PII that the scanner redacted on the way out. The
edge proxy restores the originals before the sandbox receives the
response, so the agent’s code sees a normal API response, not a
pile of REDACTED_* tokens.
What the agent does
printenvto confirm the sandbox-provided config variables.curlthe CSV into/workspace/data.csv.pip install pandas matplotlib.- Generate a script that loads, summarizes, plots, and writes
/workspace/report.md. - Return the report path. The Python driver then reads
/workspace/report.mdback through the sandbox API.
Expected output
Why filesystem isolation matters here
Every artifact (downloaded CSV, pip cache, plot, report) lives in a fresh overlay that’s discarded whenclient.delete(session=...)
runs. The next caller gets a clean VM with none of this caller’s
state. You don’t need to pre-provision scratch directories or clean
them up — the sandbox lifecycle handles it.
Full source
Seecookbook/openai_agents_data_analyst.py in the repo.