Skip to main content
Sandbox tools give agents the ability to write code, run shell commands, and explore a codebase - all inside a controlled environment. A single call to sandbox_tools() creates six tools (exec, read, write, edit, glob, grep) that share an execution environment.

Environments

Polos supports three execution environments. The environment determines where tools execute and what isolation guarantees you get.

Docker

Commands run inside an isolated Docker container. Your host workspace directory is bind-mounted into the container.

Docker configuration

The container is created lazily on the first tool call and reused for subsequent calls. Call tools.cleanup() to destroy it when done.

Local

Commands run directly on your host machine. Since there’s no container isolation, exec security defaults to approval-always and file operations default to requiring approval.

Local configuration

Local mode defaults

In local mode, Polos applies stricter defaults since there’s no container boundary:

E2B

E2B support is coming soon. The configuration is defined but not yet implemented.

Built-in tools

sandbox_tools() creates six tools that all operate within the shared environment: To include only a subset of tools:

Exec security

The exec tool supports three security modes that control which shell commands can run without user approval.

Security modes

Allowlist patterns use glob-style matching. "node *" matches node hello.js but not npm install. When a command is rejected, the agent receives the rejection along with any feedback the user provided, and can adjust its approach.

Exec configuration

File approval

Write and edit operations can require user approval before modifying files.

Path restriction

When path_restriction / pathRestriction is set (local mode), read-only tools (read, glob, grep) run freely within the restricted directory but suspend for approval when accessing paths outside it. Symlink traversal outside the restriction is blocked.

Cleanup

The execution environment (Docker container, E2B sandbox) is created lazily on the first tool call. Call cleanup() to destroy it when you’re done.

Examples

Sandbox Tools

Docker-based code execution

Exec Security

Allowlist-based command approval

Local Sandbox

Host-based sandbox without Docker

Approval Page

Web UI approval forms