Skip to content

fix(models): exclude custom providers from deferred model cache - #1458

Merged
agegr merged 3 commits into
agegr:mainfrom
Reshwell:fix/stale-provider-model-cache
Oct 29, 2026
Merged

agegr merged 3 commits into
agegr:mainfrom
Reshwell:fix/stale-provider-model-cache

Conversation

@Reshwell

@Reshwell Reshwell commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem

After a custom provider has appeared in the model picker, renaming or deleting it in Settings → Models and saving leaves its old id in subsequent model listings. The saved models.json is correct, but the process-wide deferred-provider catalog remembers every available provider. A fresh runtime no longer contains the old id, so the fallback adds it back as though an extension had deferred its registration.

Reproduction on main

  1. Add a custom provider with a usable model and save it.
  2. Load the model picker so the provider is remembered.
  3. Rename the provider, or delete it, and save again.
  4. Reload the model list. The old provider is still offered; restarting Pi Web clears it.

After this change, a renamed provider appears only under its new id, and a deleted provider is no longer offered.

Change

Only remember models from explicit extension/native provider registrations and virtual models. Use the public SDK methods getRegisteredProviderIds(), getModel(), and getPhysicalModel() to distinguish these from ordinary physical models defined only in models.json. Virtual-only providers are not included in the registration-id list, so they remain eligible when the model still exists and has no physical counterpart. Requiring that current model also prevents a physical model removed during an asynchronous availability check from being mistaken for a virtual model. Deferred extension providers continue to work as introduced in #1071, without clearing their registrations on every config save.

Add unit coverage for provider filtering, virtual models, and concurrent removal, plus real-SDK regression tests for rename and deletion. The latter write the actual configuration file, verify that deferred physical and virtual extension models remain available, and check that a pre-save runtime cannot reintroduce the old custom provider. Update the model-runtime notes.

Validation

  • The new rename/deletion integration tests and provider-filtering unit test fail on unmodified main and pass with the fix.
  • Virtual-model coverage verifies that providers missing from the registration-id list remain available through the deferred-model fallback.
  • The concurrent-removal regression fails without the current-model check and passes with it.
  • Focused model suites: 33 passed, including deferred session startup, Chat only, and model-config persistence.
  • node node_modules/typescript/bin/tsc --noEmit: passed.
  • npm run lint: passed.
  • git diff --check: passed.
  • Latest full npm test on Windows / Node 24.21.0: 3075 passed, 39 failed, 23 skipped. A clean checkout of the same base (377c012) reports 3069 passed, 40 failed, 23 skipped. All 39 failing tests also failed in the clean baseline run; the baseline additionally had an intermittent failure in mcp-host.integration.test.mjs. That file passes 11/11 when run separately on both the base and the fix. The full suite is therefore not green locally; this PR does not change the unrelated tests.

@Reshwell
Reshwell marked this pull request as ready for review October 29, 2026 11:24
@agegr

agegr commented Oct 29, 2026

Copy link
Copy Markdown
Owner

Thanks, this looks good to merge.

Checked on a scratch merge with current main (pi 1.4.0):

  • The bug is real: the four new tests fail with main's deferred-provider-models.ts and pass with this change, including the two real-SDK rename/delete tests.
  • getRegisteredProviderIds() covers both registerProvider and native provider registrations and leaves out built-in and models.json-only providers, so deferred extension providers (pi-claude-bridge) and virtual models are still remembered.
  • writeModelsConfig already invalidates the models cache, so a rename or delete shows on the next listing.
  • Model and rpc-manager suites (300 tests), tsc --noEmit and npm run lint pass.

@agegr
agegr merged commit f78c672 into agegr:main Oct 29, 2026
2 checks passed
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 6, 2026
…r#1458)

* fix(models): exclude custom providers from deferred model cache

* fix(models): preserve deferred virtual models

* fix(models): ignore models removed during availability checks
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 8, 2026
…r#1458)

* fix(models): exclude custom providers from deferred model cache

* fix(models): preserve deferred virtual models

* fix(models): ignore models removed during availability checks
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 8, 2026
…r#1458)

* fix(models): exclude custom providers from deferred model cache

* fix(models): preserve deferred virtual models

* fix(models): ignore models removed during availability checks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants