Skip to content

fix(cli): sort model picker list alphabetically - #57583

Open
Bartok9 wants to merge 1 commit into
NousResearch:mainfrom
Bartok9:fix/57578-sort-model-picker
Open

Bartok9 wants to merge 1 commit into
NousResearch:mainfrom
Bartok9:fix/57578-sort-model-picker

Conversation

@Bartok9

@Bartok9 Bartok9 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Sort the interactive model picker list alphabetically (case-insensitive).
  • The current model still gets pinned to the top with its ← currently in use marker.

Motivation

Closes #57578.

_prompt_model_selection() in hermes_cli/auth.py presented model_ids in whatever order they arrived from the provider probe / catalog. For Ollama Cloud (a live /v1/models list merged with the models.dev registry) and OpenRouter (models.dev catalog order) that order is non-deterministic and changes between invocations, so finding a specific model in a 30+ entry list is an unnecessary visual search.

Fix

Sort model_ids with sorted(model_ids, key=str.casefold) before building the ordered list. The "current model first" behaviour and dedup are unchanged.

Verification

  • python3 -m pytest tests/hermes_cli/test_terminal_menu_fallbacks.py — 8 passed
  • Added 2 regression tests (via the numbered-input fallback):
    • test_prompt_model_selection_sorts_models_alphabetically — unsorted/mixed-case input is presented alphabetically
    • test_prompt_model_selection_keeps_current_first_then_sorted — current model stays pinned first, remainder sorted
  • Confirmed both tests fail on main without the one-line sort change.

@alt-glitch alt-glitch added type/feature New feature or request comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have labels Jul 3, 2026
@teknium1

Copy link
Copy Markdown
Collaborator

Thanks for the focused picker improvement. Current main still preserves input order in hermes_cli/auth.py:6750-6756; both the curses picker (hermes_cli/auth.py:6828-6865) and numbered fallback (hermes_cli/auth.py:6876-6903) consume that same list. The proposed case-insensitive sort fixes both paths while retaining the current-model-first and exact-deduplication behavior. The added fallback tests exercise the selected-item behavior rather than snapshotting a catalog.

Automated hermes-sweeper review.

@teknium1 teknium1 added the sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users label Jul 15, 2026
@Bartok9
Bartok9 force-pushed the fix/57578-sort-model-picker branch from b49529e to e79494c Compare July 15, 2026 15:28
@Bartok9

Bartok9 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review and the sweeper:blast-contained label — agreed this stays a one-line case-insensitive sort at the shared list-build site, so both the curses picker and numbered fallback stay in lockstep with current-model-first + exact dedup unchanged.

Rebased onto current main just now so the branch is no longer 1k+ commits behind; the cherry-pick applied cleanly (only hermes_cli/auth.py + the two regression tests). Local check: python3 -m pytest tests/hermes_cli/test_terminal_menu_fallbacks.py — 8 passed. CI re-running on the rebased head.

Closes NousResearch#57578

The model picker (`/model`, `hermes model`) presented models in
provider/catalog order. For Ollama Cloud (live /v1/models merged with the
models.dev registry) and OpenRouter (models.dev catalog order) that order is
non-deterministic and changes between invocations, so scanning a 30+ model
list is a visual search problem.

_prompt_model_selection() now sorts model_ids case-insensitively before
building the ordered list; the current model still gets pinned to the top
with its marker.

Tests: two regression tests via the numbered fallback assert the presented
order is alphabetical and that the current model stays first.

(cherry picked from commit e79494ca9ea38fa3ae1320421943910a64d2a595)
@Bartok9
Bartok9 force-pushed the fix/57578-sort-model-picker branch from e79494c to c79249d Compare September 2, 2026 14:26
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 P3 Low — cosmetic, nice to have sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Sort model picker list alphabetically (nice-to-have)

3 participants