Interpreters
Execute code safely and flexibly with CAMEL’s suite of interpreters: local, isolated, and cloud-based execution environments.
Interpreters allow CAMEL agents to execute code snippets in various secure and flexible environments—from local safe execution to isolated Docker containers and managed cloud sandboxes.
What are Interpreters?
Interpreters empower agents to run code dynamically—enabling evaluation, testing, task automation, and rich feedback loops. Choose your interpreter based on trust, isolation, and supported languages.
Internal Python Interpreter
Fast, local, safe execution for trusted Python code within the agent process.
Subprocess Interpreter
Isolated execution in a subprocess. Supports Bash, Python, shell scripts.
Docker Interpreter
IPython Interpreter
Interactive, stateful execution via Jupyter/IPython kernel.
E2B Interpreter
Internal Python Interpreter
Fast, local, and safe—executes trusted Python code directly within the CAMEL agent process.
Note: Only expressions (not statements) are allowed in strict safe mode; for output, your code should evaluate to a string.
Subprocess Interpreter
Execute shell commands or scripts in a separate process for isolation and flexibility.
Supports multiple languages, including Bash and Python.
Docker Interpreter
Provides full isolation—code runs in a Docker container, protecting your host system and supporting any dependencies.
Requires Docker installed.
Install Docker
IPython Interpreter (JupyterKernel)
Interactive, stateful execution in a Jupyter-like Python kernel—maintains session state and supports rich outputs.
E2B Interpreter (Cloud Sandbox)
Run code in a secure, scalable, cloud-based environment—no local setup needed, great for running untrusted or complex code.
E2B Documentation
Best Practices
Best Practices
- Use InternalPythonInterpreter only for trusted and simple Python code.
- Subprocess and Docker interpreters are better for code isolation and dependency management.
- Prefer Docker for any untrusted code or when extra libraries are needed.
- E2B Interpreter is ideal for scalable, managed, and safe cloud execution—no local risk.
- For interactive, multi-step logic, leverage JupyterKernelInterpreter for persistent session state.
- Always validate and sanitize user inputs if agents dynamically construct code for execution.
Troubleshooting & Tips
Troubleshooting & Tips
- If Docker isn’t working, verify your Docker daemon is running and you have the correct permissions.
- For E2B, check API key and account limits if code doesn’t execute.
- Long-running scripts are best managed in Subprocess or Docker interpreters with timeout controls.
- Use session resets (where supported) to avoid cross-task state bleed in Jupyter/IPython interpreters.