Repository navigation
Description
Summary
Clearing context on a Pi-backed thread should keep the BB thread but start an empty provider session. Instead, provider-pi uses the BB thread ID as the Pi session handle again, selecting the same persisted transcript.
I reproduced the session-selection bug through the provider bridge with a fake Pi child and real Pi session-file reads. I have not verified the complete clear-command-to-model flow with live inference.
Versions and environment
- BB source inspected at
d89160eb8c69c1e3ebc2ba2514f1711af8d7c506. - Provider:
bb-plugin-provider-pi. - Persistence checks use Pi 0.84.0's
SessionManager. - Local source checkout on macOS.
- No model calls or paid inference were needed.
Steps to reproduce
The reproduction exercises the provider lifecycle used to replace a session while retaining the BB thread.
- Send
thread/startfor BB threadthr_lc_start_fresh. Record the returnedproviderThreadIdand selected session file. - Send
thread/stopwithintent: "release"and wait for the child to exit. - Open the saved file with Pi's
SessionManager.openand append a user message containinglegacy session sentinel. Independently reopen the file to confirm the message persisted. - Send
thread/startagain with the same BB thread ID. - Compare the returned provider handle and selected session file with those from the first start.
The local regression test is named start_after_release_selects_fresh_pi_session. It runs through the existing fake-child bridge test setup, not a separate mock of start allocation.
Expected vs actual
Expected:
• The BB thread ID stays unchanged.
• The second start returns a different Pi session handle.
• The selected session has an empty message context.
• The earlier session file remains unchanged.
Actual:
Both starts return thr_lc_start_fresh as the provider handle and select the same session file.
With the old allocation restored, the regression fails at:
expect(newProviderThreadId).not.toBe(oldProviderThreadId);
Both values are thr_lc_start_fresh.
Evidence
The start handler passes request.params.threadId as both the BB routing ID and the provider session handle:
bridge.ts, lines 552–558
These IDs have different purposes. The BB ID identifies the conversation. The provider handle selects Pi's persisted session file. Reusing the BB ID on a new start therefore selects the previous transcript.
A local fix generates a fresh pi_<UUID> handle only for thread/start. The regression then passes, including independent reads proving that the new context is empty and the old file is unchanged. Release/resume and legacy-handle tests also pass.
The local investigation and fix are recorded in commit fb2019c258762320e9dc4a8fdfe1c2d480ee2ea0. That commit has not been published, so there is no public patch link yet.
What you ruled out
- Normal resume is not the problem.
thread/resumeshould reopen the supplied session handle, and the compatibility tests retain that behavior. - The fixture checks independently reopen the persisted file before testing the second start, so the reproduction does not depend on an unflushed in-memory message.
- This is separate from Pi thread cannot resume after its original worktree is removed following an environment switch #3634 (now closed), which concerns a saved session's working directory after an environment change.
- A follow-up search of open issue titles and bodies for Pi, clear context, session reuse, and provider start behavior found no matching open duplicate. Server resumes a thread into whichever provider thread its latest event names, with no cross-thread ownership check #3461 concerns cross-thread provider identity selection; bb thread stop reports success but leaves a stray daemon turn, so every send is refused ("Refusing to start a competing turn") #3462 concerns a release that leaves an active turn running.
- Full BB clear-command delivery, real model behavior, and facets integration remain unverified.
AGENT GENERATED
Suggested priority and effort (optional)
No response
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 GENERATEDand links the thread or report.
Activity
bb-slop-cop commentedon Sep 14, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotBug · Medium priority · Low effort —
providers,provider-pi,confirmed-repro.Reproduction and root-cause report: REPRODUCED, high confidence. Two clean checkouts of trusted main reopened the same Pi session file with two retained messages. Fresh starts reuse the stable BB thread ID as the persistence handle. Live inference and the complete clear-command flow remain unverified.
The focused regression fails on main and passes with a fresh-handle allocation. All 155 existing tests pass before the fix; the trial exposes nine old-handle assertions across five test files. No PR: updating those files plus production code exceeds the rule’s five-file limit. The trial remains unpushed.
fix(provider-pi): start a fresh session when clearing context (get-bb…