box README

The project's README from github.com/strands-agents/box. As one markdown file: README.md.

Strands

Strands Box

An open source sandbox engine for AI agents.

Commit Activity Open Issues Open PRs Discord

Overview

Strands Box is an open source sandbox for AI agents. It combines operating-system isolation with semantic policies written in Dogwood, so you can control what agents can access and the conditions under which they can act.

Box is harness-agnostic. You choose the agent program or binary to run, configure its access in box.toml, and write its policies in policy.dw.

The host OS enforces the direct access restrictions in box.toml. Strands Shell, Monty for Python, the egress gateway, and the MCP broker send the operations they handle to the embedded Dogwood Local Engine, which evaluates the rules in policy.dw. Box enforces its allow or deny decisions outside the agent process.

Dogwood uses permit and forbid rules. Operations checked by the engine are denied by default: a matching permit must allow the operation, and a matching forbid overrides that permission.

Box's interpreters and gateways share an event history, so rules can use earlier actions and elapsed time to decide what is allowed next. For example, a file read through Shell or Python can cause the gateway to deny a later outbound HTTP request.

Preview: Box currently supports local execution on macOS with Apple silicon. We welcome feedback through GitHub issues. Read CONTRIBUTING.md before submitting a change.

Key capabilities

Direct filesystem grants in box.toml are enforced by the OS and do not produce individual Dogwood decisions. To apply a policy to file operations, use the interpreters and keep those files out of the agent's direct grants. See filesystem access and policy.

Architecture

Box runs the Dogwood Local Engine and its enforcement components in its own process, outside the agent's sandbox. Strands Shell, Monty, the egress gateway, and the MCP broker check operations with the engine before allowing them. They also record events that later policy decisions can use.

flowchart LR
    subgraph sandbox["Agent OS sandbox"]
        agent["Agent application"]
    end

    net["network requests"]:::label
    py["Python code"]:::label
    sh["shell commands"]:::label
    mc["local MCP calls"]:::label

    subgraph trusted["The box's trusted process (outside the agent sandbox)"]
        proxy["Egress gateway"]
        monty["Monty for Python"]
        shell["Strands Shell"]
        mcp["MCP broker"]
        policy[["Dogwood Local Engine and event history"]]
    end

    agent --- net --> proxy
    agent --- py --> monty
    agent --- sh --> shell
    agent --- mc --> mcp
    proxy -->|"policy checks"| policy
    monty -->|"policy checks"| policy
    shell -->|"policy checks"| policy
    mcp -->|"policy checks"| policy

    classDef label fill:none,stroke:none;

When the agent uses a program such as git or cargo, or a local MCP server, Box checks the launch against policy and runs the program in its own sandbox. You configure which files each program can read or change. The agent can send requests to Box's interpreters, but external programs and local MCP servers cannot. Box receives their output and exit status, and their network traffic goes through Box's gateway by default. See the security model for details.

For each part, where it runs, what it decides, and how one request moves through them, read Box architecture.

Getting started

Follow the getting-started guide to run Strands CLI with Box. To follow this guide, you need a Mac with Apple silicon and macOS 15 or later, Node.js 22.21 or later from Homebrew, and access to Claude Opus 5 on Amazon Bedrock in us-west-2.

The download script checks the release checksum and unpacks the binaries into ./box-core. It does not change your PATH or system directories:

curl -fsSL https://raw.githubusercontent.com/strands-agents/box/main/download.sh | sh
./box-core/box --version

Keep the downloaded binaries together in ./box-core. You can also build from source. Then follow the guide to write box.toml and policy.dw, and run the box.

Change what the box allows

Edit box.toml to change the agent's environment and direct access grants. Edit policy.dw to change the rules for operations Box checks through its interpreters and gateways. You can give your coding agent the policy-authoring skill for help with Dogwood syntax and Box's supported actions:

https://raw.githubusercontent.com/strands-agents/box/main/.agents/skills/authoring-box-policy/SKILL.md

Examples

Run the Strands Python SDK example for a small agent whose three tools use Shell.

See the example index for dependencies and run instructions.

Build from source

This is a Cargo workspace. rust-toolchain.toml pins the compiler, and rustup installs it on the first build. Build the box binaries from a clone with rustup:

git clone https://github.com/strands-agents/box.git
cd box
cargo build --release -p strands-box -p strands-box-containment

Run the compiled binary as ./target/release/strands-box. Keep its helper binaries in the same directory.

Common tasks run through just:

just build         # the CLI, the alias image, and the containment trampoline
just test          # workspace tests
just check         # pre-push gate: fmt-check + clippy + test
just test-all      # workspace tests and box example checks

cargo test --workspace --all-features runs the full suite. Include --all-features to run the box_shell and box_credentials suites, which require the test-support feature.

Documentation

Guide Contents
docs/user/ How to install Box and run a box.
docs/design/ Architecture, enforcement boundaries, and design decisions.

See AGENTS.md for the repository rules and the current state.

Reporting a problem

Open an issue on this repository. For a suspected security problem, read SECURITY.md first.

License

Apache License 2.0.

box (strands-agents/box)

Searching Database…

436 ·GitHub
这是什么?Box 是一个用于运行 AI 智能体的开源沙箱,限制它们能执行、读取、写入以及在网络上访问的内容,将操作系统级隔离与策略引擎(Dogwood)和凭据注入相结合,确保密钥永远不会到达智能体。
这是我导入的库,还是让我的智能体在里面运行的沙箱运行时?Box 是一个独立的沙箱引擎,不是库:你在 box.toml 中配置操作系统级访问授权,在 policy.dw 中配置语义规则,然后通过 Box 自己的解释器(Strands Shell 和用于 Python 的 Monty)和网关运行你选择的智能体程序。
怎么让 Box 跑起来?按照入门指南操作:运行下载脚本,它会检查发行版校验和并把二进制解包到 ./box-core(或用 Cargo 从源码构建),然后编写 box.toml 和 policy.dw,并运行 box 二进制。
尝试入门指南之前需要准备什么?你需要一台搭载 Apple 芯片、运行 macOS 15 或更高版本的 Mac,通过 Homebrew 安装的 Node.js 22.21+,以及 us-west-2 区域 Amazon Bedrock 上 Claude Opus 5 的访问权限。
Box 已经可以在任何机器上投入生产使用了吗?没有——这是一个预览版本,目前仅支持在搭载 Apple 芯片的 macOS 上本地运行;Linux 支持已在计划中,但尚未发布。
智能体会看到它使用的 API 密钥吗?不会——出口网关会使用配置好的 API 凭据或 AWS SigV4 签名自行认证获准的出站请求,智能体进程永远不会拿到底层密钥。
Dogwood 是什么?Dogwood 是 Box 使用的策略语言,基于 permit 和 forbid 规则构建;每个受检查的操作默认被拒绝,除非有 permit 规则允许它,而匹配的 forbid 规则始终会覆盖该许可。
Strands Shell 和 Monty 是什么?它们是 Box 内置的解释器,分别用于 shell 命令和 Python 代码;两者执行的每个操作都会先经过 Dogwood 策略引擎,然后才执行。
策略能根据已经发生的事情阻止后续操作吗?可以——Box 的解释器和网关共享一份事件历史,因此规则可以因为较早的一次文件读取而拒绝稍后的出站 HTTP 请求。
MCP broker 是做什么的?它在工具调用到达 MCP 服务器之前,依据 Dogwood 策略检查配置好的 MCP 工具调用及其参数,方式与出口网关检查网络请求相同。
Size
3.2 MB
Stars
436
Age
16d
Commits · 90 Days