fix(models): repair persisted mod handles on startup - #3628
Open
frezbo wants to merge 1 commit into
Open
Conversation
Local agents can load persisted model handles before provider mods register. Older normalization can prepend the provider twice, causing cold-start model resolution to target a nonexistent provider/model until the user reselects the model. Preserve valid mod handles and collapse one duplicated provider prefix both before and after mod registration. Keep built-in provider aliases on their existing canonicalization path. 👾 Generated with [Letta Code](https://letta.com) Co-Authored-By: Letta Code <noreply@letta.com> Signed-off-by: Noel Georgi <git@frezbo.dev>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes local-agent cold starts where persisted custom-provider model handles can be normalized into a double-prefixed form before a provider mod has registered, leading to an unresolvable provider/model until the user reselects /model.
Changes:
- Avoids re-prefixing persisted model handles when
model_settings.provider_typeis not a built-in provider type and the handle is already correctly prefixed. - Collapses a single duplicated provider prefix for unregistered (custom/mod) provider types (e.g.
x/x/model→x/model). - Adds regression tests covering pre-mod-load preservation/repair and ensuring built-in provider alias canonicalization is unchanged.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/backend/local/local-model-normalization.ts |
Adds special-case handling to preserve or de-duplicate custom/mod provider prefixes before mod registration, while keeping built-in canonicalization behavior. |
src/backend/local/local-model-normalization.test.ts |
Adds tests for pre-registration mod handles and for duplicated-prefix repair, plus a guard test for built-in provider alias canonicalization. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Local agents can load persisted model handles before provider mods register. Older normalization can prepend the provider twice, causing cold-start model resolution to target a nonexistent provider/model until the user reselects the model.
Preserve valid mod handles and collapse one duplicated provider prefix both before and after mod registration. Keep built-in provider aliases on their existing canonicalization path.
👾 Generated with Letta Code
Summary
Without this fix, a persisted handle such as
chatgpt-oss/chatgpt-oss/gpt-5.6-soltargets a nonexistent model until the user reselects it through/model.Verification
bun test src/backend/local/local-model-normalization.test.tsbun run checkAI Disclosure
AI Tool(s) Used
Letta Code and GPT Sol 5.6
Human Verification
I have reviewed and understand every change in this pull request and take responsibility for its correctness.