Skip to content

thread spawn --parent-self ignores --machine for Personal-project children and reuses the parent's environment #5204

Closed

Description

@mathias-pedersen

Summary

From a thread in the Personal project, bb thread spawn --parent-self --project proj_personal --machine <remote> creates the child on the parent's machine, reusing the parent's environment. --machine is silently ignored, and adding --new-environment personal or --environment-provider personal-workspace does not help. The same spawn without a parent lands on the remote machine as expected.

Versions and environment

  • bb 0.45.0 (desktop app), server on macOS 27.0.1
  • Remote machine: Windows PC enrolled with the manual machine provider, status connected, personal-workspace provider available on it
  • Provider: claude-code (Claude Code 2.1.294)
  • Parent thread runs in a Personal workspace on the server machine

Steps to reproduce

  1. Enroll a second machine (any OS) and confirm it is available:
    bb environment providers --project proj_personal --machine <remote> → personal-workspace Personal workspace projectless availability: available
  2. From inside a Personal-project thread on the server machine, run:
    bb thread spawn --parent-self --project proj_personal --machine <remote> --new-environment personal --prompt "Reply with your hostname." --json
  3. Inspect the child: bb thread show <child-id> --json.

Also reproduced with each of these variants:

  • no --new-environment
  • --environment-provider personal-workspace in place of --new-environment personal
  • BB_ENVIRONMENT_ID unset (env -u BB_ENVIRONMENT_ID bb thread spawn …)

Did not reproduce without a parent: the same command without --parent-self provisions a new personal workspace on the remote machine. After that, bb thread update <child-id> --parent-thread <parent-id> attaches it fine.

Expected vs actual

Actual (with --parent-self), returned immediately by spawn:
  "environmentId": "env_ga3ygzes3f"        <- the parent's environment
  environment.hostId: "host_hahfxsy886"    <- server machine, not <remote>
  environment.path: ~/.bb/plugins/environment-personal-workspace/host-data/workspaces/<parent thread id>

Without --parent-self:
  "environmentId": null  (provisioning), then "env_ygm6vmtv23"
  environment.hostId: "host_yke3wri6qt"    <- <remote>
  environment.path: C:\Users\<user>\.bb-machines\...\workspaces\thr_mamrpqbdhj

Expected: an explicit --machine that differs from the parent environment's host should produce a new personal workspace on that machine. Reusing the parent environment is fine when no machine is given, or when it is the same machine. If reuse is intended, bb should reject the conflicting --machine rather than ignore it.

Impact: the child agent ran on the wrong machine with a prompt meant for the remote one (here, Windows PowerShell commands ran on macOS) before I noticed and stopped it.

Evidence

  • Parent: thr_99dmaej8n3, environment env_ga3ygzes3f (personal-workspace, host host_hahfxsy886)
  • Misplaced children, all with environmentId: env_ga3ygzes3f: thr_ptgxvac3sj (plain --machine), thr_z4qqibd3vu (--new-environment personal), thr_m69n7iwu45 (BB_ENVIRONMENT_ID unset), thr_zpjckpbgff (--environment-provider personal-workspace)
  • Correct placement without a parent: thr_mamrpqbdhj, environment env_ygm6vmtv23, host host_yke3wri6qt

Suspected cause, from reading the code (not confirmed with a test): the first branch of resolveCreateThreadEnvironment returns { type: "reuse", environmentId: parentThread.environmentId } whenever parent and child are both in the Personal project and the request is any personal-workspace form. It never compares the requested machine with the parent environment's hostId:

const parentThread = args.parentThread;
const hasLiveParent = isLiveParentThread({ parentThread });
if (
hasLiveParent &&
parentThread?.projectId === PERSONAL_PROJECT_ID &&
args.projectId === PERSONAL_PROJECT_ID &&
isPersonalWorkspaceEnvironment(args.requestedEnvironment)
) {
if (!parentThread.environmentId) {
throw new Error("Personal parent thread is missing an environment");
}
return { type: "reuse", environmentId: parentThread.environmentId };
}

isPersonalWorkspaceEnvironment matches project-default, host + workspace.type === "personal", and the personal-workspace provider. So every form of the request, including one carrying an explicit machine, takes the reuse path:

function isPersonalWorkspaceEnvironment(
environment: CreateThreadEnvironment,
): boolean {
return (
environment.type === "project-default" ||
(environment.type === "host" &&
environment.workspace.type === "personal") ||
(environment.type === "provider" &&
environment.environmentProviderId ===
DEFAULT_ENVIRONMENT_PROVIDER_ID.personalWorkspace)
);
}

Possible fix: take the reuse branch only when the request has no explicit machine, or when its machine equals the parent environment's hostId. Otherwise fall through to the normal personal-workspace provisioning on the requested machine.

What you ruled out

Suggested priority and effort (optional)

Medium. It hits anyone delegating from a Personal thread to another machine, and the child silently runs on the wrong host. Workaround: spawn without a parent, then bb thread update --parent-thread. 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 GENERATED and links the thread or report.

Investigated in bb thread thr_99dmaej8n3 (local install, not publicly linkable).

AGENT GENERATED

Activity

  1. added theissue type on Oct 8, 2026
  2. added
    workspaces
    cli
    confirmed-repro
    on Oct 8, 2026
  3. bb-slop-cop commented on Oct 8, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: Medium · Effort: Low. Labels: workspaces, cli, confirmed-repro.
    • Report: Reproduction and root cause — REPRODUCED, high confidence, at the server-policy boundary in two clean trusted-main checkouts. Real cross-OS agent sessions were not exercised.
    • Root cause: Personal-child placement returns parent-environment reuse before comparing the requested machine with the parent's host, discarding different-host and new-machine selections.
    • Fix: PR #5207 preserves those selections while retaining omitted-machine and matching-host reuse. Ready for review; not merged.
    • Verification: Three regression cases fail before the fix in both checkouts; all 137 relevant tests pass afterward. Server typecheck, formatter, and git diff --check pass. Two files, 95 changed text lines.

    AGENT GENERATED

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

    cliconfirmed-reproworkspaces

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions