Skip to content

provider-pi bridge: resumed session can use a stale extensionPath from a dead bridge worker's temp dir (ENOENT on pi-tools-*.json at extension load) #5350

Open

Description

@cameronm123

Summary

A pi-provider thread failed at startup with pi exited (code 1): the extension pi was told to load (--extension) lived in one bridge worker's temp dir, while the PI_BB_TOOLS_FILE env pointed at a tools JSON in a different bridge worker's temp dir that had already been cleaned up. The user's ~/.pi config (settings, extensions, auth) is unaffected — pi runs fine headless.

Error

pi exited (code 1, signal null): Error: Failed to load extension "/var/folders/.../T/bb-provider-bridge-provider-pi-31ArBw/pi/bb-pi-extension.mjs": Failed to load extension: ENOENT: no such file or directory, open '/var/folders/.../T/bb-provider-bridge-provider-pi-wb9hmr/pi/pi-tools-92942-1791605506411-338576cb95a64.json'
Hint: Start without extensions using "pi -ne".

Note the two different per-worker temp roots in one spawn:

  • --extension → bb-provider-bridge-provider-pi-31ArBw/pi/bb-pi-extension.mjs (old worker)
  • PI_BB_TOOLS_FILE → bb-provider-bridge-provider-pi-wb9hmr/pi/pi-tools-<pid>-<ts>.json (current worker, pid 92942, 2026-10-10 04:11 UTC)

Environment

  • bb 0.46.0, macOS (darwin), provider plugin provider-pi (host artifact 74defba3…)
  • pi 1.1.0

Diagnosis

In the provider-pi host artifact:

  • spawnAndVerify() writes pi-tools-${process.pid}-${Date.now()}.json into this.options.scratchDir, then spawns pi with --extension this.options.extensionPath and env PI_BB_TOOLS_FILE pointing at that file. It deletes the tools file on child exit.
  • The bridge worker's temp dir (bb-provider-bridge-provider-pi-*, created by the worker bootstrap) is per-process and force-removed on worker exit.
  • bb-pi-extension.mjs is staged/cached per worker process (requireExtensionPath), so a worker restart always produces a new root for both the extension and the tools file.

The failing spawn combined an extensionPath from a previous worker's temp root with scratchDir/tools from the current worker — i.e. a resumed/forked session received a persisted extensionPath that the new worker never staged, and the referenced tools file was already gone (worker exit cleanup and/or macOS tmp purge). pi then exits code 1 at extension load and the thread dies.

Both temp roots involved are purged now; retrying the turn / starting a fresh pi thread works around it because everything is restaged consistently.

Suggested fix

On session start/resume, treat a persisted extensionPath as untrusted: verify it exists inside the current worker's temp root, and restage the extension in the current scratch dir if it doesn't match (e.g. compare the dirname against the active scratch root before spawn, or simply always restage per session like the tools file already is).

Workaround

Retry the failed thread or start a new pi thread — no user-side pi config needs repair.

Activity

  1. added theissue type on Oct 11, 2026
  2. added
    providers
    provider-pi
    no-repro
    on Oct 11, 2026
  3. bb-slop-cop commented on Oct 11, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority High · Effort Medium; providers, provider-pi.
    • Reproduction and root-cause report: NOT REPRODUCED · root-cause confidence low · no-repro.
    • Evidence: Real Pi resumed and forked successfully after the previous worker's temporary root was removed, in two clean checkouts of trusted origin/main (3912f4aae).
    • Root cause: Not established. Current main constructs worker-local extension and tools paths rather than restoring a persisted extension path. The reported macOS/Pi 1.1.0 setup was not replicated; the report documents this limitation.
    • No pull request: No regression reproduces the reported defect on trusted main, so a production fix was not safe.

    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

    no-reproprovider-piproviders

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions