Skip to content

Claude Code threads get the whole thread-storage root as an extra working directory, so agents save files outside their own thread's folder #7625

Closed

Description

@fangerya

Summary

Every Claude Code thread is started with the shared thread-storage root (<data-dir>/thread-storage) as an additional working directory, not the thread's own folder (<data-dir>/thread-storage/<thread id>, the value of BB_THREAD_STORAGE). The root shows up in the agent's system prompt, and agents copy it: one wrote its test reports and a screenshot straight into the root. Anything that only reads the thread's own folder then rejects those files. I expected each thread to see, and be able to write to, only its own folder.

Versions and environment

  • bb 0.49.0 (bb-app via npm, run as a systemd user service), Linux x64. The same code is on main at da3e60b.
  • Provider: Claude Code (claude-opus-5-5).
  • Direct access over Tailscale. The server was moved onto an enrolled machine, so the data dir is the installer default ~/.bb-machines/<server-host>.

Steps to reproduce

  1. Start a Claude Code thread in any project.
  2. Ask: Print your "Additional working directories" line and the output of echo $BB_THREAD_STORAGE.
  3. Compare the two paths.

Expected vs actual

  • Expected: the extra working directory is the thread's own folder, the same path as $BB_THREAD_STORAGE.
  • Actual: the extra working directory is the parent <data-dir>/thread-storage; $BB_THREAD_STORAGE is <data-dir>/thread-storage/<thread id>.

How it went wrong in practice: an agent asked to save test reports for an inline UI block ran

S=<data-dir>/thread-storage && uv run pytest … --junitxml=$S/v4lj-py.xml

then referenced <data-dir>/thread-storage/v4lj-py.xml in its reply. The inline UI plugin refused it: only files in this thread's workspace, its thread storage or /tmp can be loaded. The agent's Claude Code transcript has no mention of that path except the additionalWorkingDirectories entry; the path contains the machine-specific data-dir name, so it could not have been guessed.

Evidence

  • runtimeWorkspaceWriteRoots adds the storage root to every environment runtime's write roots:
    private runtimeWorkspaceWriteRoots(
    args: RuntimeWorkspaceWriteRootsArgs,
    ): string[] {
    const roots = [...args.workspaceRoots];
    if (args.threadStorageRootPath) {
    roots.push(args.threadStorageRootPath);
  • The Claude Code provider passes those roots on as additionalDirectories (--add-dir) and the sandbox allowWrite:
    const additionalDirectories = isWorkspaceWriteSession(params)
    ? (params.additionalWorkspaceWriteRoots ?? [])
    and #L151
  • Only BB_THREAD_STORAGE gets the per-thread path.

A side effect of the same root: every thread's file tools and sandbox are allowed to write into every other thread's storage folder. I read this from the code and did not test it.

What you ruled out

  • Not the plugin: its loader correctly limits reads to the thread's own folder; the file was in the wrong place.
  • Not specific to the data dir: its location only changes the path text. The root is added whenever threadStorageRootPath is set, which includes the default ~/.bb.
  • Searched issues for BB_THREAD_STORAGE, threadStorageRootPath, additionalWorkspaceWriteRoots, "thread storage root": nothing matching. Closest is Agent-launched Desktop inherits parent thread storage root, breaking workflow workers #1366 (closed, different failure).

Suggested priority and effort (optional)

Low to medium. Seen in 1 of ~66 recent threads, and each time it happens the user sees broken output. Workaround: a custom instruction pointing agents at $BB_THREAD_STORAGE. Fix sketch: give each thread its own folder as the extra directory and write root, since the Claude Code session options are built per thread. The runtime is per environment, so the maintainers may prefer a different place for it.

Checks

  • I reproduced this on the latest release or on main, or I say above that I could not. (Seen on 0.49.0, the latest release; on main I read the code but did not run it.)
  • I searched open and closed issues for the same problem.
  • If an agent wrote this, the body ends with > AGENT GENERATED and links the thread or report.

AGENT GENERATED: written by Claude Code in a bb thread on a private instance, from the agent's transcript and the bb 0.49.0 sources.

Activity

  1. added theissue type on Nov 16, 2026
  2. added
    providers
    host
    provider-claude-code
    confirmed-repro
    on Nov 16, 2026
  3. bb-slop-cop commented on Nov 16, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: Medium · Effort: Medium. Applied providers, host, and provider-claude-code; no existing classifications were replaced.
    • Reproduction and root-cause report: REPRODUCED, high root-cause confidence. Reproduction label: confirmed-repro.
    • Root cause: the host includes the shared storage parent in environment-wide write roots. Claude workspace-scoped sessions copy it into additional directories and sandbox write permissions, while BB_THREAD_STORAGE points to the per-thread child.
    • Verification: the configuration-level regression fails at the expected isolation assertion in both trusted-main checkouts; the existing runtime-manager suite passes all 48 tests. Full-access sessions do not advertise these additional directories. No live model turn or sandbox exploit was tested.
    • No PR: correcting this changes filesystem permission/security boundaries, which the rule excludes from automatic simple fixes.
  4. added a commit that references this issue on Nov 17, 2026
    b60ea7d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-reprohostprovider-claude-codeproviders

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions