- Run Python code in an isolated WebAssembly environment with configurable permissions via Deno
- Access Pyodide-compatible packages
- Persist variables, imports, and function definitions across code blocks in the same conversation
- Execute calculations, data analysis, and visualizations without leaving the chat
- Skip setup entirely — runs out-of-the-box once Deno is installed on the server, no Python installation needed
Prerequisites
- User role with conversation or agent edit access
- Python Sandbox enabled in your chat or agent
How to Enable Python Sandbox
The default state of the Python Sandbox module — on or off — is defined in the project settings. If Python Sandbox is turned off by default, you can turn it on for your current conversation or agent.For a Conversation
- Go to the conversation.
- Select
+in the chat input toolbar. - Select Modules → Python Sandbox in the list.
- Toggle Python Sandbox on.

For an Agent
- Select Agents.
- Select the agent to configure, or create a new agent.
- In the TOOLS section, find MODULES.
- Find Python Sandbox. Select Show all if you do not see it immediately.
- Toggle Python Sandbox on.
- Select Save.

For agents designed for data analysis, testing, or development tasks, enabling Python Sandbox significantly enhances their problem-solving capabilities and allows them to provide executable solutions.
How Python Sandbox Works
With Python Sandbox enabled, you can:- Execute multi-line Python scripts
- Use Pyodide-compatible packages (NumPy, Pandas, Matplotlib, SciPy, scikit-learn, etc.)
- Perform complex calculations and data transformations
- Generate visualizations and charts (via matplotlib)
- Maintain variables and state between executions in the same conversation
- Handle errors gracefully and provide debugging information
- Install additional packages available in the Pyodide ecosystem
Execution Flow
When Python Sandbox is enabled, ELITEA handles code execution automatically:- Code Generation: Assistant writes Python code to solve your request.
- Sandbox Invocation: Code is sent to the Pyodide sandbox environment via Deno subprocess.
- Isolated Execution: Code runs in WebAssembly with access to Pyodide packages.
- Result Capture: Output (print statements, return values, errors) is captured.
- Response Integration: Results are formatted and returned in the conversation.
Possible Use Cases
Data Analysis and Processing
- Process datasets and calculate statistics
- Transform data structures using NumPy and Pandas
Algorithm Testing and Validation
- Test code snippets
- Validate algorithms with comprehensive test cases
- Prototype solutions before production implementation
Mathematical Computations
- Perform complex calculations
- Solve equations
- Run numerical analysis and mathematical modeling
Quick Prototyping
- Iterate rapidly on solutions without leaving the conversation
- Skip local environment setup
- Get instant feedback during development
Heavy Computational Tasks
When performing heavy computational tasks, keep in mind these limitations:- Timeouts: Very large datasets or computationally intensive operations may hit Deno timeout limits (default: 60 seconds). For production workloads with large-scale data processing, use dedicated Python environments.
- Package availability: Some Python packages are not available in Pyodide. Check the Pyodide packages list before relying on specific libraries. C-extension packages may not be supported.
- File system access: Limited file I/O capabilities due to WebAssembly sandbox restrictions. For tasks requiring extensive file operations or system-level access, consider alternative approaches.
- Network operations: Network access is configurable via Deno permissions but may be restricted depending on server configuration. External API calls and web scraping may not work as expected.
Example Scenarios
Example Conversation
Example Conversation
User: I’m writing a function to validate email addresses. Can you help me test it with various inputs to make sure it works correctly?Assistant: I’ll help you test your email validation function with a comprehensive set of test cases! Let me run various inputs through it to identify any edge cases.A Python Sandbox badge appears in the chat. Selecting it opens the executed code and its output in separate panes:Output:Great! Your improved email validation function passes all test cases. The enhancements you made successfully handle:
- Consecutive dots (rejected)
- Domain without TLD (rejected)
- Proper multi-part domains (accepted)
- Special characters in local part (accepted when appropriate)
Data Analysis with NumPy and Statistics
Data Analysis with NumPy and Statistics
Scenario: A data analyst needs to quickly analyze a dataset and calculate statistical metrics.User Request:Python Sandbox enables instant analysis without switching tools or exporting data, with results returned directly in the conversation.
“I have sales data for the past 12 months: [45000, 52000, 48000, 61000, 58000, 67000, 72000, 68000, 75000, 81000, 79000, 88000]. Calculate mean, median, standard deviation, and identify the growth trend.”Assistant Response:The assistant generates and executes Python code using NumPy to:
- Calculate mean, median, and standard deviation
- Compute month-over-month growth rates
- Identify the overall trend
- Present results in a formatted summary
Algorithm Testing with Edge Cases
Algorithm Testing with Edge Cases
Scenario: A developer wants to test a binary search implementation with various edge cases.User Request:Python Sandbox provides immediate feedback on algorithm behavior and comprehensive edge case validation.
“Test my binary search function with edge cases including empty arrays, single elements, duplicate values, and targets not in the array.”Assistant Response:The assistant:
- Generates comprehensive test cases covering all edge cases
- Executes the algorithm with each test case
- Validates correctness for each scenario
- Reports results with detailed pass/fail status and execution details
Mathematical Calculations and Equation Solving
Mathematical Calculations and Equation Solving
Scenario: A student needs to solve quadratic equations and understand the mathematical properties.User Request:Python Sandbox brings mathematical concepts to life with executable code and instant verification.
“Solve the quadratic equation 2x² - 8x + 6 = 0 and explain the solutions.”Assistant Response:Using Python Sandbox with mathematical operations:
- Calculates discriminant to determine solution types
- Computes exact solutions using the quadratic formula
- Verifies solutions by substitution
- Explains the mathematical interpretation
Best Practices
Leverage Pyodide's package ecosystem
Leverage Pyodide's package ecosystem
Pyodide supports many popular Python packages including NumPy, Pandas, Matplotlib, SciPy and scikit-learn. These packages are precompiled for WebAssembly and work seamlessly in the sandbox environment.Check the Pyodide packages list for available packages.
Break complex tasks into logical steps
Break complex tasks into logical steps
Ask ELITEA to break complex analysis into logical steps. Each code block can build on previous results since the sandbox maintains state within a conversation. This makes it easier to understand the process and identify issues.
Combine with Data Analysis module
Combine with Data Analysis module
When working with conversation attachments (CSV, Excel files), enable both Python Sandbox and Data Analysis modules. Python Sandbox provides the execution environment, while Data Analysis can help with file parsing and data structure handling.
Combine with Swarm Mode for multi-agent workflows
Combine with Swarm Mode for multi-agent workflows
Python Sandbox works seamlessly alongside Swarm Mode. In multi-agent setups, individual child agents can each have Python Sandbox enabled, allowing them to perform independent code execution tasks within the shared conversation context.
Review generated code for learning
Review generated code for learning
While Python Sandbox is secure and isolated, reviewing the code the assistant plans to execute helps you understand the approach and learn from the implementation. This is especially valuable for educational use cases.
Provide sample data for better results
Provide sample data for better results
When requesting data analysis or processing, include sample data in your message or describe the data format clearly. This helps the assistant generate more accurate and relevant code tailored to your specific use case.
Use descriptive requests for clear code
Use descriptive requests for clear code
When asking the assistant to work with data structures or algorithms, use clear descriptions and specify expected behavior. This helps generate more readable and maintainable code with appropriate variable names and comments.
Troubleshooting
Python Sandbox does not execute code
Python Sandbox does not execute code
Possible Causes:
- Python Sandbox not enabled in chat or agent configuration
- Deno not installed on the server
- Backend service unavailable or crashed
- Verify Python Sandbox is enabled in MODULES for the chat or agent
- Check that the success notification appeared when enabling the tool
- Contact system administrator to verify Deno installation on the server
- Try disabling and re-enabling Python Sandbox to reset the connection
- Refresh the page and start a new chat to reset state
- Check server logs for Deno-related errors
Package import fails
Package import fails
Possible Causes:
- Package not available in the Pyodide ecosystem
- Package not preloaded in the sandbox environment
- Typo in package name
- Verify the package is listed in the Pyodide packages list
- Use alternative packages that are Pyodide-compatible
- Check the error message for suggestions on alternative packages
- Some pure Python packages may need to be loaded dynamically
Code execution times out
Code execution times out
Possible Causes:
- Long-running computations exceeding the timeout limit
- Infinite loops in the code
- Large dataset processing taking too long
- Break large computations into smaller chunks that execute faster
- Optimize algorithms to reduce time complexity
- Use iterative processing for large datasets
- Review code for potential infinite loops or performance bottlenecks
- Consider using a local Python environment for heavy computations
Session does not preserve variables between executions
Session does not preserve variables between executions
Possible Causes:
- Conversation reset or page refresh
- Backend session expiration
- An error in a previous code execution corrupted the session state
- Re-run initialization code to redefine variables and imports
- Avoid page refreshes during stateful work sessions
- Check for errors in previous executions that may have corrupted the state
- Use explicit variable definitions in each code block for critical values
- Start a new conversation if the session state is corrupted
Network requests fail
Network requests fail
Possible Causes:
- Network access not allowed by Deno permissions
- Firewall blocking outbound connections from the sandbox
- Using the
requestslibrary instead ofhttpx.AsyncClient
- Ensure network access is configured in the sandbox settings (
allow_net=True) - Use
httpx.AsyncClientfor HTTP requests instead of therequestslibrary - Contact the administrator to check the Deno network permission configuration
- Check if specific domains need to be whitelisted in the Deno settings