[Strands Box](https://strandsagents.com/box/) lets you run an agent in a contained sandbox, where you control which files, network hosts, and commands it can reach. This page tells how to give an agent running in a box access to a Stash mount.

![Stash with Strands Box. The agent and its hooks run in the box sandbox. They reach Stash only by running the stash command, and the Box policy checks each command. Other commands stop there. The Stash daemon runs outside the box, holds the credentials, and calls the sources. The daemon writes the mount point, and the box grants the agent read access to it.](https://raw.githubusercontent.com/strands-agents/stash/833198a2b91f6490291149d06b4daac8de0727c8/docs/user/images/stash-in-a-box.svg)

## Before you start

-   [Strands Box](https://strandsagents.com/box/) installed
-   A ready mount, and a running daemon. See the [Quickstart](/docs/user-guide/stash/quickstart/index.md)
-   A current Claude Code or Codex release

This page uses the example project `~/src/checkout-service` and the mount `ops`. The mount’s `mount_point` is the `context` directory of the project, such as `/Users/me/src/checkout-service/context`.

## Attach the project

```bash
cd ~/src/checkout-service
stash attach ops --no-mcp
```

`attach` connects the agents that work in this project to the mount. It writes hooks that send each turn of the agent to the mount. It also writes steering that tells the agent how to search the mount and save notes.

This is a local attach, so run `box run` from the same directory. To run a boxed agent in another directory, attach that directory too, and let the box read the mount point in the profile’s `profile.toml`:

```toml
[agent.filesystem]
read = ["~/src/checkout-service/context"]
```

Box’s hook import does not bring in the hooks of a global attach (`stash attach --global`) yet, so a global attach does not work in a box.

This guide uses `--no-mcp`, which attaches in [CLI mode](/docs/user-guide/stash/guides/attachment-modes/index.md#cli-mode). The agent and its hooks then reach Stash only through the `stash` command. So a single Box policy on that command governs everything the agent does with Stash, including its searches, its notes, and the turns its hooks send.

## Run the agent

A Box profile sets which agent runs in a box, its model provider, and the tools it can use. See the [Box quickstart](https://strandsagents.com/docs/user-guide/box/quickstart/) to learn more. A pack adds a program or a setting to a profile. The `@box/stash` pack is a tool pack that lets the agent and its hooks run the `stash` CLI in the box. The Stash daemon stays on your machine, outside the box, and the tool connects to it.

Make a profile with the pack, then run it from the project. This example uses Amazon Bedrock as the model provider:

```bash
box profile create claude-stash --with claude,bedrock,@box/stash
box run claude-stash
```

For Codex, use `--with codex,bedrock-mantle,@box/stash`. Codex runs the project’s hooks only after you trust the project and the hooks.

## Limit the agent to one mount

By default, the box lets the agent run any `stash` command. You can add a policy that permits only the commands that the agent and its hooks need, on one mount. For example, the agent then can’t run `stash create`.

1.  Save this file as `stash.dw` in the profile’s directory, `~/.strands/box/profiles/claude-stash/`. Replace `ops` with the name of your mount.
    
    ```text
    // Let the agent and its hooks run stash only on the mount ops.
    @id("stash_only_ops")
    forbid (principal, action == Box::Action::"shell:spawn", resource)
    when {
      context.input.program == "stash" &&
      !(context.input.command like "stash search ops *" ||
        context.input.command == "stash status ops" ||
        context.input.command == "stash tool list ops" ||
        context.input.command like "stash tool list ops *" ||
        context.input.command like "stash tool call ops *" ||
        context.input.command like "stash note save ops *" ||
        context.input.command like "stash hook --name ops *")
    };
    ```
    
2.  Edit the profile’s file, `~/.strands/box/profiles/claude-stash/profile.toml`, to add `stash.dw` to the `policies` line near its top:
    
    ```toml
    policies = ["policy.dw", "stash.dw"]
    ```
    

The policy permits `stash search`, `status`, `tool list`, `tool call`, `note save`, and the hooks, on the mount `ops`. The box refuses other `stash` commands.

## Check it

1.  Ask the agent to run a search. Each page in `_sources/` shows the path of its source:
    
    ```bash
    stash search ops "deploy steps" --path '/agentcore-memory/team/*'
    ```
    
2.  After a turn, run `stash status ops` on your machine. The `Workspaces` section lists the project.
    

## Run in AgentCore Runtime

The [Strands SDK in a Box sample](https://github.com/strands-agents/stash/blob/833198a2b91f6490291149d06b4daac8de0727c8/examples/agentcore-runtime/strands-sdk-box/README.md) runs a Python Strands agent in a box on AgentCore Runtime. A trusted handler serves the mount outside the box. The box policy limits the agent to `stash search` and the hooks on one mount.

## Troubleshoot

| What you see | What to do |
| --- | --- |
| `box: skipped tool stash (@box/stash): stash is not on PATH` | Make sure that `stash` is installed and on your `PATH` |
| A hook fails with `EPERM` and `posix_spawn '/bin/sh'` | Run `stash attach ops --no-mcp` again |
| `no mount "ops" is being served` | Start the daemon, then run `box run` again |
| Codex runs no hook | Trust the project, then choose **Trust all and continue** at **Hooks need review** |

## Next steps

-   [Attachment modes](/docs/user-guide/stash/guides/attachment-modes/index.md): compare CLI mode with MCP mode.
-   [Secure Stash](/docs/user-guide/stash/guides/security/index.md): review source permissions and secret handling.
-   [Observe and measure](/docs/user-guide/stash/guides/observe/index.md): inspect logs and mount health.