Skip to content
Agent in a Box: sandboxing AI coding agents with Strands Box

Measurements

This page holds every number the workshop quotes: tokens, cost, turns and time for each act and task, and the build of Box each was measured on. After it you will know what each set-up costs the developer, how much of that is the tool list, and how far the numbers can be compared. The story needs it last because the acts traded control against cost, and this is the cost side, measured.

Architecture, stage 5 of 5Pieces: macOS keychain, Developer's terminal, Claude Code, Contained filesystem view, Local exec proxy, box CLI and Box Core, Stand-in secrets, Egress gateway, MCP broker, Tool catalog, Policy engine, Records, Anthropic API, Cloudflare MCP server, Cloudflare API, Sample app. New at this stage: Local exec proxy. A full text description follows the diagram.The boxAgent's sandboxMCP server's sandboxTrusted processbox runstartsstdiomacOS keychainthree secretsDeveloper'sterminalClaude Codethe agentContainedfilesystem viewLocal exec proxysearch and executenewbox CLI and Box CoreStand-in secretsreal values stay hereEgress gatewaydecides net:connect,http:request, andmcp:call for aremote MCP serverMCP brokerlocal MCP serversTool catalogstaged, typed per toolPolicy engineCedar and Dogwood policy files (.dw)Recordsrecords.jsonl and the run's historyAnthropic APIapi.anthropic.comCloudflare MCP serverper-endpoint mode;not on act c's pathCloudflare APIapi.cloudflare.comSample appWorker box-poc-workshop,its D1, KV andWorkers Logsholds names and email addressesnew at this stage
Text description of the diagram

Stage 5 of 5.

Pieces in the picture:

  • the macOS keychain, which holds the three secrets; the developer reads them into shell variables
  • the developer's terminal
  • Claude Code, the agent
  • the contained filesystem view: only the paths the profile grants exist for the agent
  • the local exec proxy, an MCP server with search and execute tools, in its own sandbox inside the box (new at this stage)
  • the box CLI and Box Core, which build the box and run its trusted process
  • stand-in secrets: the agent gets placeholders, the real values stay in the trusted process
  • the egress gateway, which every network request from the box goes through
  • the MCP broker, which starts local MCP servers and decides their calls
  • the staged tool catalog: Box types each tool from the server's tools/list before the agent may call it
  • the policy engine, which reads the Cedar and Dogwood policy files
  • the records: every decision, written where the agent cannot reach
  • the Anthropic API
  • Cloudflare's MCP server (not on act c's path)
  • the Cloudflare API
  • the sample app: the Worker box-poc-workshop with its D1 database, KV namespace and Workers Logs; the logs and the database hold attendee names and email addresses
  • Boundaries: the box, agent's sandbox, mcp server's sandbox, trusted process.

The picture is the final one. The numbers below belong to its different paths: act a without the box, acts b1 to b3-args through the vendor’s MCP server, and act c through the local exec proxy.

  • One run per cell. Each row is one run, with model claude-sonnet-5-5, a plain task and no adversarial prompting. A second run of the same task can differ; where a repeat exists, it is shown.
  • Claude Code’s own figures. Turns, tokens and cost are what Claude Code reported at the end of the run, in its result event. Box’s records hold no token or byte figures.
  • Input tokens are all kinds added: uncached, cache write and cache read. The three parts are shown in brackets.
  • Time is two numbers: Claude Code’s own duration, and the wall time of the whole command.
  • Tool loading says what the model was given. “Code mode” is the vendor’s server with a handful of tools, run with --tools "", so Claude Code’s tool search was off. “Per-endpoint” is the vendor’s 3,053 tools with tool search on (--tools ToolSearch), so the model receives only the tool names and loads a definition when it needs one. “Exec proxy” is the local server’s two tools, tool search off.
  • Builds. The workshop’s steps use pkg-fix, a local build that prints box 0.1.0: public strands-agents/box main c70fec5 plus an earlier round of a fix for MCP tool schemas that is not in upstream Box, built 2026-11-21 as an uncommitted diff. The fork branch bugfix/mcp-shared-definitions-workshop holds a later review round of the same fix on the same commit; a build from it is not byte-identical to pkg-fix, and the acts were not run again on it. Other local builds (pkg, pkg-main) and the installed release box 0.1.8 appear in separate groups. Builds and gaps says what each build is.
  • Do not compare across groups as if only Box changed. The groups also differ in Claude Code version (2.1.325, 2.1.326, 2.1.330) and in the policy files: the pkg-fix runs of acts b2 and c used the files you write in this workshop; the other runs used policies generated by the author’s kit (now in the kit/ folder of box-exec-proxy), so their refusals name other rule ids.
  • Outcome “logs returned” means log lines came back. In these runs the last hour of the Worker’s logs held only two request lines; the attendee events with email addresses were older. An email came back in one run: act a with a 24-hour window (redacted in the evidence).

