Run an agent in a box
Strands 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.
Before you start
Section titled “Before you start”- Strands Box installed
- A ready mount, and a running daemon. See the Quickstart
- 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
Section titled “Attach the project”cd ~/src/checkout-servicestash attach ops --no-mcpattach 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:
[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. 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
Section titled “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 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:
box profile create claude-stash --with claude,bedrock,@box/stashbox run claude-stashFor 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
Section titled “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.
-
Save this file as
stash.dwin the profile’s directory,~/.strands/box/profiles/claude-stash/. Replaceopswith the name of your mount.// 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 *")}; -
Edit the profile’s file,
~/.strands/box/profiles/claude-stash/profile.toml, to addstash.dwto thepoliciesline near its top: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
Section titled “Check it”-
Ask the agent to run a search. Each page in
_sources/shows the path of its source:Terminal window stash search ops "deploy steps" --path '/agentcore-memory/team/*' -
After a turn, run
stash status opson your machine. TheWorkspacessection lists the project.
Run in AgentCore Runtime
Section titled “Run in AgentCore Runtime”The Strands SDK in a Box sample
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
Section titled “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
Section titled “Next steps”- Attachment modes: compare CLI mode with MCP mode.
- Secure Stash: review source permissions and secret handling.
- Observe and measure: inspect logs and mount health.