Skip to content

Persistent shell session wedges silently when its stored cwd is deleted (git worktree remove); all subsequent spawns return no exit status #1529

Closed

Description

@mattwyckhouse

Summary

When a persistent shell session's stored working directory is deleted out from under it — git worktree remove being the everyday trigger for agent workflows — the session wedges: every subsequent command in that session returns no exit status, with no output and no error text. Nothing self-heals; an agent (or coordinator thread) that doesn't know the workaround is dead in the water. We took a 65-minute multi-agent pipeline outage from this before isolating it.

Reproduction (100% reliable, disposable)

  1. Create a scratch git repo and git worktree add ../wt.
  2. cd the persistent session INTO the worktree.
  3. From anywhere, git -C <base> worktree remove <wt> --force. The removal itself completes fine (exit 0). The session's stored cwd is now a deleted directory.
  4. The very next new command in that session (echo hi; git status — anything, including shell builtins) returns no exit status. Pure silence, no error. Every subsequent command in the session behaves identically.

Discriminator / workaround

The same command with an explicit working_directory override to a valid directory recovers immediately (~134ms in our repro) — and fully heals the session: subsequent plain commands work again, with cwd persisted at the override target. So the fault is in the session-spawn path when the stored cwd no longer exists, not anything above it.

Incident datapoints (beyond the controlled repro)

  • 2026-08-13 ~06:31 ET: a coordinator thread's session wedged immediately after a git worktree remove --force of a scratch worktree, where a concurrently-launched background session had inherited the removed worktree as cwd. Even echo alive never returned. 60+ minutes of spaced retries never recovered; only an app restart did (the operator did not know the override workaround).
  • 2026-08-12 evening: an independent session in the same installation wedged after git worktree add churn, and recovered exactly via a command with a different explicit working directory.

Expected behavior

Any of these would be fine:

  • The session spawn detects the missing cwd and falls back (home, workspace root, or last-valid ancestor) — ideally with a warning line.
  • Or the command fails loudly ("session cwd no longer exists") instead of returning silence with no exit status.

Silent no-exit-status is the worst case: agents interpret it as a hung command, retry into the same wedged session, and conclude the environment is dead.

Environment

macOS (darwin 25.5.0, Apple Silicon), bb app 0.37.0. Happy to rerun the repro under any instrumentation you want.

Activity

  1. added theissue type on Aug 13, 2026
  2. added
    workspaces
    on Aug 18, 2026
  3. SawyerHood commented on Aug 18, 2026

    @SawyerHood
    Collaborator

    Reproduction & root-cause report: https://get-bb.github.io/reports/issues/1529.html

    • Verdict: REPRODUCED · root-cause confidence: high
    • Root cause (short): The "persistent shell" is Cursor's Shell tool (bb provider acp-cursor): its executor re-spawns each command with cwd = the cwd persisted from the last state dump, Node's spawn fails with ENOENT once that directory is deleted, the error is thrown instead of yielding an exit event (Cursor backend: "returned no exit status"), and the stored cwd is only repaired after a successful run, so it stays wedged until a working_directory override; bb additionally fabricates exitCode 0 for these (and for genuinely non-zero) Cursor calls in plugins/provider-acp/src/event-translation.ts because it derives exit codes from ACP status alone.
    • Proposed fix: Upstream (Cursor CLI, file with repro): in BashState/ZshState.execute stat the resolved cwd before spawn; if missing fall back to the request/session working directory (or nearest existing ancestor), reset this.cwd, prepend a warning line, and convert spawn 'error' into an exit item with non-zero code so the model always gets a status (Grok Build already does this). bb side (plugins/provider-acp/src/event-translation.ts, translateAcpToolCallItem + completeAcpStartedToolItem): read rawOutput.exitCode when it is a finite number; when absent keep 1 for status 'failed' but OMIT exitCode for status…
    • Caveats: Revision addressed the verifier's findings: (major) section 4b was not followable because repro/bbdev.sh hard-coded the original author's ports/worktree; bbdev.sh and run-bb-cursor.sh now take BB_SERVER_URL/BB_WORKTREE from the environment, the report spells out every command including the raw bb thread spawn and project-creation curl, and the revised steps were re-run end to end on a fresh work…

    The report has copy-paste repro steps, screenshots where the bug is visual, code permalinks at 16ceb3a54, and repro artifacts. It was independently re-run by a second agent (see its Verification section).

    AGENT GENERATED: by Claude Opus 5

  4. added
    confirmed-repro
    on Aug 18, 2026
  5. self-assigned this
    on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

confirmed-reproworkspaces

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions