Skip to content

armgit / camel

Public Imported from GitHub
0

đŸ« CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

5.1 KB
Raw Blame

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.
Guardrail layer for safe function execution.
  • LLM-based risk scoring (1=safe, 3=unsafe)
  • Threshold control for blocking risky calls
  • Pre-configured safety system prompt/tool
Isolated, reproducible containers via Docker.
  • Sandbox tool execution for safety
  • FastAPI server for tool endpoints
  • Ubuntu flavor supports .py script execution, env vars, and more
Remote, distributed execution on HTTP servers.
  • Tool execution via FastAPI HTTP APIs
  • Distribute compute and offload risky code
  • Easy integration with remote endpoints
Cloud-managed sandboxing with{" "} Daytona SDK .
  • 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 more FunctionTool objects for execution
  • reset(): Reset the runtime to its initial state
  • get_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.