Code Sandbox
Secure code execution in an isolated environment for data analysis and script processing
The Code Sandbox enables secure execution of Python and JavaScript code in an isolated environment. The assistant can process uploaded files, run scripts, and return results as files.
Purpose
The sandbox provides a secure runtime environment for code execution without access to production systems. It is suitable for:
- Processing and analyzing Office files (Excel, Word, PowerPoint, PDF)
- Running data analysis scripts with Python (pandas, numpy, matplotlib)
- Transforming and converting file formats
- Calculations and statistical evaluations
- Creating visualizations and charts
When to Use
Suitable for:
- Analyzing CSV, Excel, or JSON data
- Data cleaning and transformation
- Statistical calculations
- Generating reports as Office documents
- Batch processing multiple files
Not suitable for:
- Permanent data storage (files are deleted after session ends)
- Accessing external APIs or web services
- Database connections
- Long-running processes
Prerequisites
- The Sandbox tool must be enabled in the assistant
- Uploaded files are available via the document list
- Python or JavaScript runtime is automatically selected
Setup
- Navigate to Assistants in the sidebar
- Select an existing assistant or create a new one
- Open the Tools tab
- Enable Code Sandbox in the tool list
- Save the changes
- Upload files in the chat to process them
Available Functions
Session Management
sandbox-create-session: Creates a new session (JavaScript or Python)
File Operations
sandbox-write-file: Writes files to the workspacesandbox-upload-file: Uploads files from chat to the sandboxsandbox-download-file: Exports files from the sandboxsandbox-list-files: Shows all files in the workspace
Code Execution
sandbox-execute-command: Executes shell commands
Python Packages
The Python environment includes pre-installed packages:
- Data Analysis: pandas, numpy, scipy
- Visualization: matplotlib, seaborn, plotly, altair
- Office Files: openpyxl, python-docx, python-pptx, PyPDF2
- Web/HTTP: requests, httpx, beautifulsoup4
- Utilities: pillow, lxml, PyYAML
Common Errors
File Paths
All files must be located in the /workspace directory. Access to other directories is not possible.
Timeout
Commands have a time limit of 30 seconds. Complex calculations should be split into smaller steps.
Network Access
The sandbox has no access to external networks. HTTP requests to external servers will fail.
Permissions and Restrictions
| Permission | Status |
|---|---|
Workspace directory /workspace | Read/Write |
| External directories | No access |
| Network/Internet | No access |
| Persistence after session | None |
| Memory | 1024 MB |
| Execution time per command | 30 seconds |
Practical Example
Prompt:
Analyze the uploaded CSV file "sales_data.csv" and create a summary with:
total revenue, top 3 products by sales volume, and monthly revenue trend
as an Excel file.Expected Result: The assistant:
- Uploads the CSV file to the sandbox
- Analyzes the data using pandas
- Calculates the requested statistics
- Creates an Excel file with summary and charts
- Provides the Excel file for download