Skip to content

The agent that grows with you

fix(tui): hermes --tui -m custom:<name>:<model> routes through the startup owner too

kshitijk4poor10767ab099bc
diff --git a/hermes_cli/model_switch.py b/hermes_cli/model_switch.py
index c91daac9a78..5c7318186ed 100644
--- a/hermes_cli/model_switch.py
+++ b/hermes_cli/model_switch.py
@@ -392,7 +392,13 @@ def resolve_startup_model_route(
# the model name and the whole prompt goes to its endpoint before it 404s (#73943).
from hermes_cli.models import parse_model_input
qualified_provider, qualified_model = parse_model_input(raw, "")
- if qualified_provider and qualified_model != raw:
+ if qualified_provider == "custom" and ":" in qualified_model:
+ # ``custom:<typo>:<model>`` — no such named provider; a bare-custom request with a garbage
+ # model id would be as silent as the default-provider egress this decode prevents.
+ logger.warning("No providers.%s entry configured; ignoring provider prefix in %r",
+ qualified_model.split(":", 1)[0], raw)
+ return None
+ if qualified_provider:
return StartupModelRoute(model=qualified_model, provider=qualified_provider)
if "/" not in raw:
return None
diff --git a/tests/hermes_cli/test_startup_model_routing.py b/tests/hermes_cli/test_startup_model_routing.py
index fcec1d29ff4..363ac4980f6 100644
--- a/tests/hermes_cli/test_startup_model_routing.py
+++ b/tests/hermes_cli/test_startup_model_routing.py
@@ -182,15 +182,23 @@ def test_startup_route_decodes_custom_colon_qualified_model(tmp_path, monkeypatc
user_providers=cfg.get("providers")) is None
-def test_oneshot_qualified_model_never_reaches_default_provider(tmp_path, monkeypatch):
- """``hermes -z -m custom:<name>:<model>`` routes through the same startup owner, so provider
- auto-detection never hands the qualified string to the configured default (#73943)."""
+def test_oneshot_and_tui_qualified_model_never_reaches_default_provider(tmp_path, monkeypatch):
+ """``hermes -z -m custom:<name>:<model>`` and ``hermes --tui -m …`` route through the same
+ startup owner, so provider auto-detection never hands the qualified string to the configured
+ default (#73943)."""
from hermes_cli.oneshot import _resolve_model_and_provider
+ from tui_gateway import server as tui_server
cfg = _write_named_provider(tmp_path, monkeypatch)
- monkeypatch.delenv("HERMES_INFERENCE_MODEL", raising=False)
+ monkeypatch.delenv("HERMES_INFERENCE_PROVIDER", raising=False)
+ monkeypatch.delenv("HERMES_TUI_PROVIDER", raising=False)
monkeypatch.setattr(
"hermes_cli.models.detect_provider_for_model",
lambda *_a, **_k: pytest.fail("auto-detection ran on a provider-qualified model"))
- choice = _resolve_model_and_provider(cfg, "custom:jetson-vllm:nemotron-nano-30b", None)
+ monkeypatch.setattr(
+ "hermes_cli.models.detect_static_provider_for_model",
+ lambda *_a, **_k: pytest.fail("auto-detection ran on a provider-qualified model"))
+ monkeypatch.setenv("HERMES_INFERENCE_MODEL", "custom:jetson-vllm:nemotron-nano-30b")
+ choice = _resolve_model_and_provider(cfg, None, None)
assert (choice.provider, choice.model) == ("custom:jetson-vllm", "nemotron-nano-30b")
+ assert tui_server._resolve_startup_runtime() == ("nemotron-nano-30b", "custom:jetson-vllm")
diff --git a/tui_gateway/server.py b/tui_gateway/server.py
index 18e42ec42ad..47c7c21f902 100644
--- a/tui_gateway/server.py
+++ b/tui_gateway/server.py
@@ -1432,10 +1432,17 @@ def _resolve_startup_runtime() -> tuple[str, str | None]:
if not (explicit_model := _env_model_seed()):
return model, None
with contextlib.suppress(Exception):
+ from hermes_cli.model_switch import resolve_startup_model_route
from hermes_cli.models import detect_static_provider_for_model
- cfg = _load_cfg().get("model") or {}
+ full_cfg = _load_cfg()
+ cfg = full_cfg.get("model") or {}
current_provider = ((str(cfg.get("provider") or "").strip().lower() if isinstance(cfg, dict) else "")
or os.environ.get("HERMES_INFERENCE_PROVIDER", "").strip().lower() or "auto")
+ # Same owner as HermesCLI/oneshot: ``custom:<name>:<model>`` selects that provider (#73943).
+ if route := resolve_startup_model_route(
+ explicit_model, current_provider=current_provider,
+ user_providers=full_cfg.get("providers"), custom_providers=full_cfg.get("custom_providers")):
+ return route.model, route.provider
if detected := detect_static_provider_for_model(explicit_model, current_provider):
provider, detected_model = detected
return detected_model, provider