Skip to content

fix(models): repair persisted mod handles on startup - #3628

Open
frezbo wants to merge 1 commit into
letta-ai:mainfrom
frezbo:fix/mod-model-handle-normalization
Open

fix(models): repair persisted mod handles on startup#3628
frezbo wants to merge 1 commit into
letta-ai:mainfrom
frezbo:fix/mod-model-handle-normalization

Conversation

@frezbo

@frezbo frezbo commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

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

  • Preserve persisted custom-provider model handles when local agents start before their provider mod is registered.
  • Collapse duplicated provider prefixes both before and after provider registration.
  • Keep built-in provider aliases on the existing canonicalization path.

Without this fix, a persisted handle such as chatgpt-oss/chatgpt-oss/gpt-5.6-sol targets a nonexistent model until the user reselects it through /model.

Verification

  • bun test src/backend/local/local-model-normalization.test.ts
    • 9 tests passed
    • 57 assertions passed
  • bun run check
    • 12 checks passed

AI Disclosure

  • This pull request was written with AI assistance and reviewed and edited by a human
  • I have read the AI Policy and agree to its terms

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.

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>
Copilot AI review requested due to automatic review settings August 2, 2026 19:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_type is 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/modelx/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.

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.

3 participants