HERMES-GIELIE/api
nesquena-hermes e68c1b92a4
fix: do not build phantom Custom group when active provider is set (#206)
* fix: do not build phantom "Custom" group when active provider is set

When model.provider is a real provider (e.g. openai-codex) and model.base_url
is configured, hermes_cli reports 'custom' as an authenticated provider. The
WebUI model picker was building a separate "Custom" group for it and parking
the configured default_model there instead of under the active provider's
group — diverging from the TUI which correctly shows the model under its
configured provider.

Two fixes in api/config.py get_available_models():

1. Discard 'custom' from detected_providers when active_provider is set and
   isn't 'custom' itself. The base_url belongs to the active provider.

2. Replace the substring-based default-model injection check with an exact
   match against _PROVIDER_DISPLAY. The old check `active_provider.lower() in
   g.get('provider', '').lower()` silently failed for hyphenated IDs like
   'openai-codex' vs display name 'OpenAI Codex' (hyphen vs. space),
   falling through to groups[0] and landing the model in the alphabetical
   first group instead.

Adds two regression tests in tests/test_model_resolver.py covering both
conditions.

* fix: do not build phantom Custom group when active provider is set

Two bugs in get_available_models():

1. Phantom Custom group: hermes_cli reports 'custom' as authenticated
whenever model.base_url is set. With provider=openai-codex + base_url,
detected_providers contained both 'openai-codex' and 'custom', producing
a duplicate group. Fixed by discarding 'custom' from detected_providers
when the active provider is any real named provider.

2. Hyphen/space mismatch in default_model injection: the substring check
'openai-codex' in 'openai codex' is False (hyphen vs space), causing the
default model to fall through to groups[0] (alphabetically first provider)
instead of the active provider group. Fixed by using _PROVIDER_DISPLAY
for exact display-name comparison.

Also fixes test helper _available_models_with_full_cfg to clear model env
vars during the call, preventing real hermes profile env from leaking into
the test assertions.

---------

Co-authored-by: mbac <marco.baciarello@gmail.com>
Co-authored-by: Nathan Esquenazi <nesquena@gmail.com>
2026-04-09 18:33:24 -07:00
..
__init__.py Hermes Web UI — Sprints 11-14: multi-provider models, settings, session QoL, alerts, polish 2026-03-31 07:02:47 +00:00
auth.py fix(auth): prune expired sessions on every verify to prevent memory leak (#196) 2026-04-09 18:05:23 -07:00
config.py fix: do not build phantom Custom group when active provider is set (#206) 2026-04-09 18:33:24 -07:00
helpers.py fix: add Content-Security-Policy and Permissions-Policy headers (#197) 2026-04-09 18:07:07 -07:00
models.py release: v0.39.0 — security hardening, 12 fixes (#171) 2026-04-07 22:26:03 -07:00
profiles.py chore: add missing type hints across 10 files 2026-04-05 13:30:20 +07:00
routes.py fix: support CLI sessions in /api/list file browser (#204) 2026-04-09 18:18:38 -07:00
state_sync.py fix: sync message_count to state.db for /insights (#163) (#164) 2026-04-06 22:56:27 -07:00
streaming.py fix: surface approval prompt in UI instead of getting stuck in Thinking (#187) 2026-04-08 20:16:22 -07:00
updates.py fix: use current branch upstream for update checks instead of default branch (#201) 2026-04-09 18:10:11 -07:00
upload.py chore: add missing type hints across 10 files 2026-04-05 13:30:20 +07:00
workspace.py chore: add missing type hints across 10 files 2026-04-05 13:30:20 +07:00