Skip to content

provider-pi reuses the previous session when clearing context #3673

Closed

Description

@samanthar0se

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.

  1. Send thread/start for BB thread thr_lc_start_fresh. Record the returned providerThreadId and selected session file.
  2. Send thread/stop with intent: "release" and wait for the child to exit.
  3. Open the saved file with Pi's SessionManager.open and append a user message containing legacy session sentinel. Independently reopen the file to confirm the message persisted.
  4. Send thread/start again with the same BB thread ID.
  5. 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

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 GENERATED and links the thread or report.

Activity

  1. added theissue type on Sep 14, 2026
  2. added
    providers
    provider-pi
    confirmed-repro
    on Sep 14, 2026
  3. bb-slop-cop commented on Sep 14, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    Bug · 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.

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

    confirmed-reproprovider-piproviders

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions