Best sandbox · Data analysis
The best sandbox for data analysis agents
Updated
A data analysis agent writes pandas, runs it on your files and draws charts. The sandbox has to hold real, often private, data while running code nobody reviewed, so the network should be closed, the data should go in and results come out through calls you control, and the whole machine should be easy to throw away. kosa8 runs the analysis in a microVM on your own machine with egress="deny", takes files in and out through the SDK, and returns matplotlib charts as PNG bytes.
01What a data analysis agent needs from a sandbox
The risk in analysis is less a deleted file than a leaked one: a snippet that uploads the CSV it was given, or a prompt in a cell value that tells the agent to. The other needs are practical: the right libraries already installed, enough memory for the dataset, and outputs (tables and charts) that come back cleanly.
02Checklist for choosing one
- No network. Nothing leaves, DNS included.
- Data stays where it is allowed to be. Your machine or your servers for private data.
- Libraries preinstalled. So the sandbox never needs the network to work.
- Files in, results out. Through explicit calls you can log.
- Charts returned as images. Not left as files to fish out.
- Memory you can size. For the dataset at hand.
- Throwaway. Delete the machine and the copy of the data goes with it.
03How kosa8 meets it
Build a template with your libraries once. The build has network; the sandboxes made from it need none.
FROM python:3.12-slim RUN pip install --no-cache-dir pandas matplotlib
kosa8 template build analysis-env ./analysis-env
from kosa8 import Kosa8Client client = Kosa8Client() client.create_sandbox(name="analysis", template="analysis-env", egress="deny", mem_mb=4096, auto_stop_min=30) sb = client.sandbox("analysis") sb.write_file("sales.csv", open("sales.csv", "rb").read()) r = sb.run_code(""" import pandas as pd, matplotlib.pyplot as plt df = pd.read_csv("sales.csv") df.groupby("region")["revenue"].sum().plot.bar() plt.savefig("by_region.png") print(df.describe()) """, timeout_s=120) print(r.stdout) for a in r.artifacts: # charts come back as PNG bytes open(a.name, "wb").write(a.data) sb.delete()
Hand run_code to your model as a tool and it can iterate on the analysis while the data never leaves the sandbox except through read_file calls you make. Every action is in the audit log.
04When another option fits better
- Data already in a warehouse. For large tables, push the query to the warehouse's own compute rather than copying data into a sandbox.
- Shared notebooks. If people collaborate on the analysis, a hosted notebook service suits that better; it is not a boundary for untrusted code.
- Hosted code execution from a model provider. Fine for data that may leave your environment, with nothing to run yourself.
05FAQ
Can the agent upload my data anywhere?
Not from a sandbox created with egress="deny": nothing leaves, DNS included, and the policy is enforced on the host where root in the guest cannot lift it.
How do charts come back?
Figures a Python snippet draws with matplotlib are returned in CodeResult.artifacts as PNG bytes, with a name and type.
How big a dataset can it handle?
As big as the memory and disk you give the sandbox (mem_mb, and --disk on the CLI) and your machine has. kosa8 has not published data-size benchmarks.
Can I run it on kosa8 Cloud?
Yes, with Kosa8Cloud and the python template; for private data, running locally keeps it on your hardware.
06Get started
Install kosa8 on a Mac, Linux or Windows (WSL2) machine, or make an account and run the same sandboxes on kosa8 Cloud.
07Sources
- kosa8 docs: Python quickstart
- kosa8 docs: Network
- kosa8 docs: Agent frameworks (Python)
- kosa8 command reference
Related
- How do I build a self-hosted code interpreter for my LLM?
- The best sandbox for an LLM code interpreter
- How do I restrict an AI agent's network access to an allow-list?
- How do I run an AI agent sandbox on my own machine instead of the cloud?
- All best-sandbox pages
Updated 2026-11-14