Repository navigation
Conversation
pi-web builds a fresh ModelRuntime for every model listing and never starts a session in it. Extensions that register their provider only in the first runtime of a process and defer later ones to session_start (pi-claude-bridge) disappeared from the picker after the first listing, and a session could not start on their models. Remember the available models of every runtime pi-web builds and add back providers a runtime does not register at all. A session whose requested or restored model is deferred starts on the default and switches once its extensions are bound.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Models of pi-claude-bridge showed in the picker only on the first listing after Pi Web started. They vanished as soon as the user switched folders, and a session could not start on them.
pi-web builds a fresh
ModelRuntimefor every model listing (createAgentSessionServices()in/api/models,/api/models/default,/api/models/enabled) and never starts a session in it. The bridge registers its provider eagerly only in the first runtime of a process. Later instances defer tosession_start, so that a subagent sharing its parent's registry does not overwrite the parent's stream function. In pi-web, every runtime after the first therefore lacked the provider:The same deferral breaks other hosts; it is tracked upstream in elidickinson/pi-claude-bridge#149. This PR makes Pi Web tolerate any extension that registers its provider at
session_start.Listings
lib/deferred-provider-models.tsremembers the available models of every runtime Pi Web builds: listings,createModelRuntimeWithExtensions(), and sessions once their extensions are bound.withDeferredProviderModels()adds back the models of providers a runtime does not register at all. A provider it registered but cannot use (signed out, no key) is never added back, so auth state stays truthful.Sessions
startRpcSession()builds a session whose requested model (new chat) or restored model (resumed chat) belongs to such a deferred provider on the default model. Once the extensions are bound andsession_starthas run, it switches to that model withset_model. Before, a new chat on a bridge model failed the scope check, and a resumed one silently fell back to the default.Known limit: a project-only extension that defers its provider would also appear in other folders' listings. Picking it there leaves the session on its default model.
docs/agents/models.mdgets a section on this, and theAGENTS.mdfile map is updated.Test plan
tsc --noEmit,npm run lint,npm run buildnpm test: 2286/2286. The newlib/deferred-provider-models.test.mjscovers:/api/modelsfor folders A, B, C, then A again: every listing hasclaude-bridge(13 models) andzai(7). Before, only the first did;POST /api/agent/newwithclaude-bridge/claude-haiku-4-5in a folder that was not listed first: the session starts on Haiku and the reply comes from the bridge;get_statereportsclaude-bridge/claude-haiku-4-5, not the default model.