fix(models): include extension-registered providers in settings and auth routes - #833
Open
elrond298 wants to merge 1 commit into
Open
fix(models): include extension-registered providers in settings and auth routes#833elrond298 wants to merge 1 commit into
elrond298 wants to merge 1 commit into
Conversation
elrond298
force-pushed
the
fix/settings-extension-providers
branch
from
September 13, 2026 09:18
b96528e to
90d115f
Compare
…uth routes Providers registered by an extension (via registerProvider, typically with the createProvider helper) were missing from the provider listing and auth routes: such a provider was selectable in the composer — /api/models loads extensions — but absent from the Models panel, and its stored API key could not be managed. A bare ModelRuntime.create() only sees built-in providers plus models.json; extension registrations are applied by createAgentSessionServices(). Add createModelRuntimeWithExtensions() and use it in the provider listing and auth routes. The agent dir acts as cwd so project-local extensions stay out; global package extensions always load. Uncached: auth status and login/logout need fresh credentials.
elrond298
force-pushed
the
fix/settings-extension-providers
branch
from
September 13, 2026 09:20
90d115f to
4e8bbe8
Compare
elrond298
marked this pull request as ready for review
September 13, 2026 09:22
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.
Problem
Providers registered by an extension package (any extension that calls
pi.registerProvider/createProviderwhile loading resources) never appear in theModels config panel, so their credentials cannot be managed from Pi Web — even though
the composer's model selector offers them and they work in a session.
With such an extension installed and its key stored in
auth.json:/api/models→ lists the provider's models ✅/api/auth/providers→apiKeyProvidershas no entry for that provider ❌Root cause
Extension providers reach a model runtime in
createAgentSessionServices(): it runs theresource loader, then replays
pendingProviderRegistrationsonto itsModelRuntime(
dist/core/agent-session-services.js)./api/modelsbuilds its runtime that way — hence the model is offered in the composer.The four auth routes instead called a bare
ModelRuntime.create(), which only knowsbuilt-in providers plus
models.json.getProviders()never contained the extensionprovider (so the panel could not list it) and
getProvider(id)returnedundefinedforits login / logout / save-key paths.
Fix
New
lib/model-runtime.tsexportscreateModelRuntimeWithExtensions(), which builds theruntime through
createAgentSessionServices({ cwd: agentDir, agentDir }). All four authroutes now use it:
app/api/auth/providers/route.ts— panel listingapp/api/auth/api-key/[provider]/route.ts— save keyapp/api/auth/login/[provider]/route.ts— OAuth / device-code loginapp/api/auth/logout/[provider]/route.ts— OAuth logoutDeliberate choices:
load; a browsed repository's project-local
.pi/extensionsare never imported, so theseroutes cannot become a new execution path for untrusted repository code (related: Project-local
.piextensions execute local commands during pi-web session startup without project trust confirmation #236).credentials rather than a stale snapshot.
Verification
Dev server started from this branch (pi-web 0.9.1) with a provider extension installed
(14 models registered, key already in
auth.json):/api/modelsunchanged — same list, extension models still presentPOST /api/auth/api-key/<unknown>still fails cleanly (... does not support API key login) rather than crashingnpm run lintclean; no type errors in the changed filesScope
Bug: "Chat only" tool preset drops extension-registered model providers, so sending fails with "Model not found" #804 — a "Chat only" session never loads extensions, so that session's own runtime
still lacks extension providers. That path is session creation (
startRpcSession),not the auth routes.
lib/provider-usage.tscontains the same bareModelRuntime.create(); quota lookupfor extension providers stays unavailable there. Left out to keep this diff small.