Sources: the result files of each run, in the author’s measurement notes (not published), and Claude Code’s own result figures of the runs made while writing and verifying this workshop. Every number on this page was copied from one of those; none is estimated.

Claude Code 2.1.330. Runs from 2026-11-21 (b3-args) and 2026-11-22 (b2, c).

Act Task Tool loading Outcome Turns Input tokens Output tokens Cost (USD) Claude / wall (s) Tool calls
b2 logs (last hour) code mode refused 6 75,732 (12 + 20,075 + 55,645) 1,715 0.0729 20.7 / 22 3 search, 1 docs, 1 execute (refused)
b2 allowed code mode refused 2 4,826 (6 + 601 + 4,219) 708 0.0090 5.7 / 8 1 execute (refused)
b3-args two workers_deployments_list calls, another account then the workshop’s per-endpoint first refused, second answered 4 320,678 (8 + 79,890 + 240,780) 1,157 0.2354 18.0 / 85 1 ToolSearch, 2 workers_deployments_list
c, before the route allowed exec proxy refused at net:connect 2 not recorded in the notes not recorded 0.0103 not recorded 1 execute
c allowed exec proxy done 2 4,089 (6 + 2,057 + 2,026) 862 0.0140 7.8 / 9 1 execute
c logs (last hour) exec proxy refused 4 17,302 (10 + 6,582 + 10,710) 997 0.0275 11.5 / 14 2 search, 1 execute

The five paid runs made while writing the workshop (b2 both tasks, c before the route, c both tasks) cost USD 0.1337 in total. Act a runs with no box, and acts b1 and b3 have no full measurement on pkg-fix: their numbers come from the groups below. Later verification runs, typed as the pages show them, recorded turns and cost only. Act a has no box: its logs run took 7 turns, USD 0.0415, with Claude Code 2.1.330. On pkg-fix: b1 logs 5 turns, USD 0.0354; b3 steering sentence 3 turns, USD 0.2218 and 0.2217; b3-args 4 turns, USD 0.2228 and 0.2217.

Other newer builds: pkg, pkg-main and box 0.1.11

Section titled “Other newer builds: pkg, pkg-main and box 0.1.11”

Claude Code 2.1.330, except the box 0.1.11 row (2.1.326). All runs on 2026-11-21. These runs used the kit’s generated policies.

