The Python Sandbox
Each conversation has a separate Python sandbox container. the model can write and execute Python code independently during the response process: analyze the data you upload, draw diagrams, process tables, and even generate downloadable PDF/PPTX/DOCX/XLSX documents. The sandbox runs in parallel with the chat, and files are preserved throughout the conversation life cycle.
This page describes user-visible behavior; the deployment of the sandbox service itself. The Sandbox Deployment。
When to use Sandbox?
You don't need any special action, you can request it directly in natural language. model will call the code execution tool on its own when you encounter the following tasks:
- mathematical calculation and statistical analysis;
- Read and analyze the CSV/Excel/data files you uploaded;
- Drawing diagrams (matplotlib, etc., supporting middle text);
- Generate downloadable documents (reports, slides, tables, see "Document Generation" below);
- Multi-step data flow lines (see the data structure first, then calculate, and then produce the file).
A typical single message workflow:
你:"分析 data.csv,生成柱状图,再制作一份包含该图表的幻灯片。"
模型在同一轮内依次执行:
python_execute 读取 /workspace/uploads/data.csv,输出分析结果
image_generate 渲染柱状图,产物自动存入工作区
python_execute 用 python-pptx 把图表嵌入 slide.pptx
幻灯片以下载卡片出现在回复末尾
How to enter the sandbox
Before each code is executed, the following is automatically stored in the sandbox. /workspace/uploads/ Directory, model can be read directly by path:
| The contents | Explained |
|---|---|
| All the documents you uploaded in this conversation | Forms, CSV, PDF, images, etc., up to 20 MB per single |
| All images generated in this conversation | For example, the last step. image_generate The painted map. |
| You are entitled to use skills assets. | Located /workspace/skills/<name>/ As a file template. |
Therefore, such as "uploading files, generating models, and putting images into documents" cross-tool lines do not require you to do any intermediate operations.
Implementation process visualization
The code executed in the form of a tool call line appears in the thought process panel above the answer (see panel interaction in detail). Conversation and Model):
- Head state point: Running for the green pulse point of the tail grass, becoming a green match, failing for the red warning triangle;
- The line tail is the counting of real-time time, beats per second during the run, and the total length of time is determined after the end;
- ** Start this line. ** Above is the complete Python code written by the model (such as wide fonts, scrollable), and below is the run output of the terminal style (stdout / stderr).
A sandbox running for a long time doesn’t represent an empty wait, you can always see how it runs, how long it runs, and what code it runs.
Products: diagrams, documents and data
Write in sandbox. /workspace/outputs/ The catalogue will be ** The Art (Artifact) ** Returns in the middle of the round:
| Type of product | Method of Exhibition |
|---|---|
| Images (PNG and so on) | Direct Inbound appears in the response, click on the new tag page to see the original map |
| Other documents (PDF / PPTX / DOCX / XLSX / CSV, etc.) | A download card with the name of the file appears at the end of the answer, click to download. |
The product is permanently attached to this message: it can still be downloaded after updating pages, switching branches, sharing conversations.
Document Generation (PDF / PPTX / DOCX / XLSX)
Sandbox pre-installs the complete document generation toolkit to ask the model directly to "generate a PDF report / make a PPT / export Excel":
| formally | The way of generating | Production characteristics |
|---|---|---|
| model Writing HTML/CSS Conversions with Styles | Version control, text optional, suitable for reports / resumes / contracts | |
| PPTX (Visual Priority) | Screenshot each page in HTML design, then synthesize slides | The format is consistent with the design draft, the page is an entire page image, text cannot be edited again |
| PPTX ( can be edited) | Programming or filling of templates | Text can be edited; better performance with the template skills provided by administrators |
| DOCX | Programming generated or template filled | Text can be edited. |
| XLSX | Programming is generated. | Support for formulas, styles and data testing |
- The model that supports visual capabilities will be generated after ** Self-examination page ** (text flow, overlap, intersection), the problem is found to be automatically modified and re-produced, the quality is significantly better; the visual model is not supported.
- Sandbox has built-in CJK fonts, and charts and documents are displayed in Chinese.
- Administrators can package “Document Template + Workflow Description” as skills, load them automatically when the model generates the document, and you’ll see in the tool call line.
use_skillThe steps.
Session work area: cross-wheel duration
Sandbox is ** have state. ** The calculation environment, in conversation units:
/workspaceThe following files are retained between multiple executions, between multiple messages: the middle data written in the previous round, the third-party package installed, and the subsequent message can be used directly thereafter;- ** Session intermediate model switch, the file is still in place. ** sandbox to the platform management, not related to specific manufacturers;
- Each code execution is an independent process. ** Variable does not carry out reservations **, step-by-step data transmission please let the model end up as a file (the model itself knows this);
- The sandbox container is recovered after a period of restraint (standard 30 minutes, administrator can adjust) and the work area is automatically archived; it is automatically restored the next time it is executed. ** Totally transparent to you. **。
The administrator can use the sandbox inspector in the background. /admin/sandbox Browse and clean any conversation workspace files and check for disk occupation issues.
Overtime and resource limitations
| Restrictions are | The default value | Explained |
|---|---|---|
| Execution of single overtime | and 120 seconds. | Overtime forced to terminate this execution. Administrators can adjust on the Background Tool page for up to 10 minutes. |
| Export of text | Returned after cutting. | Extremely long stdout/stderr will be cut off to avoid the irrigation of the model. |
| Individual product documents | 20 MB | Excess documents will not be returned as products. |
| Number of single calls | 16 times | A model can run Python up to 16 times in a message (8 times in Deep Research mode) |
| CPU and memory | Container level limits | Configured by the developer to prevent single conversation from occupying the host. |
The Network Visits
The sandbox container ** Isolation from public networks. ** (No network), this is a secure base line: the model code can’t output data, can’t access the internal network.
- The content that needs to be accessed by the network is served by other tools on the platform:
web_fetchGathering the website,fetch_imageDownload the public network./workspace/uploads/Use of code; - Could it
pip installThird-party packages depend on whether the developer has configured an internal PyPI mirror white list; sandbox mirrors are pre-installed with common data science stacks such as pandas, numpy, scipy, scikit-learn, matplotlib, openpyxl, and most tasks are open-boxed.
Failure and automatic trial.
- ** The container is recycled. ** When the system detects a failed session, automatically restore the sandbox, reset all files, transparently try again, you will not see any errors;
- ** The code itself is wrong. ** The abnormality and stderr are returned to the model, and the model usually modifies the code again (within a single-round budget), you can see every attempt in the Thinking Process Panel.
- ** Execution of overtime ** The execution is forcibly killed and to the model, and the model can dismantle the small task again.
Without a sandbox.
- When the administrator has not configured the sandbox service address, the code executing tool enters ** The safety model **, can only do simple arithmetic, suitable for demonstration and development debugging; full capacity needs to deploy sandbox sidecar, see The Sandbox Deployment。
- Complementary with server-side sandbox, Python in AI response ** the code. ** In the upper right corner there is the "Run" button, executed by the Pyodide engine in the browser: instant run, zero backend dependence, output stream display, matplotlib chart display, support "stop" and overtime protection. The first run requires a CDN load engine (about 12 MB) and then permanent. The path is also defaultly blocked from network access, suitable for quick authentication of the code given by the model.