Repository navigation
Description
Summary
Found while chasing mise WARN failed to write cache file ... Operation not permitted on every command inside bb threads. bb starts each Claude Code thread with its own sandbox option through the Agent SDK, and Claude Code then drops the sandbox.filesystem.allowWrite list from ~/.claude/settings.json. Any tool that writes a cache outside the workspace (mise, bun, pnpm, maestro) fails inside a bb thread and works in a plain claude session. I expected bb to add its roots to my sandbox policy, not replace it.
More generally: we think bb should try to incorporate the user's local sandbox and permission settings wherever it can, for every provider. The user's ~/.claude/settings.json and ~/.codex/config.toml already say which paths, commands, and domains they trust. When bb hands a provider a policy of its own, it should start from that and extend it with the environment's roots, rather than start from a fixed policy and lose what the user configured. #2524 asks for the same shape on the Codex side.
Versions and environment
- bb 0.41.0 (desktop app), macOS 26 (Darwin 25.5.0)
- claude-code, claude 2.1.259,
@anthropic-ai/claude-agent-sdk0.3.245 - Local (non-worktree) environment, permission scope
workspace, modeauto ~/.claude/settings.jsonhassandbox.filesystem.allowWrite: ["~/Library/Caches", "~/.bun/install/cache", "~/.cache", ...]
Steps to reproduce
Without bb, using the options bb passes from buildWorkspaceWriteSandbox:
- Put
"sandbox": {"enabled": true, "filesystem": {"allowWrite": ["~/Library/Caches"]}}in~/.claude/settings.json. - Save bb's SDK sandbox option as a settings file:
cat > /tmp/bb-sandbox.json <<'JSON' {"sandbox":{"enabled":true,"failIfUnavailable":false,"autoAllowBashIfSandboxed":true,"allowUnsandboxedCommands":false,"network":{"allowLocalBinding":true},"filesystem":{"allowWrite":["/Users/<handle>/.bb/thread-storage"]}}} JSON
- Run:
claude -p --model haiku --setting-sources user,project,local --settings /tmp/bb-sandbox.json \ 'Run exactly this one bash command and report its output verbatim: touch ~/Library/Caches/bb-probe && echo WRITE_OK'
In bb: open a Claude Code thread in auto mode and send the same prompt.
Did not reproduce with: the same claude -p command without --settings. The user list is honored and WRITE_OK prints.
Expected vs actual
# actual, step 3 and inside a bb thread
touch: /Users/<handle>/Library/Caches/bb-probe: Operation not permitted
# mise, on every command inside a bb thread
mise WARN failed to write cache file: /Users/<handle>/Library/Caches/mise/neovim/0.12.4/exec_env_....msgpack.z Operation not permitted (os error 1)
# expected
WRITE_OK
Expected: the effective sandbox is my allowWrite list plus bb's roots. The Claude Code sandboxing docs say filesystem arrays merge across settings scopes, and bb passes settingSources: ["user", "project", "local"], so the user entries should survive.
Evidence
bb builds the option here, and filesystem.allowWrite only ever holds additionalWorkspaceWriteRoots:
// plugins/provider-claude-code/src/bridge/session-options.ts, buildWorkspaceWriteSandbox()
const allowWrite = params.additionalWorkspaceWriteRoots ?? [];
return {
enabled: true,
failIfUnavailable: false,
autoAllowBashIfSandboxed: true,
allowUnsandboxedCommands: true,
network: { allowLocalBinding: true },
...(allowWrite.length > 0
? { filesystem: { allowWrite: [...allowWrite] } }
: {}),
};bb/plugins/provider-claude-code/src/bridge/session-options.ts
Lines 192 to 210 in 874958b
| function buildWorkspaceWriteSandbox( | |
| params: BuildSessionOptionsArgs, | |
| ): Options["sandbox"] | undefined { | |
| if (!usesWorkspaceSandbox(params)) { | |
| return undefined; | |
| } | |
| const allowWrite = params.additionalWorkspaceWriteRoots ?? []; | |
| return { | |
| enabled: true, | |
| failIfUnavailable: false, | |
| autoAllowBashIfSandboxed: true, | |
| allowUnsandboxedCommands: true, | |
| network: { allowLocalBinding: true }, | |
| ...(allowWrite.length > 0 | |
| ? { filesystem: { allowWrite: [...allowWrite] } } | |
| : {}), | |
| }; | |
| } |
Those roots are the worktree's git roots plus thread storage. Nothing there reads user settings:
bb/apps/host-daemon/src/runtime-manager.ts
Lines 320 to 328 in 874958b
| private runtimeWorkspaceWriteRoots( | |
| args: RuntimeWorkspaceWriteRootsArgs, | |
| ): string[] { | |
| const roots = [...args.workspaceRoots]; | |
| if (args.threadStorageRootPath) { | |
| roots.push(args.threadStorageRootPath); | |
| } | |
| return [...new Set(roots)]; | |
| } |
settingSources includes user, so this is not the "excluded source" case the docs describe:
| settingSources: ["user", "project", "local"], |
The effective sandbox config Claude Code reports inside a bb thread lists ., $TMPDIR, /tmp/claude, and ~/.bb/thread-storage as writable and none of the user entries.
Over 7 days of my local Claude Code transcripts I counted 1,252 dangerouslyDisableSandbox retries. The largest groups were bun cache writes, ~/.bb-dev, ~/.local/state, and /var/folders (maestro flows). Every one of those paths is in my allowWrite list.
Thread: thr_6hxm52ewwi, project proj_dhxdkz286e.
What you ruled out
- Not a stale settings file: the live
~/.claude/settings.jsonhas the list and a plainclaudesession honors it. - Not feat(codex): select named permission profiles in execution controls #2524: that one is the Codex provider, where
sandbox_workspace_write.writable_rootsreplaces the user'sdefault_permissionsprofile. Same shape, different provider. - Workaround:
Edit(~/Library/Caches/**)inpermissions.allowsurvives, because Claude Code mergesEditallow rules from every loaded source into the sandbox write set. Step 3 printsWRITE_OKafter adding it. That means mirroring everyallowWriteentry as anEditrule, which also widens what the Edit tool may write without a prompt.
Proposal
We should read sandbox.filesystem.allowWrite from the user's settings and append it in buildWorkspaceWriteSandbox, or omit filesystem when the runtime has no extra roots so Claude Code falls back to the user policy. The same principle applies to excludedCommands, network.allowedDomains, and the Codex profile in #2524: bb's policy should be the user's policy plus the environment's roots.
Suggested priority and effort
Medium. Hits every Claude Code user who relies on allowWrite for mise, bun, or pnpm caches. Workaround exists but is non-obvious. Effort probably Low.
Checks
- I reproduced this on the latest release or on
main, or I say above that I could not. - I searched open and closed issues for the same problem.
- If an agent wrote this, the body ends with
> AGENT GENERATEDand links the thread or report.
AGENT GENERATED — bb thread
thr_6hxm52ewwi
Activity
bb-slop-cop commentedon Sep 4, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotproviders,provider-claude-code,confirmed-reproconfirmed-repro; the focused regression test failed identically on trusted main in two clean checkouts.Decide agent writable folders per session; grant each thread only its…