---
title: "Code Sandbox"
description: "Isolated Python and JavaScript execution for file analysis, transformations, and computations (secure, deleted after use, EU-hosted)."
canonical_url: "https://meingpt.com/en/docs/platform/code-sandbox"
language: en
---

# Code Sandbox

The **Code Sandbox** is a built-in tool that lets an assistant run real code (Python or JavaScript) instead of just generating text answers. It's especially relevant for tasks the model alone can't reliably handle: exact calculations, processing of Excel/CSV files, file generation.

## Why a sandbox?

A language model like GPT or Claude is at its core a **text generator**: it reads and writes text. Three things it can't reliably do on its own: but that come up constantly in real work:

1. **Read binary files**: an `.xlsx` file is not text, it's a binary format. The model only sees what was extracted as text beforehand.
2. **Calculate reliably**: for larger multiplications or multi-step computations, the model can miscalculate, because it "guesses" numbers based on probability.
3. **Complex data analysis**: pivots, filters, aggregations across thousands of rows are simply impossible with text processing alone.

The sandbox solves this by giving the model **its own small computer**. Instead of estimating the answer textually, the model writes Python code that runs on this machine and returns the real result.

## How a sandbox call flows

**File upload**: You upload a file to the chat (e.g. an Excel sheet, a CSV, a Python script).

**Task recognition**: The assistant detects from your question that the file needs to be processed directly.

**File loaded into the sandbox**: The original file (not just extracted text) is copied into the sandbox workspace.

**Code generation**: The assistant writes Python code that solves the task, e.g. `import pandas as pd; df = pd.read_excel('file.xlsx'); print(df['Revenue'].mean())`.

**Execution**: The code runs in the isolated environment. The common libraries are **preinstalled** (incl. `pandas`, `numpy`, `matplotlib`, `openpyxl`) – no `pip install` at the start of a session.

**Result back**: You get the result in chat, plus optionally generated files (e.g. a modified `.docx` or a PNG chart) as a file card with preview and download actions, if the format supports preview (currently, for example, not for Excel files or ZIP archives - only download is available for those).

**Images, screenshots, and individual PDF pages** are recognized **natively** – the model sees the image content directly instead of guessing it via OCR. You can also hand **multiple files** to the sandbox in a single step.

## With sandbox vs. without sandbox

| Use case | Without sandbox | With sandbox |
|---|---|---|
| **Excel analysis** ("Compute the average of the Revenue column") | Model guesses the numbers, often inaccurate | Python reads the file and calculates exactly |
| **Edit Excel** ("Add a margin column") | Not possible: the model can't write a file back | The file is modified, formatting and formulas are preserved, you receive the edited `.xlsx` as a download |
| **Charts from data** | Only simple text diagrams (Mermaid) | Real PNG charts via `matplotlib` |
| **Run code** | Model can show the code but not execute it | Code is run, output comes back |
| **Large tables** (50,000+ rows) | Doesn't fit in the model's context | Python handles arbitrarily large files |

## What you see in the chat

From a user perspective, this all happens automatically. You see:

- A short **loading indicator** while the sandbox starts and the code runs (typically seconds, for complex analysis 10–30 seconds)
- Optionally a display of the **executed code**: depending on the workspace setting
- The **result** as text in the chat or as a **file card** with preview and download actions for generated files
- On errors, an error message; the assistant often tries an alternative approach automatically

## Security and hosting

The sandbox is an **isolated virtual machine**: code running inside it has **no access** to other customer data, the internet, or the meinGPT system. Even if faulty or malicious code were executed, it could do no damage outside the sandbox.

- **Hosting:** Frankfurt, Germany (Unikraft Cloud), isolated EU cloud setup
- **Lifetime:** A sandbox session is bound to your chat. Within the session, files remain in the workspace — across multiple tool calls and messages. When idle, the VM pauses (scale-to-zero); the attached volume keeps the files until the session ends
- **Important:** The sandbox session is bound to the chat, but not available over long periods. If you keep working in the same chat over multiple days, the session can be automatically terminated in between (e.g. after a longer period of inactivity) — in that case the volume holding the workspace files is also deleted, and your next message starts a new, empty sandbox. There is currently **no warning in the chat** before this happens. For multi-day projects with intermediate results, we recommend downloading important intermediate files regularly rather than relying on the workspace persisting across multiple days.
- **Data flow:** Original files are temporarily loaded into the sandbox for processing and deleted immediately after execution. For on-premise customers it's important to note that sandbox processing happens in the cloud
- **Internet access:** disabled by default
- **Script libraries:** a broad stack is **preinstalled** (no `pip install` needed). Python for data analysis (`pandas`, `numpy`, `matplotlib`, `pyarrow`), Excel editing and creation (`openpyxl`, `XlsxWriter`), PDF (`PyMuPDF`, `pdfplumber`, `pypdf`, `PyPDF2`, `pdfminer.six`, `pdf2image`, `reportlab`, `fpdf2`), Office documents (`python-docx`, `python-pptx`), web/HTML (`requests`, `beautifulsoup4`, `lxml`, `flask`), images (`Pillow`; OCR via `pytesseract` as a fallback); for Node incl. SheetJS (`xlsx`), `pdfkit`, `docx`, `pptxgenjs` plus ZIP operations (`archiver`, `unzipper`)
- **Office skills baked into the image:** for `.xlsx`, `.docx`, and `.pptx`, short skill guides ship directly inside the runtime — the assistant gets not just the libraries but also the right approach hints (e.g. "preserve formatting when editing, work with styles when generating")