Act Task Build Tool loading Outcome Turns Input tokens Output tokens Cost (USD) Claude / wall (s) Box decisions
b1 logs (last hour) pkg code mode logs returned 7 100,197 (14 + 22,510 + 77,673) 1,372 0.0778 19.8 / 22 permit docs, search x3, execute x2
b2 logs (last hour) pkg code mode refused 5 56,887 (10 + 17,032 + 39,845) 1,175 0.0583 13.9 / 17 deny execute (logs_vendor_execute)
b3 allowed box 0.1.11 per-endpoint refused 5 239,108 (6 + 79,407 + 159,695) 1,039 0.2249 14.7 / 18 deny workers_list, workers_get; deny workers_deployments_list (catalog not accepted)
b3 allowed pkg per-endpoint partly: deployments answered 4 241,478 (6 + 80,349 + 161,123) 1,076 0.2278 14.2 / 80 deny workers_list; permit workers_deployments_list
b3 only workers_deployments_list pkg per-endpoint done 3 239,979 (6 + 77,873 + 162,100) 787 0.2188 12.5 / 78 permit workers_deployments_list
b3 only workers_deployments_list pkg-main per-endpoint done 3 239,928 (6 + 79,405 + 160,517) 718 0.2218 11.4 / 75 permit workers_deployments_list
b3 logs (last hour) pkg per-endpoint refused 3 248,292 (6 + 81,934 + 166,352) 1,426 0.2357 17.1 / 82 deny o11y_telemetry_query
b3-args two calls, another account then the workshop’s pkg per-endpoint first refused, second answered 4 240,409 (6 + 78,229 + 162,174) 1,049 0.2223 14.3 / 80 deny, then permit workers_deployments_list
b3-args the same, repeated pkg per-endpoint first refused, second answered 4 240,364 (6 + 79,778 + 160,580) 1,045 0.2260 13.8 / 83 deny, then permit
b3-args the same pkg-main per-endpoint first refused, second answered 4 240,361 (6 + 78,210 + 162,145) 923 0.2210 12.5 / 77 deny, then permit
c allowed pkg exec proxy done 2 6,055 (6 + 3,790 + 2,259) 746 0.0172 7.1 / 10 permit two GETs
c allowed pkg-main exec proxy done 2 6,095 (6 + 3,830 + 2,259) 779 0.0176 7.9 / 11 permit two GETs
c logs (last hour) pkg exec proxy refused 5 31,101 (12 + 7,159 + 23,930) 1,620 0.0365 16.9 / 19 deny POST …/telemetry/query (logs_allowlist)

On box 0.1.11 the per-endpoint catalog was not accepted, so even the listed tool was refused. On pkg, pkg-main and pkg-fix it was accepted.

The installed release: box 0.1.8, and act a without a box

Section titled “The installed release: box 0.1.8, and act a without a box”

Claude Code 2.1.325. All runs on 2026-11-14. Kit-generated policies.

Act Task Tool loading Outcome Turns Input tokens Output tokens Cost (USD) Claude / wall (s)
a, no box allowed code mode done 2 3,981 (6 + 2,663 + 1,312) 918 0.0160 8.8 / 10
a, no box logs (last hour) code mode logs returned 4 21,563 (10 + 7,519 + 14,034) 1,159 0.0318 12.3 / 13
a, no box logs, 24 hours code mode logs returned, with an email 4 24,490 (10 + 15,306 + 9,174) 1,448 0.0537 20.8 / 22
b1 allowed code mode done 2 3,954 (6 + 1,334 + 2,614) 781 0.0114 7.6 / 9
b1 logs (last hour) code mode logs returned 6 80,736 (12 + 26,391 + 54,333) 1,311 0.0845 19.6 / 21
b1 logs, 24 hours code mode logs returned 4 32,104 (10 + 18,069 + 14,025) 1,775 0.0643 22.2 / 24
b2 allowed code mode refused 3 4,984 (8 + 902 + 4,074) 909 0.0118 9.7 / 12
b2 logs (last hour) code mode refused 5 25,897 (12 + 7,050 + 18,835) 1,735 0.0369 20.0 / 22
b3 allowed per-endpoint refused 4 238,856 (6 + 79,138 + 159,712) 774 0.2216 11.4 / 14
b3 logs (last hour) per-endpoint refused 3 246,672 (6 + 81,862 + 164,804) 1,351 0.2347 16.5 / 19
b3 allowed per-endpoint, tool search off failed: request too large 1 0, refused by the API 0 0.0000 2.0 / 5
c allowed exec proxy done 2 6,573 (6 + 4,308 + 2,259) 847 0.0195 8.2 / 10
c logs (last hour) exec proxy refused 5 26,450 (12 + 6,038 + 20,400) 1,274 0.0299 14.9 / 17

Box 0.1.8 refused the per-endpoint catalog at once (one tool schema it could not read refuses the whole server), so act b3 on 0.1.8 had no staging wait and refused even the listed tool. Its cost is the cost of loading the catalog and failing, not of doing the task. Act b3-args needs a newer build and was not run on 0.1.8. With tool search off, Claude Code sent every definition up front and the API refused the request: about 2.2 million tokens against a limit of 1,000,000, not billed.

