Repository navigation
Description
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
mainat faec441 - Server and thread on the same macOS machine
- Provider: claude-code
Steps to reproduce
- Start a scratch thread in the Personal project (a new personal workspace).
- In that thread, have the agent call
update_environment_directorywith any existing absolute directory outside bb's data dir, for examplemkdir -p ~/scratch-dirand then~/scratch-dir. End the turn. - 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
- Wait more than 5 minutes, then try
--environment <original personal workspace env id>. The id is inpreviousEnvironmentIdof the thread's "Updated environment directory" event. - 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/unmanagedwith a path.assertProjectWorkspaceCompatibility(thread-create.ts) only allows Personal threadsreuse,provider,project-default, implicit host default, orpersonal, so it returns 400. - The original workspace has no live threads after the move. The environment engine gives it a
retireAtequal to the defaultretireGraceMs(300 000 ms) and then removes it. Reusing it hitsthrowEnvironmentNotReady.
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
- Unrelated to the machine: the parent and child are on the same host. This is not the thread spawn --parent-self ignores --machine for Personal-project children and reuses the parent's environment #5204 path.
- The thread is not archived, and the attached directory environment is
ready.
Workaround
Spawn without --parent-self, then run bb thread update <child-id> --parent-thread "$BB_THREAD_ID".
AGENT GENERATED
Activity
bb-slop-cop commentedon Nov 7, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotthreads,workspaces,confirmed-repro.Let Personal threads share a folder their parent moved into (get-bb#7258