đ« CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
title: "Runtimes" description: "Flexible, secure, and scalable code execution with CAMELâs runtime environments: guardrails, Docker, remote, and cloud sandboxes." icon: server
doc_code_map: - "camel/runtimes/**/*.py"
CAMELâs runtime module enables the secure, flexible, and isolated execution of tools and code. Runtimes allow agents to safely run functions in controlled environmentsâfrom in-process security checks to Docker isolation and remote/cloud sandboxes.
What are Runtimes?
Modern agent systems often require more than a simple interpreter.{" "} Runtimes provide safe, scalable execution via guardrails, isolation, or remote/cloud endpointsâideal for complex or untrusted code.- LLM-based risk scoring (1=safe, 3=unsafe)
- Threshold control for blocking risky calls
- Pre-configured safety system prompt/tool
- Sandbox tool execution for safety
- FastAPI server for tool endpoints
- Ubuntu flavor supports .py script execution, env vars, and more
- Tool execution via FastAPI HTTP APIs
- Distribute compute and offload risky code
- Easy integration with remote endpoints
- Secure remote sandbox per tool
- Upload, run, and manage source code safely
- Automated input/output handling
Runtime Interface
All runtimes inherit from BaseRuntime, which defines core methods:
add(funcs): Register one or moreFunctionToolobjects for executionreset(): Reset the runtime to its initial stateget_tools(): List all tools managed by the runtime
Quick Start Example: RemoteHttpRuntime
Easily run tools in a remote FastAPI-based runtimeâgreat for scaling, isolation, and experimentation.```python from camel.runtimes import RemoteHttpRuntime from camel.toolkits import MathToolkit
if name == "main": runtime = ( RemoteHttpRuntime("localhost") .add(MathToolkit().get_tools(), "camel.toolkits.MathToolkit") .build() )
print("Waiting for runtime to be ready...")
runtime.wait()
print("Runtime is ready.")
# There are more tools imported from MathToolkit.
# For simplicity, we use only "add" tool here
add = runtime.get_tools()[0]
print(f"Add 1 + 2: {add.func(1, 2)}")
# Example output:
# Add 1 + 2: 3
</Card>
## Runtime Types: Key Features
<AccordionGroup>
<Accordion title="LLMGuardRuntime">
<ul>
<li>Evaluates risk before executing functions or tool calls (risk scores 1-3)</li>
<li>Customizable LLM-driven safety logic</li>
<li>Blocks or allows function execution based on threshold</li>
</ul>
</Accordion>
<Accordion title="DockerRuntime / UbuntuDockerRuntime">
<ul>
<li>Runs CAMEL tools/agents in Docker containers for isolation and reproducibility</li>
<li>UbuntuDocker flavor adds support for full script execution and system-level configuration</li>
<li>Preconfigures <code>PYTHON_EXECUTABLE</code>, <code>PYTHONPATH</code>, and more for custom envs</li>
</ul>
</Accordion>
<Accordion title="RemoteHttpRuntime">
<ul>
<li>Executes registered tools on a remote FastAPI server via HTTP endpoints</li>
<li>Ideal for distributed, scalable, or cross-server tool execution</li>
</ul>
</Accordion>
<Accordion title="DaytonaRuntime">
<ul>
<li>Runs code in a managed, remote cloud sandbox using Daytona SDK</li>
<li>Uploads user code, executes with input/output capture</li>
<li>Safety and resource guarantees from cloud provider</li>
</ul>
</Accordion>
</AccordionGroup>
## More Examples
Youâll find runnable scripts for each runtime in <b>[examples/runtimes](https://github.com/camel-ai/camel/tree/master/examples/runtimes)/</b> in our main repo.
Each script demonstrates how to initialize and use a specific runtimeâperfect for experimentation or production setups.
## Final Note
The runtime system primarily sandboxes <code>FunctionTool</code>-style tool functions.
For agent-level, dynamic code execution, always consider dedicated sandboxingâsuch as <b>UbuntuDockerRuntime</b>âs <code>exec_python_file()</code>âfor running dynamically generated scripts with maximum isolation and safety.