The charts keep the groups apart. Each bar names its build.

Cost per run, logs task, newer builds (USD)
b1 (pkg)0.0778 USD (logs returned)b2 (pkg-fix)0.0729 USD (refused)b3 (pkg)0.2357 USD (refused)c (pkg-fix)0.0275 USD (refused)
Cost per run, logs task, newer builds (USD)
ItemUSDNote
b1 (pkg)0.0778logs returned
b2 (pkg-fix)0.0729refused
b3 (pkg)0.2357refused
c (pkg-fix)0.0275refused

Source: b1 and b3 on pkg, b2 and c on pkg-fix; Claude Code 2.1.330

Input tokens per run, logs task, newer builds
b1 (pkg)100,197b2 (pkg-fix)75,732b3 (pkg)248,292c (pkg-fix)17,302
Input tokens per run, logs task, newer builds
ItemtokensNote
b1 (pkg)100,197
b2 (pkg-fix)75,732
b3 (pkg)248,292
c (pkg-fix)17,302

Source: b1 and b3 on pkg, b2 and c on pkg-fix; all kinds of input token added

Cost per run, allowed task and the b3-args task, newer builds (USD)
b2 (pkg-fix)0.0090 USD (refused)b3 (pkg)0.2278 USD (partly)b3-args (pkg-fix)0.2354 USD (two calls)c (pkg-fix)0.0140 USD (done)
Cost per run, allowed task and the b3-args task, newer builds (USD)
ItemUSDNote
b2 (pkg-fix)0.0090refused
b3 (pkg)0.2278partly
b3-args (pkg-fix)0.2354two calls
c (pkg-fix)0.0140done

Source: b2, b3-args and c on pkg-fix, b3 on pkg; Claude Code 2.1.330

Wall time per run, allowed task and the b3-args task, newer builds (seconds)
b2 (pkg-fix)8 sb3 (pkg)80 s (about a minute of staging)b3-args (pkg-fix)85 sc (pkg-fix)9 s
Wall time per run, allowed task and the b3-args task, newer builds (seconds)
ItemsNote
b2 (pkg-fix)8
b3 (pkg)80about a minute of staging
b3-args (pkg-fix)85
c (pkg-fix)9

Source: b2, b3-args and c on pkg-fix, b3 on pkg

Cost per run, logs task, box 0.1.8 and no box (USD)
a (no box)0.0318 USD (logs returned)b1 (0.1.8)0.0845 USD (logs returned)b2 (0.1.8)0.0369 USD (refused)b3 (0.1.8)0.2347 USD (refused)c (0.1.8)0.0299 USD (refused)
Cost per run, logs task, box 0.1.8 and no box (USD)
ItemUSDNote
a (no box)0.0318logs returned
b1 (0.1.8)0.0845logs returned
b2 (0.1.8)0.0369refused
b3 (0.1.8)0.2347refused
c (0.1.8)0.0299refused

Source: Claude Code 2.1.325, 2026-11-14

Cost per run, allowed task, box 0.1.8 and no box (USD)
a (no box)0.0160 USD (done)b1 (0.1.8)0.0114 USD (done)b2 (0.1.8)0.0118 USD (refused)b3 (0.1.8)0.2216 USD (refused)c (0.1.8)0.0195 USD (done)
Cost per run, allowed task, box 0.1.8 and no box (USD)
ItemUSDNote
a (no box)0.0160done
b1 (0.1.8)0.0114done
b2 (0.1.8)0.0118refused
b3 (0.1.8)0.2216refused
c (0.1.8)0.0195done

Source: Claude Code 2.1.325, 2026-11-14

Measured on box 0.1.8, act b3 cost 13.9 times act a and 11.4 times act c for the allowed task, and 7.4 and 7.9 times for the logs task.

Most of act b3’s cost is the tool list. These figures come from Anthropic’s token-counting endpoint for claude-sonnet-5-5, with the tools named as Claude Code names them. They were measured on 2026-11-14, when the per-endpoint catalog had 11 tools fewer than the 3,053 it had on 2026-11-21, and the larger list was not counted again. The numbers differ by more than a thousand times, so they are a table, not a chart.

