Skip to content

Fix default model rehydration when providers share slash-qualified model IDs#1326

Closed
hacker1e7 wants to merge 2 commits intonesquena:masterfrom
hacker1e7:fix/default-model-slash-id-collisions
Closed

Fix default model rehydration when providers share slash-qualified model IDs#1326
hacker1e7 wants to merge 2 commits intonesquena:masterfrom
hacker1e7:fix/default-model-slash-id-collisions

Conversation

@hacker1e7
Copy link
Copy Markdown
Contributor

Summary

Fixes the default-model Preferences dropdown when multiple providers expose the same slash-qualified model id (for example google/gemma-4-27b).

Previously, _deduplicate_model_ids() only disambiguated bare ids and skipped slash-qualified ids entirely. That left duplicate <option value> entries in the dropdown, so reopening Preferences could snap the saved default model back to the first provider that exposed the same id.

What changed

  • extend _deduplicate_model_ids() to also de-duplicate repeated slash-qualified ids
  • keep the existing backward-compat rule where the first occurrence remains unchanged
  • prefix later collisions as @provider_id:<original_id>
  • teach the frontend dropdown matcher to prefer the configured active_provider when rehydrating a saved default model
  • wire that provider-aware matching into the relevant default-model restore paths

Why this fixes #1313

The bug was not only that duplicate slash ids existed in the dropdown, but also that default-model rehydration only matched by value/normalized id. With this patch:

  1. duplicate slash-qualified ids become unique dropdown values
  2. saved default-model restore prefers the configured provider instead of always falling back to the first matching option

Tests

Added regression coverage for:

  • two providers exposing the same slash-qualified model id
  • de-duplication of later duplicates into @provider_id:<original_id>
  • frontend provider-aware dropdown resolution choosing the correct option for the saved provider

Closes #1313.

@hacker1e7
Copy link
Copy Markdown
Contributor Author

Pushed a small follow-up fix for the session picker PRIMARY badge issue when duplicate slash-qualified model IDs exist across providers. This makes both the backend badge mapping and the UI badge lookup provider-aware, and adds coverage for the regression.

@nesquena-hermes
Copy link
Copy Markdown
Collaborator

Thanks for the patch. The two-part approach lines up with how #1313 manifests:

  1. dedup at the catalog layer so dropdown values stop colliding
  2. provider-aware rehydration so the saved default model snaps back to the right active_provider instead of the first option that happens to share the id

The follow-up commit on the session picker PRIMARY badge is a nice catch — same root cause (badge lookup keyed on bare id) and worth folding into the same PR rather than splitting.

Will review the diff in api/config.py (the _deduplicate_model_ids() extension) and the frontend matchers in panels.js / ui.js against the regression tests in test_issue1228_model_picker_duplicate_ids.py and test_model_picker_badges.py before merging. The @<provider_id>:<id> prefix scheme keeps backward-compat for the first occurrence which is the right call.

One thing worth confirming on review: that the prefixed values round-trip through /api/config save/load so a user who happens to have a colliding model selected today doesn't get their preference dropped. The tests look like they cover the dropdown path; will sanity-check the persistence path too.

@hacker1e7
Copy link
Copy Markdown
Contributor Author

Thanks — I also sanity-checked the persistence path locally. Saving a prefixed duplicate still writes the CLI-safe bare/slash model plus the matching model.provider, and the UI rehydrates using default_model + active_provider, so the provider identity is preserved across save/load.

@nesquena-hermes
Copy link
Copy Markdown
Collaborator

Thanks for the persistence-path sanity check. That confirms the round-trip I was worried about:

  • default_model is written as the CLI-safe bare/slash id (no @<provider_id>: prefix in the saved config)
  • model.provider is written alongside it, carrying the disambiguation
  • on rehydrate, the dropdown matcher prefers the configured active_provider instead of the first option that happens to share the bare id

So a user who has a colliding model selected today won't get their preference dropped after this lands — the prefix is purely a dropdown-value uniqueness mechanism and doesn't bleed into persisted config.

Will move to review. The PRIMARY-badge follow-up commit fits in this PR rather than getting split, since both bugs share the same root cause (lookup keyed on bare id without provider context).

@nesquena-hermes
Copy link
Copy Markdown
Collaborator

Shipped in v0.50.245 via batch release PR #1334 (merge commit 52e1567). Thanks @Hacker2005! 🙏

Live now at https://github.com/nesquena/hermes-webui/releases/tag/v0.50.245.

Released alongside 9 other contributor fixes — see the v0.50.245 entry in CHANGELOG.md.

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.

bug(settings): Preferences default model loses provider identity and re-selects the first duplicate provider

2 participants