Skip to content

fix: prevent bare 'custom' slug in model.provider (#17478)#17481

Closed
Andy283 wants to merge 1 commit into
NousResearch:mainfrom
Andy283:fix/custom-provider-slug-bare-string
Closed

fix: prevent bare 'custom' slug in model.provider (#17478)#17481
Andy283 wants to merge 1 commit into
NousResearch:mainfrom
Andy283:fix/custom-provider-slug-bare-string

Conversation

@Andy283

@Andy283 Andy283 commented Apr 29, 2026

Copy link
Copy Markdown

Problem

When using hermes model interactive picker to switch to a custom_providers entry, the CLI can write the literal string custom to model.provider in config.yaml instead of the actual provider name (e.g. xiaomi-coding).

This causes every subsequent session to fail with:

Unknown provider "custom". Check hermes model for available providers.

Root cause: in list_authenticated_providers() (model_switch.py:1466-1472), when current_provider is already "custom" from a prior failed switch and current_base_url matches, slug gets set to the literal "custom". Then resolve_provider_full("custom") finds no match since the canonical slug is custom:xiaomi-coding.

Fix (2 files, +33/-1)

hermes_cli/model_switch.py — Slug assignment guards against bare "custom":

  • If current_provider is "custom", fall back to custom_provider_slug(display_name) which produces the canonical custom:<name> form

hermes_cli/providers.py — Self-healing fallback in resolve_custom_provider():

  • When requested == "custom" matches nothing by name or slug, fall back to the first valid custom_providers entry so corrupted configs auto-recover

Testing

9/9 test cases pass:

  • Normal resolution by name and slug
  • Bare "custom" self-heals to first entry
  • Unknown provider returns None
  • Slug assignment handles bug case, normal case, None case, and URL mismatch

Closes #17478

When hermes model picker switches to a custom_providers entry, the slug
assignment can write the literal string 'custom' to model.provider if a
prior failed switch already left that value in config.yaml.

Two fixes:
1. model_switch.py: filter out bare 'custom' in slug assignment, always
   resolve to canonical custom:<name> form
2. providers.py: resolve_custom_provider() self-heals bare 'custom' by
   falling back to the first valid custom_providers entry

Closes NousResearch#17478
@teknium1

Copy link
Copy Markdown
Contributor

Salvaged onto current main via #17891 (commits 201f7caed8, 61fec7689d, 3fc4c63d38). Your original fix commit kept your authorship; we added an AUTHOR_MAP entry for your gitee email and updated the existing regression test to match the fix. Thanks for the clear bug report and PR!

@teknium1 teknium1 closed this Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P1 High — major feature broken, no workaround type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: picker writes literal 'custom' to model.provider instead of actual provider name

3 participants