Skip to content

fix(tui): pass providers: dict (not list) to switch_model — fixes /model for user-defined providers#18085

Closed
arsaboo wants to merge 1 commit into
NousResearch:mainfrom
arsaboo:tui
Closed

fix(tui): pass providers: dict (not list) to switch_model — fixes /model for user-defined providers#18085
arsaboo wants to merge 1 commit into
NousResearch:mainfrom
arsaboo:tui

Conversation

@arsaboo

@arsaboo arsaboo commented Apr 30, 2026

Copy link
Copy Markdown

Summary

  • Root cause: tui_gateway/server.py::_apply_model_switch() was converting the providers: dict from config.yaml into a list of {"provider": k, **v} dicts before calling switch_model(). But resolve_user_provider() in hermes_cli/providers.py calls user_config.get(name) — which expects a plain dict keyed by provider slug. The list format always returned None, causing the "Unknown provider 'ollama-local'" error.
  • tui_gateway/server.py: Changed the list comprehension to cfg.get("providers") if isinstance(..., dict) else {} — matching how the CLI and web_server.py already pass this value.
  • hermes_cli/model_switch.py: Fixed the validation-override block which was written to iterate the (now-removed) list format. It now does a direct dict key lookup on target_provider instead of looping.

Test plan

  • test_switch_model_resolves_ollama_local_from_providers_dict — end-to-end switch through the corrected dict path; asserts no "Unknown provider" error and target_provider == "ollama-local"
  • test_switch_model_list_format_user_providers_fails_to_resolve — unit proof that the old list shape returns None while the correct dict shape resolves; prevents regression back to the list format
  • Full tests/hermes_cli/test_user_providers_model_switch.py suite (27 tests) passes
python -m pytest tests/hermes_cli/test_user_providers_model_switch.py -o 'addopts=' -q
# 27 passed

…odel_switch

TUI /model failed for user-defined providers (e.g. ollama-local) with
"Unknown provider 'ollama-local'" because _apply_model_switch() was
converting the config.yaml providers: dict into a list of
{"provider": k, **v} dicts.  resolve_user_provider() calls
user_config.get(name) which expects a plain dict keyed by provider slug,
so the list format always returned None and provider resolution failed.

Fix _apply_model_switch() to pass the raw dict (matching how the CLI
and web_server already pass it).  Also fix the validation-override loop
in switch_model() which was written to iterate the (now-removed) list
format; it now does a direct dict lookup on the target provider key.

Adds two regression tests:
- end-to-end switch_model() call with ollama-local in dict format
- unit proof that the old list shape fails while dict shape succeeds

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@alt-glitch alt-glitch added type/bug Something isn't working comp/tui Terminal UI (ui-tui/ + tui_gateway/) comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists labels Apr 30, 2026
@arsaboo arsaboo closed this May 10, 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 comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants