WebsitePlatform Login

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

  1. The Sandbox tool must be enabled in the assistant
  2. Uploaded files are available via the document list
  3. Python or JavaScript runtime is automatically selected

Setup

  1. Navigate to Assistants in the sidebar
  2. Select an existing assistant or create a new one
  3. Open the Tools tab
  4. Enable Code Sandbox in the tool list
  5. Save the changes
  6. 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 workspace
  • sandbox-upload-file: Uploads files from chat to the sandbox
  • sandbox-download-file: Exports files from the sandbox
  • sandbox-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

PermissionStatus
Workspace directory /workspaceRead/Write
External directoriesNo access
Network/InternetNo access
Persistence after sessionNone
Memory1024 MB
Execution time per command30 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:

  1. Uploads the CSV file to the sandbox
  2. Analyzes the data using pandas
  3. Calculates the requested statistics
  4. Creates an Excel file with summary and charts
  5. Provides the Excel file for download

On this page