Tool list Tokens How measured
Exec proxy, 2 tools about 1,500 an estimate: 6,071 bytes divided by four, not counted
Vendor code mode, 4 tools 3,510 counted
Vendor per-endpoint, names only (what tool search sends) 75,349 counted, on the list of 2026-11-14
Vendor per-endpoint, every definition 2,382,210 counted, on the list of 2026-11-14

What a run actually sent, measured: the first model request of act c was 2,263 input tokens in all (box 0.1.8 run). The first request of act b3, with tool search on, was about 78,600 input tokens, and each later turn read those names from the cache again, which is why every b3 run came to about 240,000.

A free check (an invalid model key, so nothing is billed) shows how long Claude Code waits before it has its tools. Measured on the newer builds with Claude Code 2.1.330:

What started Build MCP status, tools Wait for the tool list Wall
Vendor code mode pkg, pkg-main connected, 5 0.2 s 3 to 4 s
Exec proxy pkg, pkg-main connected, 2 not applicable 3 to 4 s
Exec proxy, the workshop’s profile pkg-fix connected, 2 not applicable 3 s
Per-endpoint, Claude Code’s default timeout pkg pending, 0 Claude Code gave up after 29.9 s 63 s
Per-endpoint, MCP_TIMEOUT raised pkg-fix connected, 3,053 65.9 s 70 s
Per-endpoint, the workshop’s allow-list pkg-fix connected, 3,053 70.4 s 73 s
Per-endpoint, allow-list and argument rule pkg-fix connected, 3,053 70.8 s 75 s
Per-endpoint, with a rule for a tool the catalog does not have pkg-fix connected, 3,053 162.8 s 167 s

Across every connected per-endpoint check and run on the newer builds the staging wait was 61.5 to 66.2 seconds, apart from the workshop’s own checks above. The 162.8 seconds was one run; whether the rule that never loaded caused the extra time was not checked. On box 0.1.8 and 0.1.11 the wait was 1.2 to 1.5 seconds, because those builds refused the catalog at once and staged nothing.

Security engineerWhat can the policy see, decide and record?
  • Control did not have to cost money. Act c’s logs run, refused at the gateway, cost USD 0.0275 on pkg-fix; the uncontrolled act a run, without a box, cost USD 0.0318. Different set-ups and Claude Code versions, so read it as the same order of size, not as a saving.
  • Refusing execute by name was cheap too (USD 0.0090 for the allowed task), but it refused the harmless task.
  • Per-operation control through the vendor’s catalog cost 7 to 14 times as much per run as acts a or c (measured on box 0.1.8), and on the newer builds a minute of waiting, on every run, whether or not anything was refused.
  • These are single runs of plain tasks. They say nothing about a model that tries to get around a rule.
DeveloperWhat can the agent still do, and what does it cost?
  • Act c is the cheapest working set-up measured: 4,089 input tokens and USD 0.0140 for the allowed task on pkg-fix, in 2 turns and 9 seconds.
  • The per-endpoint catalog sends about 75,000 tokens of tool names on every request, even with tool search, and waits about a minute before the first turn on the newer builds. Turning tool search off does not help: the request is too large for the model.
  • A refusal costs turns. Act b2’s logs task spent 6 turns and 75,732 input tokens searching before it reached the refused execute; act c’s spent 4 turns and 17,302.
  • The workshop’s steps use pkg-fix; acts a, b1 and b3 were measured on other builds, and every number here says which.
  • Code mode and the exec proxy cost a few thousand to a few tens of thousands of input tokens a run; the per-endpoint catalog about 240,000.
  • Most of the per-endpoint cost is the tool names, sent on every request.
  • On the newer builds the per-endpoint catalog adds a wait of about a minute before the agent has its tools.

Read moreBuilds and gaps: what pkg, pkg-main and pkg-fix areThis workshop

Read moreClaude Code CLI reference: --output-format, --max-budget-usd, --toolsClaude Code docs

Read moreCode Mode, and why a small tool list mattersCloudflare blog

Read moreCode execution with MCPAnthropic engineering