LangBot Docs
Sandbox

Sandbox

LangBot Box Runtime gives the built-in Agent command and file tools with a choice of sandboxed or trusted-host backends.

Box Runtime gives the built-in Agent one execution interface for running commands, reading and writing files, and hosting long-lived processes. Everyday Agent use cases (data processing, file operations, running user code, hosting stdio MCP) all rely on it. Docker, nsjail, and E2B provide sandbox isolation; the explicitly selected Host backend is for trusted local development and provides no isolation.

Once Box is enabled, the built-in Agent automatically gains six tools — no need to wire each one into the Chat.

Built-in Tools

ToolPurpose
execRun shell commands inside the sandbox
readRead workspace files
writeCreate or overwrite files
editModify files via string replacement
globFind files by glob pattern
grepSearch file contents by regex

All six tools execute inside the Box session against /workspace. With Host selected, commands run directly on the Box Runtime host.

These tools target the built-in Agent. When using external runners such as Dify, n8n, Langflow, or Coze, use that platform's own tool mechanism.

Sandbox Scope

The Chat's AI configuration lets you choose how the sandbox is shared across messages. The default "per chat" works for most cases.

ScopeTemplateShared across
Global{global}All users share one sandbox
Per chat (default){launcher_type}_{launcher_id}Same group or DM shares one
Per user{launcher_type}_{launcher_id}_{sender_id}Each member in a group is isolated
Per conversation{launcher_type}_{launcher_id}_{conversation_id}Isolated by conversation
Per message{query_id}Fully stateless

Commands within the same scope share filesystem state. Choose "per message" for a separate workspace. Scope controls session reuse; it is not a security boundary. Host has no host-level isolation even when different scopes are used.

Lifecycle

ConditionBehavior
Idle for more than 5 minutesCleaned up automatically
Box-managed processes running (e.g. stdio MCP)Kept alive until those processes exit
persistent: true configuredNever cleaned up automatically

These lifecycle rules also apply to Host. Cleanup terminates the session's managed process trees and removes the Box-owned private session workspace directory. Runtime shutdown and explicit session deletion also perform cleanup.

Quick Start

Trusted local development on Linux / macOS can select Host without installing Docker:

  1. Edit config.yaml:
    box:
      enabled: true
      backend: 'host'
  2. Start LangBot: Box Runtime is enabled automatically
  3. In the Chat, select the built-in Agent plus a model that supports function calling

The Agent will then automatically receive the six tools. See Sandbox Configuration for details.

Host executes commands directly with the LangBot / Box Runtime user's permissions and must only process trusted input. To execute untrusted code, set backend to local (auto-pick Docker / Nsjail), docker, nsjail, or e2b.

Disabling Box

Set box.enabled: false. Everything that depends on the sandbox (built-in tools, Skill create/edit/activate, stdio MCP) is disabled together; MCP servers in http/sse mode are unaffected.

Next Steps

Assistant sandbox

The Workspace assistant has a sandbox of its own to run code, work with files and write and build plugins. The box icon at the top of the assistant panel shows its state, size and settings.

  • There is one per Workspace, shared by every member who can use the assistant: members see each other's files. Plugins, Agents and workflows do not see it.
  • Files in /workspace and installed packages are kept, also across restarts. After 10 idle minutes it goes to sleep and wakes up when used again.
  • When a Workspace has not used its assistant sandbox for 30 days, the hourly maintenance deletes its files. Set the number of days with box.assistant_sandbox_retention_days; 0 keeps them.
  • Network access is on by default; an administrator can turn it off in the panel. A command may take 120 seconds, and one runs at a time.
  • The limit is 2 GB unless the disk quota under Settings → Workspace → Execution → Workspace limits sets another. When it is full, ask the assistant to tidy up, or have an administrator empty the sandbox, which cannot be undone.
  • Files the assistant exports can be downloaded below its answer. A plugin it built is previewed first and installed when you confirm.
  • Do not put passwords or keys into it.

It needs Docker, nsjail or E2B with box.file_transfer_mode: network and box.workspace_mode: private, the defaults. The host backend is not isolated and is not used by the assistant; the cloud is not supported yet. The panel says why it is not available.

With Docker and nsjail the files are below .langbot-durable-workspaces in the working directory of Box Runtime: include it in backups, and keep it on a persistent volume in container deployments. With E2B they are in the paused sandbox.

Workspace sandbox settings

Select Docker, E2B or nsjail in Settings → Workspace → Execution and confirm before saving. Changes apply to new tasks. Running tasks and stdio MCP connections retain their backend, E2B credentials, template and limits. This feature requires matching Core, SDK and Box Runtime versions; the older SDK can still start Core but cannot use these settings.

Connection checks and saving create no sandbox. Test run creates, executes in and deletes a temporary E2B sandbox, consuming capacity and potentially incurring charges. Disk usage is checked around commands rather than continuously enforced. Settings are available to members and API keys and are excluded from plugin and Runner Workspace tools. Administrative MCP clients can call them explicitly; HTTP and MCP share the Application API.

In network mode, E2B supports a workspace disk limit. LangBot checks it before and after commands. If the Box exceeds the limit after a command, LangBot removes the Box and its working files may be lost.

On this page