Sandbox Execution
RadarOS can run tool code inside isolated subprocesses with configurable timeout, memory limits, and filesystem/network restrictions. This prevents untrusted or long-running tool code from crashing, hanging, or compromising the host process.Sandbox is entirely optional and off by default. Tools run normally in the main process unless you explicitly opt in — per-tool or per-agent.
Quick Start
How It Works
When a sandboxed tool is called:- The tool’s
executefunction is serialized and sent to a forked child process via IPC - The child process runs the function in isolation with memory limits (
--max-old-space-size) - The result (or error) is sent back via IPC
- If the tool exceeds the timeout, the child process is killed with
SIGKILL - The error is returned to the LLM as a tool result
SandboxConfig
Explicit on/off toggle. Defaults to
true when a config object is provided. Set false to disable sandbox for a specific tool even when the agent has a global sandbox.Maximum execution time in milliseconds. The subprocess is killed if it exceeds this limit.
Maximum V8 heap memory in megabytes (passed as
--max-old-space-size).Allow outbound network access from the sandbox.
Allow filesystem access. Pass an object for granular control:
{ readOnly: ["/data"], readWrite: ["/tmp"] }.Whitelisted environment variables forwarded to the sandbox process. Only these variables are available inside the sandbox.
Per-Tool Sandbox
Addsandbox to any tool definition:
sandbox: true for defaults (30s timeout, 256MB, no network, no FS):
Agent-Level Sandbox
Setsandbox on AgentConfig to apply to all tools by default:
sandbox: false:
Priority
Per-tool config always takes precedence over agent-level config:Tool sandbox | Agent sandbox | Result |
|---|---|---|
undefined | undefined | No sandbox |
undefined | { timeout: 10000 } | Sandboxed (agent config) |
true | undefined | Sandboxed (defaults) |
{ timeout: 5000 } | { timeout: 10000 } | Sandboxed (tool config: 5s) |
false | { timeout: 10000 } | No sandbox (tool opts out) |
Limitations
- Serialization: The tool’s
executefunction is serialized as source code. It cannot capture closures over non-serializable values (database connections, class instances, etc.). - No shared state: The sandbox runs in a separate process. It cannot access variables from the parent process.
- Node.js only: Uses
child_process.fork()— works in Node.js, not in browser/edge runtimes.
See Also
- Human-in-the-Loop — Require human approval before executing sensitive tools
- Tools & Function Calling —
defineTool()reference - Tool Caching — Cache tool results