Skip to content

bb thread spawn --parent-self from a Personal thread that moved to an attached directory always fails with "Personal project threads must reuse a personal workspace" #7256

Closed

Description

@benwaffle

Summary

A Personal-project thread that has switched its working directory with update_environment_directory can no longer spawn Personal children with --parent-self. Every environment flag combination is rejected. bb still tries to reuse the parent's current environment, an unmanaged attached directory, and then the reuse check rejects that environment because it is not a personal workspace. Five minutes after the move, the thread's original personal workspace is torn down, so it cannot be reused either.

The same spawn without --parent-self succeeds and provisions a new personal workspace.

Versions and environment

  • bb 0.48.1 (desktop app), upstream main at faec441
  • Server and thread on the same macOS machine
  • Provider: claude-code

Steps to reproduce

  1. Start a scratch thread in the Personal project (a new personal workspace).
  2. In that thread, have the agent call update_environment_directory with any existing absolute directory outside bb's data dir, for example mkdir -p ~/scratch-dir and then ~/scratch-dir. End the turn.
  3. On the next turn, from inside the thread, run each of these commands:
    bb thread spawn --project proj_personal --parent-self --prompt "say hi" --json
    bb thread spawn --project proj_personal --parent-self --new-environment personal --prompt "say hi" --json
    bb thread spawn --project proj_personal --parent-self --environment-provider personal-workspace --prompt "say hi" --json
    bb thread spawn --project proj_personal --parent-self --environment "$BB_ENVIRONMENT_ID" --prompt "say hi" --json
    bb thread spawn --project proj_personal --parent-self --environment ~/scratch-dir --prompt "say hi" --json
  4. Wait more than 5 minutes, then try --environment <original personal workspace env id>. The id is in previousEnvironmentId of the thread's "Updated environment directory" event.
  5. Run the first command without --parent-self.

Expected vs actual

Actual:
  (no env flag)                          409 Personal project threads must reuse a personal workspace
  --new-environment personal             409 Personal project threads must reuse a personal workspace
  --environment-provider personal-workspace  409 Personal project threads must reuse a personal workspace
  --environment <current env id>         409 Personal project threads must reuse a personal workspace
  --environment <path>                   400 Personal project threads must use a personal workspace
  --environment <old workspace env id>   409 Environment unavailable   (status destroyed, teardown removed)
  without --parent-self                  succeeds, new personal workspace

Expected: if the parent's environment is not a personal workspace, a Personal child with no environment flag, or with --new-environment personal, gets a fresh personal workspace, the same result as without --parent-self. --new-environment is documented as "Create a fresh environment of the given kind", so reusing the parent's environment for --new-environment personal is also surprising when the parent is in a personal workspace.

Root cause

resolveCreateThreadEnvironment (apps/server/src/services/threads/thread-default-policy.ts) has a branch for a live Personal parent. When the request is project-default, host + workspace: personal, or provider: personal-workspace, and no other machine is named, it returns { type: "reuse", environmentId: parentThread.environmentId }. It does not check that the parent environment is a personal workspace.

After update_environment_directory, parentThread.environmentId points at an unmanaged environment (environmentProviderId is null). assertReuseWorkspaceProjectCompatibility (thread-request-eligibility.ts) then throws 409 "must reuse a personal workspace", because isPersonalWorkspaceEnvironment(row) requires a non-null environmentProviderId.

Each of the other variants fails at a different check:

  • An explicit path becomes host/unmanaged with a path. assertProjectWorkspaceCompatibility (thread-create.ts) only allows Personal threads reuse, provider, project-default, implicit host default, or personal, so it returns 400.
  • The original workspace has no live threads after the move. The environment engine gives it a retireAt equal to the default retireGraceMs (300 000 ms) and then removes it. Reusing it hits throwEnvironmentNotReady.

The parent-reuse branch is intentional: #5204 asked for reuse to apply only when the request names no other machine. The branch is missing a guard for a parent that is no longer in a personal workspace.

Suggested fix

In the Personal-parent branch of resolveCreateThreadEnvironment, reuse the parent environment only when it is a ready personal workspace (environmentProviderId === personal-workspace, not torn down). Otherwise fall through to the normal fresh-personal-workspace path. Consider treating --new-environment personal (host + workspace: personal) as a request for a fresh workspace, as its help text says.

What I ruled out

Workaround

Spawn without --parent-self, then run bb thread update <child-id> --parent-thread "$BB_THREAD_ID".

AGENT GENERATED

Activity

  1. added theissue type on Nov 7, 2026
  2. added
    workspaces
    threads
    confirmed-repro
    on Nov 7, 2026
  3. bb-slop-cop commented on Nov 7, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: Medium · Effort: Low. Applied labels: threads, workspaces, confirmed-repro.
    • Verdict: REPRODUCED · root-cause confidence: high. All three server-boundary regression cases fail on unchanged trusted main in two clean checkouts.
    • Root cause: Personal-child placement automatically reuses the parent's unmanaged attached directory; the workspace compatibility validator correctly rejects it.
    • Report: https://get-bb.github.io/reports/issues/7256.html — includes the reproduction patch, clean-run evidence, and code permalinks. Live desktop/CLI behavior and retirement timing were not exercised.
    • Fix: Let Personal threads share a folder their parent moved into #7258 — ready, not merged. Guards automatic reuse while preserving valid-parent reuse semantics. 98 changed text lines across three files; 126 tests pass, with server typecheck and diff checks passing.
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-reprothreadsworkspaces

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions