Installation
Install the executor you need:Docker Command Line Executor
TheDockerCommandLineCodeExecutor provides the highest level of safety by running code in isolated Docker containers.
Basic Usage
Configuration Options
string
default:"python:3-slim"
Docker image to use for code execution
string
Name for the Docker container. Auto-generated if not provided
int
default:"60"
Timeout in seconds for code execution
Path | str
Working directory for code execution. Uses a temporary directory if not provided
Path | str
Directory to bind mount into the container. Defaults to
work_dirbool
default:"true"
Automatically remove container when stopped
bool
default:"true"
Automatically stop container on exit
string
default:"functions"
Module name for custom functions
Advanced Configuration
GPU Support
Enable GPU access in containers:Custom Volumes
Mount additional volumes:Network Configuration
Configure container networking:Initialization Commands
Run setup commands before each execution:Docker Jupyter Executor
Execute code in a Jupyter kernel running inside Docker:Benefits of Jupyter Execution
- Persistent state: Variables and imports persist between executions
- Rich output: Supports plots, HTML, and other rich media
- IPython features: Magic commands and special syntax
Example with Matplotlib
Local Command Line Executor
Basic Usage
Configuration Options
int
default:"60"
Timeout in seconds for code execution
Path | str
Working directory. Defaults to a temporary directory
string
default:"functions"
Module name for custom functions
bool
default:"true"
Automatically clean up temporary files after execution
SimpleNamespace
Virtual environment to use for execution
Virtual Environment Support
Run code in a specific virtual environment:Custom Functions
Provide reusable functions to code executors:Supported Languages
All executors support:- Python:
.pyfiles - Bash/Shell:
.shfiles (languages:bash,shell,sh) - PowerShell:
.ps1files (languages:pwsh,powershell,ps1)
Python Execution
Shell Script Execution
PowerShell Execution
File Handling
Executors support file creation and modification:Error Handling
Handle execution errors:Security Best Practices
Use Docker in Production
Always use Docker-based executors for production:Set Resource Limits
Limit container resources:Use Read-Only Mounts
Mount sensitive data as read-only:Restrict Network Access
Disable network for untrusted code:Context Manager Usage
Use context managers for automatic cleanup:Integration with Agents
Use executors with coding agents:Troubleshooting
Docker Not Running
Permission Denied
Timeout Errors
Next Steps
Model Clients
Configure LLM providers
Tools
Add tools and capabilities