Skip to content

Native Pi extension providers unavailable during cold-start model listing and thread startup #1087

Closed as not planned

Description

@toasterman234

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

  1. Configure a Pi extension that registers a provider/model, for example:
    • commandcode/deepseek/deepseek-v4-pro
    • router/deep
  2. Start bb's native Pi provider from a cold bridge.
  3. 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-pro completed 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.
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions