Repository navigation
Description
Summary
The native Pi provider in bb can fail to discover extension-registered providers and models during cold start. Pi extensions such as pi-commandcode-provider and pi-model-router register their providers while createAgentSession() initializes the resource loader, but bb's native bridge resolves configured models and lists models through a ModelRuntime created before that initialization.
This affects both:
- native
provider.list_models/ the desktop model picker - native Pi thread startup with an explicitly configured extension model
A first CommandCode thread can otherwise fail with Failed to resolve Pi model before session creation has a chance to load the extension.
Reproduction
Source checkout: ymichael/bb main
- Configure a Pi extension that registers a provider/model, for example:
commandcode/deepseek/deepseek-v4-prorouter/deep
- Start bb's native Pi provider from a cold bridge.
- Request Pi model listing or start a thread with the exact extension model.
Before extension initialization, the model is absent from ModelRuntime; configured-model resolution can fail before createAgentSession() runs.
Fix direction
Initialize Pi extensions against the shared ModelRuntime before returning the runtime to model listing or configured-model resolution. The initialization must not bind the active thread to a disposed bootstrap session.
A source-dev validation patch currently uses a disposable createAgentSession() to prime the shared runtime, then disposes that bootstrap session. The exact implementation is in:
packages/agent-runtime/src/pi/bridge/model-runtime.ts
The preferred long-term implementation should be reviewed against Pi's extension-aware createAgentSessionServices API if that avoids duplicate extension instances or stale router registry state.
Evidence
Using the source-dev stack with the patch:
- exact model listing included
commandcode/deepseek/deepseek-v4-pro - exact model listing included
router/deep - native Pi thread using
commandcode/deepseek/deepseek-v4-procompleted successfully - follow-up turns completed successfully
- native Pi read and write tools completed successfully
- thread settled to idle after each turn
The router path remains a separate unresolved compatibility/authentication investigation: model-list visibility does not prove router execution. In controlled A/B/A testing, direct CommandCode passed immediately before and after a router failure.
Acceptance criteria
- Extension-registered Pi models appear in native model listing on a cold bridge.
- An explicit extension model resolves during native thread startup.
- The active thread uses a live session, not the disposable bootstrap session.
- A regression fixture covers model listing and exact model resolution without real credentials or network access.
- Router execution is tested separately from discovery and is not considered proven by picker visibility alone.
Activity