docs/guides/agent/agent_quickstarts/sandbox_quickstart.md
RAGFlow's CodeExec agent component needs a sandbox provider to run Python and JavaScript code.
The simplest setup flow is:
Configure sandbox providers from the admin page:
self_managed: Uses the executor manager service.local: Runs code on the current machine.ssh: Runs code on a remote machine over SSH.aliyun_codeinterpreter, e2b, tenki, and ucloud_agent_sandbox: Cloud providers.RAGFlow supports multiple sandbox providers. Configure the active provider in Admin > Sandbox Settings after the services are up.
self_managed: Runs code inside Docker-managed sandbox containers. This is the default provider.local: Runs code as local Python or Node.js subprocesses. Use this only in trusted development environments.ssh: Runs code on a remote machine over SSH.aliyun_codeinterpreter and e2b: Cloud-hosted providers that remain available in the admin provider list.tenki: Cloud-hosted provider that runs each execution in a disposable Tenki microVM. See Tenki below.ucloud_agent_sandbox: Cloud-hosted provider that runs each execution in a disposable UCloud Agent Sandbox. See UCloud Agent Sandbox below.tenki runs each code execution in a fresh Tenki microVM and destroys it afterwards. It is cloud-hosted, so it needs no local sandbox services, gVisor, or Docker base images — only outbound network access and an API key.
The tenki SDK is an optional dependency (it requires protobuf>=6.31, which differs from RAGFlow's default gRPC stack), so it is not installed by default. Install it into the RAGFlow runtime before selecting this provider:
pip install tenki
Configure it in Admin > Sandbox Settings:
api_key (required): Tenki API key. Create one at app.tenki.cloud under API Keys.base_url (optional): override the Tenki API endpoint.image (optional): sandbox base image. Leave empty to use the Tenki default image, which includes python3 and node.allow_outbound (optional, security-relevant): whether the sandbox may make outbound network connections. Defaults to false so sandboxed code has no network access; set it to true when code needs the network (for example, to install packages).timeout, max_lifetime, cpu_cores, memory_mb, disk_size_gb, and the output/artifact limits have sensible defaults and can be tuned in the same page.Notes:
artifacts/ directory of the working directory are returned as run artifacts.ucloud_agent_sandbox uses UCloud's native Sandbox SDK to create one disposable sandbox for each CodeExec run. No local sandbox service or Docker runtime is required.
Configure it in Admin > Sandbox Settings:
api_key (required): obtain one from UCloud ModelVerse API Keys.region: defaults to cn-wlcb; us-ca is also supported.domain and api_url: optional endpoint overrides for private or custom deployments.template: defaults to base, which includes Python and Node.js runtimes.allow_internet_access: defaults to false; enable it only when sandboxed code needs outbound network access.timeout, sandbox_timeout, and the output/artifact limits can be tuned for the workload.Notes:
insecure_http option is intended only for trusted test deployments.artifacts/ directory are returned as run artifacts.See UCloud Agent Sandbox prerequisites and regions.
29.1.0 or higher to stay compatible with the latest Docker daemons.:::tip NOTE
The error message client version 1.43 is too old. Minimum supported API version is 1.44 indicates that your executor manager image's built-in Docker CLI version is lower than 29.1.0 required by the Docker daemon in use.
:::
The sandbox uses isolated base images for secure containerized execution environments.
Build the runtime base images:
docker build -t sandbox-base-python:latest ./sandbox_base_image/python
docker build -t sandbox-base-nodejs:latest ./sandbox_base_image/nodejs
Alternatively, build all base images at once using the Makefile:
make build
Build the executor manager image:
docker build -t sandbox-executor-manager:latest ./executor_manager
If you do not need to customize runtime dependencies, pull the published base images and tag them with the names used by standalone Docker Compose:
docker pull infiniflow/sandbox-base-python:latest
docker pull infiniflow/sandbox-base-nodejs:latest
docker tag infiniflow/sandbox-base-python:latest sandbox-base-python:latest
docker tag infiniflow/sandbox-base-nodejs:latest sandbox-base-nodejs:latest
Then restart the standalone sandbox services:
docker compose -f docker-compose.yml down
docker compose -f docker-compose.yml up -d
Verify that gVisor is properly installed and operational.
Configure the .env file located at docker/.env:
SANDBOX_ENABLED=1.sandbox in COMPOSE_PROFILES if you want the default
self_managed executor-manager service..env if you need to change the
sandbox-executor-manager image, pool size, base images, seccomp, memory, or
timeout.Add the following entry to your /etc/hosts file to resolve the executor manager service:
127.0.0.1 es01 infinity mysql minio redis sandbox-executor-manager
Start the RAGFlow service as usual.
Open Admin > Sandbox Settings.
Select a provider.
Fill in the required fields.
Click Save.
Click Test Connection if needed.
The variables in docker/.env are grouped by scope.
These variables apply to sandbox support in general:
SANDBOX_ENABLED: Enables sandbox support in RAGFlow.COMPOSE_PROFILES: Include sandbox to start the default self-managed executor-manager service.SANDBOX_ARTIFACT_BUCKET: MinIO bucket used for files generated by sandbox code.SANDBOX_ARTIFACT_EXPIRE_DAYS: Number of days before sandbox artifacts expire.These variables are shown in Admin as deployment defaults for self_managed.
Changing them requires restarting sandbox-executor-manager.
SANDBOX_EXECUTOR_MANAGER_IMAGE: Docker image for the executor manager service.SANDBOX_EXECUTOR_MANAGER_POOL_SIZE: Number of Python and Node.js sandbox containers kept in the pool.SANDBOX_BASE_PYTHON_IMAGE: Python runtime image used by executor-managed containers.SANDBOX_BASE_NODEJS_IMAGE: Node.js runtime image used by executor-managed containers.SANDBOX_EXECUTOR_MANAGER_PORT: Host port exposed by the executor manager.SANDBOX_ENABLE_SECCOMP: Enables the optional seccomp profile for sandbox containers.SANDBOX_MAX_MEMORY: Memory limit for each sandbox runtime container.SANDBOX_TIMEOUT: Default execution timeout.Provider selection and runtime settings are configured in Admin > Sandbox Settings.
Examples:
self_managed runtime settingslocal settingsssh settingsFor self_managed:
.env and are shown as read-only valuesInitialize the environment variables:
cp .env.example .env
Launch the sandbox services with Docker Compose:
docker compose -f docker-compose.yml up
Test the sandbox setup:
source .venv/bin/activate
export PYTHONPATH=$(pwd)
uv pip install -r executor_manager/requirements.txt
uv run tests/sandbox_security_tests_full.py
Run all setup, build, launch, and tests with a single command:
make
To follow logs of the executor manager container:
docker logs -f sandbox-executor-manager
Or use the Makefile shortcut:
make logs