Skip to main content

Configure Code Execution Sandbox

Select a Sandbox Provider

If your organization uses the Code component in Agent, administrators must configure the code execution sandbox in Sandbox settings.

The current page supports the following Provider options:

ProviderDescription
LocalExecute code directly in the current host process.
Self-ManagedUse Daytona or Docker for localized deployment.
SSHExecute code on a remote machine through SSH.
AliyunCodeInterpreterUse Alibaba Cloud Function Compute Code Interpreter.
E2BUse E2B Cloud Code Execution Sandboxes.

After selecting a Provider, the page displays the corresponding configuration area.

Select Sandbox Provider

Caution: Sandbox configuration affects not only connection availability, but also code isolation, network access, file access, and runtime resource limits. In production environments, prefer Self-Managed, cloud, or independent remote execution solutions with isolation capabilities. Direct use of Local is not recommended.

ProviderApplicable scenarioMain characteristicsRecommendation
LocalLocal development and functional debuggingRuns code directly on the current host and is easy to configure.Recommended only for controlled development and test environments.
Self-ManagedEnterprise intranet and private deploymentUses a self-managed sandbox service to execute code. Data and runtime environments can be controlled independently.Suitable for production environments and scenarios with high data security requirements.
SSHExisting independent execution serversExecutes code on a remote host through SSH.Suitable for reusing existing servers or custom runtime environments.
AliyunCodeInterpreterAlibaba Cloud-related servicesUses a cloud service to provide the code execution environment, making elastic scaling easier.Suitable for organizations already using the corresponding cloud service.
E2BFast access to a cloud sandboxExecutes code in an isolated environment provided by E2B.Suitable for scenarios that need quick use without deployment.

Test and Save Configuration

When configuring a sandbox, first fill in the connection information and runtime parameters required by the selected Provider, then use Test connection to verify availability. After the test succeeds, click Save.

Local Runtime Configuration

Local configuration configures the local code execution environment. The system uses the following configuration when executing code tasks such as Python and Node.js.

  1. Go to Local Configuration.
  2. Configure each parameter according to the actual runtime environment.
  3. Click Test connection to test whether the configuration is correct.
  4. After the test succeeds, click Save.
ParameterDescriptionRecommendation
Working DirectoryWorking directory used during code execution, for temporary files generated during runtime.Keep the default, or configure a local directory with read and write permissions.
Python BinaryPython executable name or path.Usually python3. If using a virtual environment, enter the full Python path.
Node.js BinaryNode.js executable name or path.Usually node. If installed elsewhere, enter the full path.
Max Artifact Size (bytes)Maximum allowed size for a single generated file.Configure according to business needs. The default usually satisfies common use.
Max ArtifactsMaximum number of files allowed in one run.Keep the default to avoid generating too many temporary files.
Max Memory (MB)Maximum memory available to a single code run.Configure according to server resources. Increase it when resources are sufficient.
Max Output (bytes)Maximum length of console output.Keep the default to avoid oversized output.
Timeout (seconds)Maximum runtime for a single code execution.Set according to the business scenario. The task is terminated automatically after timeout.

If Python or Node.js is not installed, or the executable path is wrong, the connection test fails.

Self-Managed Configuration

Self-Managed configuration connects to a deployed SandboxExecutorManager service for remote sandbox execution. If the code execution service is deployed on an independent server or in a container, complete this configuration.

  1. Go to Self-Managed Configuration.
  2. Configure the code execution service connection information.
  3. Click Test connection to test whether the connection is normal.
  4. After the test succeeds, click Save.
ParameterDescriptionRecommendation
Executor Manager EndpointAccess address of the SandboxExecutorManager service.Enter the HTTP address of the code execution service, such as http://sandbox-executor-manager:9385 or http://<SERVER_IP>:9385. Make sure RAGFlow can access this address.
Request Timeout (seconds)Timeout for requests to the code execution service.Configure according to the network environment and code execution duration. The default 30 seconds is sufficient for most cases; increase it for large tasks.

Executor Manager Endpoint must be the address of a deployed and normally running SandboxExecutorManager service.

Deployment Defaults displays the current default deployment parameters of SandboxExecutorManager.