## Current methods

When the Code Sandbox connector is attached to an assistant, the following methods are available. A sandbox session is created implicitly on the first tool call in a chat (matching runtime: Python or Node); there is no separate "start session" method.

- `sandbox-write-file`: write a chat file into the sandbox
- `sandbox-upload-file`: upload an external file
- `sandbox-download-file`: fetch a generated file back into the chat
- `sandbox-view-file`: let the model look at an image or PDF page from the workspace directly (instead of OCR)
- `sandbox-read-file`: read a text file from the workspace with line-level offset/limit
- `sandbox-execute-command`: execute a command inside the sandbox
- `sandbox-mount-skill`: make a prebuilt skill (e.g. `xlsx`, `docx`, `pptx`) available in the running session
- `sandbox-create-skill`: save a workflow proven in the session as a reusable skill

## Limits

- **Session-bound:** The workspace belongs to your chat. If you start a new chat, the sandbox begins fresh — files from another chat aren't available there
- **Time limit per execution:** A single sandbox command (e.g. via `sandbox-execute-command` or `sandbox-run`) runs for up to 2 minutes by default, and 5 minutes maximum in any case. If a command isn't done by then, it's cancelled and reported as failed
- **Split complex workflows:** For very long compute pipelines — like generating a full interactive HTML dashboard from a large Excel file in one step — break the task into smaller steps (prepare data → compute chart data → assemble HTML) instead of one giant call. This also keeps you safely under the per-execution time limit above
- **Limited memory:** each sandbox VM currently has 1 GB of RAM. Memory-intensive operations on very large tables — such as generating a PDF from a large data table — can fail as a result. If that happens, reduce the data volume first (e.g. filter columns/rows) or split the task into smaller steps
- **No outbound internet access from the sandbox**: external APIs are connected via connectors or skills, not directly from code
- **Base image ships without `curl`; the `apt-get` index is empty until `apt-get update`:** The preinstalled libraries (see [Security and hosting](#security-and-hosting)) cover the common file workflows; beyond that, the base image is intentionally minimal. `curl` isn't preinstalled, for example, and the `apt-get` package index is empty until you explicitly run `apt-get update`. Larger `apt-get install` operations can hit the 1 GB RAM limit and leave `dpkg` in an incomplete state that needs a manual `dpkg --configure -a` before further installs will work

## Frequent questions

### Why does a sandbox response take longer than a regular chat answer?

The sandbox needs to start, code needs to be written and executed. That's more work than plain text generation. Complex analyses take 10–30 seconds, that's normal.

### Why is the result sometimes still wrong?

The assistant writes the code. If it misinterprets the data structure or picks the wrong approach, the result can be wrong. Tip: spot-check the result, and when in doubt, sharpen the prompt with concrete constraints (e.g. "filtered on column X = Y").

### Which file types work reliably?

Excel (`.xlsx`, `.xls`), CSV, and Python scripts generally work reliably for simple to moderately complex spreadsheets. For **macro-enabled workbooks (`.xlsm`)**, very large named ranges, deeply nested formula chains, or workbooks with many linked helper sheets, automatic extraction can miss or truncate individual tables, factors, or conditions – the preinstalled libraries (`openpyxl`, `XlsxWriter`) do not execute or interpret VBA macros themselves. For business-critical calculations, we recommend spot-checking the result against the original file before using it in production. PDF and Word can be parsed with the preinstalled libraries; heavily formatted documents may leave gaps. The same goes in reverse for generation: when a skill fills a Word template, the text follows the template's existing styles – exact adherence to your brand guidelines isn't automatically checked, so spot-checking the result before sending it is recommended. The template also needs to be a plain `.docx` file – the skill cannot open macro-enabled `.docm` files, and in that case generates a new document from scratch instead of filling the actual template. Images, screenshots, and individual PDF pages are recognized by the model **natively** — even scanned or photographed PDFs are looked at directly by the model (`sandbox-view-file`), which usually beats classic OCR. `pytesseract` is available as a fallback for purely text-heavy scans.

### Is this GDPR-compliant?

Yes. The sandbox is isolated (no access to other data), runs in Frankfurt/Germany (Unikraft Cloud), and is released when your chat session ends. Original files are temporarily loaded into the sandbox. If that matters for your compliance setup, get in touch and we'll walk through the data flow in detail.

## Where to go next

- **[Skills](/en/docs/platform/skills)**: your own code packages with libraries and external API access
- **[Assistants](/en/docs/platform/assistants)**: how to attach the Code Sandbox to an assistant as a tool
