sandbox
sandbox
¶
Lightweight process sandbox using bubblewrap (bwrap).
Provides process-level isolation for agent execution with near-zero overhead. Uses the same technology Claude Code uses. Works on WSL2.
The sandbox provides: - Workspace bind-mount (read-write to agent's work directory) - Shared directory bind-mounts (selective read/write) - MCP socket forwarding (Unix socket bind-mount from pool) - Optional network isolation - Optional resource caps (memory, CPU, PID limits)
Resource budget: sandbox overhead is measured in kilobytes, not megabytes. A bwrap subprocess starts in ~4ms.
Classes¶
SandboxConfig
¶
Bases: BaseModel
Configuration for a bwrap sandbox instance.
Defines the isolation boundaries for an agent execution subprocess. The conductor creates a SandboxConfig per agent based on their technique declarations and workspace assignment.
SandboxWrapper
¶
Builds and manages bwrap sandbox commands.
Given a SandboxConfig, produces the bwrap command line that sets up the isolation boundaries. The conductor uses this to wrap agent subprocess execution.
Usage::
config = SandboxConfig(workspace="/tmp/agent-ws")
wrapper = SandboxWrapper(config)
cmd = wrapper.build_command(["python", "agent_script.py"])
# cmd is ["bwrap", "--bind", "/tmp/agent-ws", "/workspace", ...]
Source code in src/marianne/execution/sandbox.py
Functions¶
build_command
¶
Build the bwrap command wrapping the given inner command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inner_command
|
list[str]
|
The command to execute inside the sandbox. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Full bwrap command line as a list of strings. |
Source code in src/marianne/execution/sandbox.py
check_available
async
staticmethod
¶
Check if bwrap is available on the system.
Returns:
| Type | Description |
|---|---|
bool
|
True if bwrap is installed and runnable. |