Overview
Key Features:- Secure Execution: Code runs in an isolated WebAssembly environment with configurable permissions via Deno
- Rich Python Ecosystem: Access to Pyodide-compatible packages including NumPy, Pandas, Matplotlib, SciPy, and more
- Stateful Sessions: Variables, imports, and function definitions persist across code blocks within the same conversation
- Instant Results: Execute calculations, data analysis, and visualizations without leaving the chat
- No Setup Required: Works out-of-the-box once Deno is installed on the server—no Python installation needed
Prerequisites
- Permission Level: User role with conversation or agent edit access
- Use Case: Tasks involving Python code execution, data analysis, calculations, or algorithm validation
How It Works
Traditional Approach vs Python Sandbox| Aspect | Without Python Sandbox | With Python Sandbox |
|---|---|---|
| Code Execution | Copy code, run locally or in external tool | Execute code directly in conversation |
| Environment Setup | Install Python, packages, dependencies | No setup—Pyodide runs in WebAssembly via Deno |
| Data Sharing | Export/import files between tools | Process data within conversation context |
| Results | Manual copy-paste of outputs | Automatic integration of results into chat |
| Security | Depends on local environment | Isolated sandbox with restricted Deno permissions |
- 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
With Python Sandbox enabled, the assistant 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 Pyodide ecosystem
Enabling Python Sandbox in Conversations
Enable Python Sandbox for code execution in your conversations.- Navigate to your conversation.
- Locate the chat input toolbar at the bottom of the screen.
- Click the Internal Tools icon (value icon) next to the attachment button.
- In the popup, find Python sandbox in the list.
- Click the toggle switch next to “Python sandbox” to enable it.
- A success toast notification appears: “Internal tools configuration updated”.
- Click anywhere outside the popup to close it.

The Python Sandbox setting persists for the conversation. You can toggle it on/off at any time during the conversation.
Enabling Python Sandbox in Agent Configuration
Configure Python Sandbox as part of an agent’s default configuration.- Navigate to Agents in the main menu.
- Select the agent you want to configure or create a new agent.
- On the Configuration tab, scroll down to the TOOLKITS section.
- Within the TOOLKITS section, locate the INTERNAL TOOLS subsection.
- Find the Python sandbox toggle. If it is not visible, click Show all to expand the full list of internal tools.
- Click the Python sandbox toggle to enable it.
- Click Save at the top of the configuration page to persist the change.
- New conversations created with this agent will have Python Sandbox enabled by default.

Using Python Sandbox
Once enabled, Python Sandbox works seamlessly during conversations. The assistant automatically uses it to execute code when needed to solve your requests.What Happens Behind the Scenes
- Code Generation: The assistant writes Python code to address your request
- Automatic Execution: Code is executed in the Pyodide sandbox without manual intervention
- Result Processing: Output, errors, and visualizations are captured
- Integrated Response: Results are presented naturally in the conversation flow
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.[Tool Used: pyodide_sandbox]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, scikit-learn, and more. Check the Pyodide packages list to see what’s available. These packages are precompiled for WebAssembly and work seamlessly in the sandbox environment.
Break Complex Tasks into Logical Steps
Break Complex Tasks into Logical Steps
For better readability and debugging, ask the assistant 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.
Use Python Sandbox for Prototyping and Testing
Use Python Sandbox for Prototyping and Testing
Perfect for quickly testing code snippets, validating algorithms, or prototyping data transformations before implementing in production. Get immediate feedback without setting up local environments or installing dependencies.
Combine with Data Analysis Internal Tool
Combine with Data Analysis Internal Tool
When working with conversation attachments (CSV, Excel files), enable both Python Sandbox and Data Analysis internal tools. 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.
##Performance Considerations
Data Analysis and Processing
- Excellent for processing datasets, calculating statistics, and transforming data structures using NumPy and Pandas.
- Perfect for testing code snippets, validating algorithms with comprehensive test cases, and prototyping solutions before production implementation.
- Ideal for complex calculations, equation solving, numerical analysis, and mathematical modeling.
- Enables rapid iteration on solutions without leaving the conversation or setting up local environments. Instant feedback loop for development.
Troubleshooting
Python Sandbox Not Executing Code
Python Sandbox Not Executing Code
Possible Causes:
- Python Sandbox not enabled in conversation or agent configuration
- Deno not installed on the server
- Backend service unavailable or crashed
- Verify Python Sandbox is enabled in the Internal Tools popup or agent configuration
- 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 conversation to reset state
- Check server logs for Deno-related errors
Package Import Errors
Package Import Errors
Possible Causes:
- Package not available in 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
- For pure Python packages, some may need to be loaded dynamically
Code Execution Timeout
Code Execution Timeout
Possible Causes:
- Long-running computations exceeding 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 local Python environment for heavy computations
Stateful Session Not Preserving Variables
Stateful Session Not Preserving Variables
Possible Causes:
- Conversation reset or page refresh
- Backend session expiration
- Error in previous code execution corrupted 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 state
- Use explicit variable definitions in each code block for critical values
- Start a new conversation if session state is corrupted
Network Request Failures
Network Request Failures
Possible Causes:
- Network access not allowed by Deno permissions
- Firewall blocking outbound connections from sandbox
- Using
requestslibrary instead ofhttpx.AsyncClient
- Ensure network access is configured in sandbox settings (
allow_net=True) - Use
httpx.AsyncClientfor HTTP requests instead of therequestslibrary - Contact administrator to check Deno network permission configuration
- Check if specific domains need to be whitelisted in Deno settings
- Pyodide Documentation - Learn about Python in WebAssembly
- Pyodide Packages - Available Python packages and compatibility
- Deno Documentation - Deno runtime and security model
- Data Analysis Internal Tool - Complementary tool for working with uploaded CSV/Excel files
- Swarm Mode Internal Tool - Multi-agent collaboration for complex workflows
- Smart Tools Selection Internal Tool - Intelligent toolkit selection and management
- Planner Internal Tool - Task planning and execution coordination
- Agent Configuration - Complete guide to configuring agents and toolkits
- Conversation Management - Managing conversations and settings
- Toolkits Overview - Understanding toolkits and internal tools