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

Fully sandboxed in Docker containers.



Install Docker

IPython Interpreter

Interactive, stateful execution via Jupyter/IPython kernel.


E2B Interpreter

Cloud-based sandboxing for scalable, secure remote execution.



E2B Docs


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.



from camel.interpreters import InternalPythonInterpreter

# Initialize the interpreter

interpreter = InternalPythonInterpreter()

# Code to execute (should evaluate to a string)

python_code = "'Hello from InternalPythonInterpreter!'"

# Run code

result_str = interpreter.run(code=python_code, code_type="python")
print(f"Result: {result_str}")

Subprocess Interpreter

Execute shell commands or scripts in a separate process for isolation and flexibility.
Supports multiple languages, including Bash and Python.



from camel.interpreters import SubprocessInterpreter

interpreter = SubprocessInterpreter()
shell_command = "echo 'Hello from SubprocessInterpreter!'"

result_str = interpreter.run(code=shell_command, code_type="bash")
print(f"Result: {result_str.strip()}")

Docker Interpreter

Provides full isolation—code runs in a Docker container, protecting your host system and supporting any dependencies.
Requires Docker installed.


Install Docker

from camel.interpreters import DockerInterpreter

interpreter = DockerInterpreter()
python_code_in_docker = "print('Hello from DockerInterpreter!')"

result_str = interpreter.run(code=python_code_in_docker, code_type="python")
print(f"Result: {result_str.strip()}")

IPython Interpreter (JupyterKernel)

Interactive, stateful execution in a Jupyter-like Python kernel—maintains session state and supports rich outputs.



from camel.interpreters import JupyterKernelInterpreter

interpreter = JupyterKernelInterpreter(
    require_confirm=False, print_stdout=True, print_stderr=True
)

python_code_in_jupyter_kernel = "print('Hello from JupyterKernelInterpreter!')"
result = interpreter.run(code=python_code_in_jupyter_kernel, code_type="python")
print(result)

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



from camel.interpreters import E2BInterpreter

interpreter = E2BInterpreter()
python_code_in_e2b = "print('Hello from E2BInterpreter!')"
result = interpreter.run(code=python_code_in_e2b, code_type="python")
print(result)