Skip to content

fix(provider-pi): start a fresh session when clearing context - #3677

Merged
SawyerHood merged 1 commit into
get-bb:mainfrom
samanthar0se:fix/plugin-launch-context-remediation
Sep 15, 2026
Merged

SawyerHood merged 1 commit into
get-bb:mainfrom
samanthar0se:fix/plugin-launch-context-remediation

Conversation

@samanthar0se

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

Provider-pi used the BB thread ID as the durable Pi session handle on every thread/start. After releasing a session to clear context, starting the same BB thread selected its previous session file instead of an empty context. The BB routing ID and the provider session handle serve different purposes. See #3673 for the reproduction and investigation.

What changed

thread/start now allocates a fresh pi_<UUID> handle with Node's randomUUID(). The BB thread ID stays unchanged. Production changes are limited to the import and the provider-handle argument passed to session construction.

Resume still opens the supplied handle, including older BB-ID-shaped handles. Rebuild, fork, and discard behavior remain unchanged. No wire fields changed, so no HOST_DAEMON_PROTOCOL_VERSION bump is needed. There are no core, SDK, database, CLI, or documentation changes.

The tests cover same-thread release/start with a fresh empty session, release/resume with persisted context and replacement configuration, and legacy-handle resume. Existing Pi tests now use returned provider handles instead of assuming they equal BB thread IDs.

How you verified

  • start_after_release_selects_fresh_pi_session fails with the old allocation because both starts return thr_lc_start_fresh. With the fix, it verifies distinct safe handles, matching identity announcements on the same BB thread, an empty new context, and unchanged old session bytes.
  • release_resume_preserves_pi_session_and_replaces_configuration verifies the supplied handle, session header, and persisted sentinel survive release/resume, while instructions and tools change and a subsequent fake-child turn succeeds.
  • resume_legacy_pi_session verifies an old BB-ID-shaped handle remains resumable without file migration.
  • Persistence fixtures use the real Pi 0.84.0 SessionManager. Each seeded file is independently reopened to confirm the sentinel persisted.

Ran the provider package checks through Turbo, with prerequisite tasks and cache bypass:

npm exec --yes [email protected] -- exec turbo run typecheck test --filter=bb-plugin-provider-pi --force

Typecheck passed. Tests passed across 26 files: 157 passed, 1 skipped. git diff --check passed. The subsequent squash preserved the exact file tree. Scope review confirmed the final diff contains only eight provider-pi files, and the human Plannotator review requested no changes.

These checks use the production bridge with a fake Pi RPC child and real persisted-context reads. A live test against the exact fork commit also passed: on one BB thread using openai-codex/gpt-5.6-luna, clearing context replaced the old Pi session identity with a new one. The new session's first user message did not contain the prior magic-number message, while the agent could still retrieve 2534 through preserved BB history with bb thread search and answer correctly. This confirms context replacement while preserving durable BB history and tool retrieval. The full facets workflow was not tested. No paid inference was used.

Fixes #3673

AGENT GENERATED

@SawyerHood
SawyerHood force-pushed the fix/plugin-launch-context-remediation branch from fb2019c to 848d9b0 Compare September 15, 2026 00:02
@SawyerHood
SawyerHood merged commit 96fddad into get-bb:main Sep 15, 2026
22 of 24 checks passed
samantha-clanker Bot pushed a commit to samanthar0se/bb that referenced this pull request Sep 19, 2026
Where upstream solved the same problem, take its version:
- thread plugin metadata base (get-bb#3555)
- provider-pi fresh session on thread start (get-bb#3677); take upstream's
  provider-pi files wholesale
- keep upstream's optional-field allowlist groups; fold
  experimental_pluginMetadataByPlugin into the plugin metadata group

Keep local composer APIs that upstream does not provide
(experimental_selectedProviderId, draft plugin metadata, provider-owned
metadata), alongside upstream's pluginSubmission, lifecycleOwnerThreadId,
setSelection, removeMention and onSubmitted. Update test fixtures for
upstream's triggers and mentionMenuPlacement props.

Co-Authored-By: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

provider-pi reuses the previous session when clearing context

2 participants