Sandbox Configuration
Code sandbox settings for secure remote code execution. Supports Daytona, E2B, CubeSandbox, and boxd platforms.
Chat folders and project workspaces
Chats use separate file folders by default and keep the same folder across turns. Cloud sandboxes are reused per user; a new chat does not require a new cloud sandbox.
To work on the same local files across chats, bind a local folder from the desktop project menu, then start a chat within that project. New chats inherit the computer and folder while keeping separate conversation histories. Existing chats retain their workspace when a project binding changes, a chat moves, or the assistant changes; files are not migrated automatically.
A chat can select another folder or return to its separate folder. Explicit choices override project defaults; the folder cannot be changed while a task is running. API-created project chats also snapshot the project binding when workspace options are omitted. Later requests without workspace options reuse the chat snapshot rather than current project settings.
Changing computers clears the previous computer's folder binding. Selecting a folder saves its computer and folder together. Message submission and file reads wait for pending workspace saves. Invalid, mismatched, or unavailable native bindings report an error instead of silently switching folders; select the folder again or return to the separate chat folder. Workspace updates share the message admission lock and are rejected during execution or an active Goal.
Chats sharing a folder see each other's file changes and can conflict when editing the same file concurrently. Separate folders organize files; they are not process or virtual-machine security boundaries. Local file contents read by the agent may be sent to the selected model.
General
| Variable | Default | Description |
|---|---|---|
ENABLE_SANDBOX | false | Enable sandbox execution. |
SANDBOX_PLATFORM | daytona | Sandbox platform: daytona, e2b, cubesandbox, or boxd. |
SANDBOX_GREP_TIMEOUT | 30 | Sandbox grep command timeout in seconds. |
Daytona
| Variable | Default | Sensitive | Description |
|---|---|---|---|
DAYTONA_API_KEY | (empty) | Yes | Daytona API key. |
DAYTONA_SERVER_URL | (empty) | No | Daytona server URL. |
DAYTONA_TIMEOUT | 180 | No | Command timeout in seconds (3 minutes). |
DAYTONA_IMAGE | (empty) | No | Sandbox image/snapshot ID to use. |
DAYTONA_AUTO_STOP_INTERVAL | 5 | No | Auto-stop interval in minutes. |
DAYTONA_AUTO_ARCHIVE_INTERVAL | 5 | No | Auto-archive interval in minutes. |
DAYTONA_AUTO_DELETE_INTERVAL | 1440 | No | Auto-delete interval in minutes (24 hours). |
E2B
| Variable | Default | Sensitive | Description |
|---|---|---|---|
E2B_API_KEY | (empty) | Yes | E2B API key. |
E2B_TEMPLATE | base | No | Sandbox template name. |
E2B_TIMEOUT | 3600 | No | Sandbox timeout in seconds (1 hour). |
E2B_AUTO_PAUSE | true | No | Pause sandbox on timeout instead of killing (preserves state). |
E2B_AUTO_RESUME | true | No | Auto-resume paused sandbox on next activity. |
CubeSandbox
CubeSandbox is supported through the native CubeSandbox Python SDK. LambChat uses CubeSandbox metadata to keep a stable user-to-sandbox binding: each user should have one running sandbox that is shared across conversations and sessions.
| Variable | Default | Sensitive | Description |
|---|---|---|---|
CUBE_API_URL | http://127.0.0.1:3000 | No | CubeSandbox API base URL. For the local dev environment this is commonly http://127.0.0.1:13000. |
CUBE_TEMPLATE | (empty) | No | CubeSandbox template ID used when creating sandboxes. |
CUBE_TIMEOUT | 3600 | No | Sandbox timeout in seconds. |
CUBE_PROXY_NODE_IP | (empty) | No | Proxy node IP used by the SDK to reach sandbox data-plane services. |
CUBE_PROXY_PORT_HTTP | 80 | No | HTTP proxy port used by the SDK. |
CUBE_SANDBOX_DOMAIN | cube.app | No | Sandbox domain suffix used by CubeSandbox proxy routing. |
CUBE_REQUEST_TIMEOUT | 120 | No | SDK request timeout in seconds. Lower values fail faster on stale data-plane connections; higher values tolerate slower local starts. |
CUBE_AUTO_PAUSE | true | No | Ask CubeSandbox to pause on timeout instead of killing when supported by the runtime. |
CUBE_AUTO_RESUME | true | No | Ask CubeSandbox to auto-resume paused sandboxes when supported by the runtime. |
Lifecycle Behavior
When SANDBOX_PLATFORM=cubesandbox, LambChat follows this order for a user:
- Reuse the in-process cached sandbox if it is still healthy.
- Reconnect to the MongoDB
user_sandbox_bindingsrecord. - If the binding is missing or unhealthy, list CubeSandbox instances with matching
metadata.user_idand reuse a healthy running sandbox. - Create a new sandbox only when no healthy existing sandbox can be used.
- Clean duplicate same-user running sandboxes while keeping the selected sandbox.
CubeSandbox may occasionally report a sandbox as running in the control plane even though the data plane returns 504 Gateway Time-out. LambChat treats that as unhealthy when it cannot create the session work directory or run commands, then falls back to another existing sandbox or creates a new one.
Production Migration
LambChat stores sandbox bindings per user and per platform. New records use:
sandboxes.e2bsandboxes.cubesandbox
Older production records may only have top-level fields such as sandbox_id and sandbox_state. When SANDBOX_PLATFORM=e2b, those legacy top-level records are treated as E2B bindings for backward compatibility. On the next successful reuse, LambChat writes the same sandbox into sandboxes.e2b, so the existing E2B sandbox continues to be used and is not recreated.
Switching a user or deployment from e2b to cubesandbox creates or reuses a CubeSandbox binding under sandboxes.cubesandbox without overwriting sandboxes.e2b. Switching back to e2b reads the E2B slot again.
For production deployments that should keep using E2B, leave:
SANDBOX_PLATFORM=e2bDo not set SANDBOX_PLATFORM=cubesandbox unless you intentionally want those users to start using CubeSandbox. The two platforms have separate sandbox IDs and separate lifecycle APIs.
Performance Notes
- A cold CubeSandbox create depends on the template and local runtime restore time. In local testing this can take around 20-30 seconds.
- New conversations for the same user should normally reuse the same sandbox and avoid cold start.
- Duplicate sandbox cleanup runs outside the critical cache-hit path, so reuse can return before background cleanup finishes.
CubeSandboxBackendusesCUBE_TIMEOUTfor command execution and caches parent-directory creation for repeated file writes.- The session manager caches successfully prepared session work directories in the current backend process. After a backend restart,
mkdir -pis run again and remains safe.
Console and API Checks
For the local CubeSandbox dev environment used during integration:
# CubeSandbox Web UI
open http://127.0.0.1:12088
# List sandboxes from the Cube API
curl http://127.0.0.1:13000/sandboxesUseful checks:
- The selected sandbox should have
metadata.user_idequal to the LambChat user ID. - A user should normally have only one healthy
runningsandbox. - If a sandbox is listed as
runningbut command execution returns 504, kill it from CubeSandbox or let LambChat replace it on the next sandbox initialization.
boxd
boxd runs each user's workspace on a boxd machine: a KVM microVM with a persistent disk. LambChat creates one machine per user on first use, stores its id in sandboxes.boxd, and reuses it across chats and sessions.
| Variable | Default | Sensitive | Description |
|---|---|---|---|
BOXD_API_KEY | (empty) | Yes | boxd API key. Required when SANDBOX_PLATFORM=boxd. |
BOXD_ORG | (empty) | No | Organization for new machines. Empty uses the API key's organization. |
BOXD_REGION | (empty) | No | Region for new machines, for example fra or nyc. Empty uses the default region. |
BOXD_SNAPSHOT | (empty) | No | Optional snapshot to create machines from, for a workspace with your tools preinstalled. |
BOXD_NAME_PREFIX | lambchat | No | Machine name prefix. Machines are named <prefix>-<random>. |
BOXD_TIMEOUT | 1800 | No | Default command timeout in seconds. A tool call can pass its own timeout. |
Create an API key with the boxd CLI:
boxd auth keys create lambchat --org <your-org>Lifecycle behavior
- Machines are created with
isolatedon. They run model-driven code, so they never join your organization's private network. - Each chat works in
/home/boxd/sessions/<session>. Commands run underbashas theboxduser. The user's sandbox environment variables are passed to every command and are not saved in the machine's configuration. - With
SANDBOX_PAUSE_WHEN_IDLE=true, LambChat hibernates the machine when no run needs it. The next command wakes it with its files and running processes intact. A stopped machine is started on next use. - If a bound machine was deleted outside LambChat, the binding is kept and the workspace reports it as unavailable instead of creating an empty one.
- LambChat does not delete a user's machine. Delete machines you no longer need from the boxd console or CLI.
- Each user who uses the sandbox gets one machine, and these machines count toward your organization's machine limit.
- Keep
BOXD_REGIONfixed once machines exist. LambChat finds each user's machine by id in that region.
Examples
Daytona (Self-hosted)
ENABLE_SANDBOX=true
SANDBOX_PLATFORM=daytona
DAYTONA_API_KEY=your_daytona_api_key
DAYTONA_SERVER_URL=https://daytona.example.com
DAYTONA_TIMEOUT=180E2B (Cloud)
ENABLE_SANDBOX=true
SANDBOX_PLATFORM=e2b
E2B_API_KEY=your_e2b_api_key
E2B_TEMPLATE=base
E2B_TIMEOUT=3600CubeSandbox (Local Dev)
ENABLE_SANDBOX=true
SANDBOX_PLATFORM=cubesandbox
CUBE_API_URL=http://127.0.0.1:13000
CUBE_TEMPLATE=tpl-your-template-id
CUBE_PROXY_NODE_IP=127.0.0.1
CUBE_PROXY_PORT_HTTP=11080
CUBE_SANDBOX_DOMAIN=cube.app
CUBE_TIMEOUT=3600
CUBE_REQUEST_TIMEOUT=120
CUBE_AUTO_PAUSE=true
CUBE_AUTO_RESUME=trueboxd (Cloud)
ENABLE_SANDBOX=true
SANDBOX_PLATFORM=boxd
BOXD_API_KEY=your_boxd_api_key
BOXD_REGION=fra
BOXD_TIMEOUT=1800INFO
The DAYTONA_AUTO_*_INTERVAL settings control sandbox lifecycle management to optimize resource usage. Sandboxes are automatically stopped, archived, and eventually deleted based on these intervals.
TIP
For CubeSandbox, tune CUBE_REQUEST_TIMEOUT based on your local runtime. Shorter values make stale sandboxes fail faster; longer values reduce false failures during slow local restores.