Repository navigation
Description
Summary
The Pi provider's bridge worker loads ~/.pi/agent/models.json once at process boot. The bridge process identity does not include the contents of that file, so editing it is invisible to both stale-bridge retirement paths. bb plugin reload provider-pi reports success but only reloads server-side plugin registration; the host daemon keeps serving model/list from the old worker. The catalog stays stale until the tracked worker dies by hand, and superseded workers are leaked as duplicates.
Verified live against bb 0.39.0 (macOS, packaged app; embedded Pi 0.84.0 vs standalone pi 0.84.2).
Reproduction
- Start bb with the Pi provider running.
- Add a new model to
~/.pi/agent/models.json(e.g. a custom provider entry). Standalonepiresolves it immediately; bb's embedded runtime would too on a fresh boot. bb provider models pistill omits it.bb plugin reload provider-piprints success. No worker restart happens.- Repeated reloads leak duplicate
bb-provider-bridge-worker.mjs … bb-pi-bridge.mjs provider-pi …processes. - SIGTERM to the tracked worker → the next
model/listspawns a fresh worker, which re-readsmodels.json, and the picker updates. Any other surviving superseded worker keeps running idle until manually killed.
I verified steps 3–6 live today with a probe model: probe invisible while two workers were alive; after killing one, the query respawned a fresh worker and the probe appeared, with the older superseded worker still leaking.
Root cause
In the host-daemon bundle:
- A bridge worker's
processKeyis<base>#<hash>where the hash covers only the bridge launch source digest (for bundled Pi:bundled:<id>) plus a hash of the declared capabilities (yB(bridgeLaunch)). retireStaleBridgeProcesses(runs on each provider spawn) retires same-base/same-suffix workers only when their hash differs from the newly current one.retireSupersededBridgeProcessIfIdlelikewise compares hashes only.
Since models.json is external to the launch config, its contents can never change the hash, so neither path ever has a reason to retire the pre-edit worker. Plugin reload does not reach into host-daemon bridge lifecycle at all.
Suggested fix directions
- Include a digest of the provider's external config inputs (for Pi,
~/.pi/agent/models.json) in the bridge processKey hash, so an edit makes the next spawn retire the old idle worker naturally; or - Give plugin reload a way to ask the host daemon to retire idle same-hash bridge workers for that provider id; or
- Have the Pi bridge re-read
models.jsonpermodel/listinstead of caching at boot.
Any of these should keep the existing safety property: retirement only when identity.threadIds.size === 0.
Regression test
A test where models.json gains a custom model entry after provider startup: assert provider models pi picks it up after a supported refresh path (config edit + reload or watcher), and that exactly one bridge worker remains afterwards.
Activity
SawyerHood commentedon Aug 24, 2026
---Auto-Generated---
Reproduction & root-cause report: https://get-bb.github.io/reports/issues/2289.html
pi --mode rpc --no-sessioncatalog child per cwd, the daemon keeps that bridge worker across plugin reloads because its process key (artifact digest + declaration fingerprint) never changes, and the server additionally memoizes provider.list_models for 10 minutes keyed by registration revision.bb plugin reload provider-pi…The report is self-contained: copy-paste repro steps with the test or script inline, expected vs actual output, screenshots where the bug is visual, and code permalinks at the base commit. It was independently re-executed by a second agent (see its Verification section).
dandaka commentedon Oct 2, 2026
Additional evidence for the stale-catalog part of this issue, plus a smaller fix for the bridge layer. Verified against
mainat1b973d5584e10963018f4ae7d9c001e8ec09b99b.Environment: bb 0.44.0 (
npx bb-app), macOS 15.6, Node 26.3.0, Pi 1.0.0 (npm install -g @earendil-works/pi-coding-agent), one connected persistent host. I also ran the bridge repro against Pi 0.84.0 (the pinned devDependency andPI_MINIMUM_SUPPORTED_VERSION).Observation 1: a live catalog child also misses credential changes
This repro runs at the bridge layer with the real
pibinary and an isolatedPI_CODING_AGENT_DIR. No bb server is involved. Save the file below asplugins/provider-pi/src/bridge/real-pi.repro.test.ts, then run:real-pi.repro.test.tsActual output on
1b973d5with Pi 1.0.0:I also ran a variant that logs each read instead of asserting. All three reads returned
['probe/alpha']from the samepiPID, so nodeepseek/*model appeared after a DeepSeek key was written toauth.jsoneither. Pi 0.84.0 behaves the same way in the asserting version.The cause is on Pi's side of the RPC.
case "get_available_models"indist/modes/rpc/rpc-mode.jsreturnssession.modelRuntime.getAvailableSnapshot()in both 0.84.0 and 1.0.0, and the RPC command list has no refresh verb. The child stays alive for up toBB_PI_CATALOG_IDLE_MS(5 minutes) after its last fetch, andfetchRawFrom()asks it for that snapshot each time.Observation 2: the host row and the workspace row disagreed
I captured this earlier today on the same machine. DeepSeek had been configured in Pi through
auth.jsononly, with nomodels.jsonchange.scope_key''(host)<workspace>Pi recorded its DeepSeek check at 10:35:08 (
checkedAtinmodels-store.json), after the host row was written. A read without an environment at 10:47 served the stale 73-model host row. Twelve seconds later the row held the 46-model list, which is the serve-stale-then-revalidate path inevaluate(). After that, Pi and bb agreed exactly (46 IDs each):My reading of this: by 10:47 the host-scope child had been idle longer than 5 minutes and was respawned, so this case was not caused by a live child. It came from the server memo (
FRESH_MS, andcatalogFingerprinthas no Pi config input), and from the host and workspace scopes keeping separate rows with separate TTLs.Proposed fix for the bridge layer
Pi already exposes a reload to extensions.
ExtensionContext.modelRegistry.refresh(options?)("Reload models.json asynchronously") exists in both 0.84.0 and 1.0.0. In 1.0.0,refresh({ allowNetwork: false })reloadsmodels.json, rebuilds providers, and reruns the availability pass, which re-readsauth.json(AuthStorage.list→readLatestData). Pi calls it itself after provider registration changes. The bb extension already answers bridge-channel requests (fork,leaf,model-scopeinrunBridgeRequest). So arefresh-modelsrequest handled there, and sent beforeget_available_models, keeps the child alive and current.This also covers the credential case, which fingerprinting
models.json(the report's proposal) would miss.Proposed split:
refresh-modelschannel request. If the refresh is unsupported, rejects, or times out, replace the child as a fallback. Tests use the existing fake-Pi harness. I have this ready on a branch. With it, the repro above passes against real Pi 1.0.0 and 0.84.0 with a single PID across all three reads, at 2–4 ms per read, and the package suite passes (170 tests). I'll open the PR once I'm approved as a contributor.read()serves stale data and revalidates in the background; onlyaccess.kind === "validation"waits. The design question: an explicit picker refresh (for example?refresh=1with a bounded wait that falls back to stale), or a shorter or revision-keyed memo? Blocking on every picker open would cost seconds when the child is cold.Ruled out
pi --list-modelslistsdeepseek/deepseek-flashanddeepseek/deepseek-v4-pro, and the bb workspace row matched Pi exactly.Separately, Pi has no RPC command for refreshing models. A
refresh_modelsRPC command would spare every RPC client this extension hop. That belongs in the Pi repository, not here.Refresh Pi's model registry before serving the catalog (get-bb#4727)