SSH Configuration

SSH configuration connects to a remote Linux host and executes Python, Node.js, and other code tasks on the remote server. After configuration, the system logs in to the specified server through SSH and executes code in the remote working directory.

  1. Go to System management > Model service > SSH Configuration.
  2. Fill in the remote server connection information.
  3. Select the authentication method: password authentication or private-key authentication.
  4. Configure the remote code runtime environment.
  5. Click Test connection to test whether the connection is normal.
  6. After the test succeeds, click Save.

SSH Connection Configuration

ParameterDescriptionRecommendation
SSH HostRemote server IP address or host name.For example, 192.168.1.10 or server.example.com.
SSH UsernameUser name used to log in to the remote server.Enter a user with code execution permissions, such as root, ubuntu, or ragflow.
SSH PortPort on which the SSH service listens.The default is 22. If the server uses another SSH port, enter the actual port.

Authentication

The system supports Password and PrivateKey authentication.

Authentication methodDescriptionRecommendation
PasswordUses the SSH user password for authentication.Fill in SSH Password.
PrivateKeyUses an SSH private key for authentication.Fill in the SSH private key content. If the private key has a password, also fill in the corresponding Passphrase. Private-key authentication is recommended in production.

Execution

ParameterDescriptionRecommendation
Remote Workspace RootWorking directory on the remote server for temporary files generated during code runs.Configure a directory with read and write permissions, such as /tmp or /home/ragflow/workspace.
Python BinaryPython executable name or full path.Usually python3. If using a virtual environment, enter the full Python path.
Node.js BinaryNode.js executable name or full path.Usually node. If installed elsewhere, enter the full path.
Max Artifact BytesMaximum allowed size for a single generated file.Keep the default or adjust according to business needs.
Max ArtifactsMaximum number of files allowed in one run.Keep the default configuration.
Max Output BytesMaximum size of console output.Keep the default. Output exceeding the limit is truncated.
Timeout (seconds)Maximum runtime for a single code execution.The default is 30 seconds. Increase it when execution takes longer.

Make sure the remote server has SSH enabled and allows the current user to log in. The configured user must have read and write permissions on the remote working directory and be able to execute Python, Node.js, and other runtime environments. When using private-key authentication, make sure the private key matches the server configuration.

Alibaba Cloud CodeInterpreter Configuration

Alibaba Cloud CodeInterpreter configuration connects to Alibaba Cloud CodeInterpreter. The system executes code tasks through this service.

  1. Go to AliyunCodeInterpreter Configuration.
  2. Fill in the connection information for Alibaba Cloud CodeInterpreter.
  3. Click Test connection to test whether the connection is normal.
  4. After the test succeeds, click Save.
ParameterDescriptionRecommendation
AccessKeyIDAlibaba Cloud account AccessKeyID for authentication.Enter an AccessKeyID with access to the CodeInterpreter service.
AccessKeySecretSecret corresponding to AccessKeyID.Enter the corresponding AccessKeySecret and keep it secure to avoid leakage.
AccountIDAlibaba Cloud account ID.Enter the current Alibaba Cloud account ID.
RegionRegion where the CodeInterpreter service is located.Enter the actual deployment region, such as cn-hangzhou.
TemplateNameTemplate name used by CodeInterpreter.Enter the created template name, such as my-interpreter.
ExecutionTimeout (seconds)Maximum runtime allowed for a single code execution.The default is 30 seconds. Adjust according to business needs.

E2B Configuration

E2B configuration connects to the E2B Cloud code execution service. After configuration, the system executes code tasks through the E2B cloud sandbox.

  1. Go to E2B.
  2. Fill in the E2B service connection information.
  3. Click Test connection to test whether the connection is normal.
  4. After the test succeeds, click Save.
ParameterDescriptionRecommendation
API KeyAPI key provided by E2B Cloud for authentication.Log in to the E2B platform, create the corresponding API key, and enter it.
RegionRegion where the E2B service is located.Enter the actual region, such as us.
Request Timeout (seconds)Timeout for requests to the E2B service.The default is 30 seconds. Increase it if the network is slow or execution takes longer.