Repository navigation
Description
Summary
A Pi-backed BB thread can retain its original worktree in the saved Pi session after update_environment_directory moves the thread to another worktree. Once the original worktree is removed, a later turn cannot start, although BB has a valid current environment.
The thread must resume in the new environment, or fail before the environment switch is committed. It must not retain a hidden dependency on the old worktree.
Versions and environment
- bb 0.43.0; remote Linux host, x86_64
- Pi provider;
pi0.85.1 in RPC mode - BB-managed Git worktree moved to another existing Git worktree on the same host
- Observed and retried in an existing thread. A clean, from-scratch reproduction against public
mainwas not run.
Steps to reproduce
- Start a Pi-backed BB thread in a managed Git worktree, A.
- Create or select a second existing worktree, B, for the same repository.
- During a thread turn, call
update_environment_directorywith B. The tool reports that the change applies to future turns and stops the current turn. - Remove A (or allow its managed-worktree cleanup to remove it).
- Send another message to the thread.
Expected vs actual
Expected: The resumed provider process and all agent tools run from B, the thread's current BB environment.
Actual: Pi opens the saved session, reads A from its session header, and rejects the turn because A no longer exists. In the affected run, BB had already recorded the alternate worktree as the thread environment before the failure.
Sanitized relevant output:
pi exited (code 1, signal null): Stored session working directory does not exist: <original worktree A>
Session file: <Pi session file>
Current working directory: <thread environment>
Before A was removed, later tool calls resolved relative paths against A, not B. This means the defect can silently operate in the wrong checkout before becoming a hard failure.
Evidence
The public BB 0.43.0 Pi-provider source both starts the child process in the supplied environment cwd and resumes the saved Pi session with --session:
Pi then reads the session header cwd and, in non-interactive mode, exits if that directory is missing rather than using the process cwd:
BB has a partial missing-cwd fallback for its own provider-session construction, but that does not update the Pi session header before the child is launched with --session:
Related issue
This is related to #3187, which reports a Pi environment-directory update that strands a tool call and then leaves later turns in the old directory. It does not report the distinct post-cleanup resume failure above. Its automated triage identifies the same stale session-cwd mechanism.
What was ruled out
- The original session did not issue a shell command to remove its original worktree.
- The destination worktree existed and was a valid Git worktree when BB accepted the environment change.
- Source inspection indicates that the current Claude Code and Codex providers supply the current BB cwd separately from their resume identity. This is not an end-to-end comparison.
- The ACP provider was not assessed.
Suggested priority and effort
High — a thread can edit the wrong checkout without an immediate error and later becomes impossible to resume after normal cleanup. Workaround: create a new provider session in the intended worktree. Likely medium effort: define and implement a durable Pi session-relocation path.
Checks
- I reproduced this on the installed bb 0.43.0 / Pi 0.85.1 setup; a clean reproduction on public
mainwas not run. - I searched open and closed issues; update_environment_directory commits the switch but strands the Pi tool call until manual interruption #3187 is related but does not cover this post-cleanup resume failure.
AGENT GENERATED — investigation performed in a private BB thread; no public-safe thread or report link is available.
Activity
bb-slop-cop commentedon Sep 14, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotBug · High priority · Medium effort. Applied
providers,provider-pi, andconfirmed-repro.Reproduction and root-cause report — REPRODUCED, high confidence. A focused regression test using the real repository-pinned Pi executable fails in two clean checkouts: BB accepts the replacement cwd but passes an unchanged session whose header points to the deleted directory. The 12 existing related tests pass, including the fake-Pi fallback test.
No PR: durable session relocation requires a persisted-state or environment-switch policy decision outside this rule’s simple-fix limits. The full environment-switch UI journey was not exercised.
SawyerHood commentedon Sep 14, 2026
Consolidated into #3187 at the owner’s request. The canonical tracker now preserves this report’s additional evidence and acceptance requirements. Closing as duplicate/covered scope, not as fixed.