Skip to content

The agent that grows with you

test: keep only the RED-on-base invariant for the no-caller-route override

kshitijk4poor7ed337b72c1d
diff --git a/tests/hermes_cli/test_custom_provider_context_length_no_caller_route.py b/tests/hermes_cli/test_custom_provider_context_length_no_caller_route.py
index ee08d3e8f11..970ff5e3c69 100644
--- a/tests/hermes_cli/test_custom_provider_context_length_no_caller_route.py
+++ b/tests/hermes_cli/test_custom_provider_context_length_no_caller_route.py
@@ -11,68 +11,28 @@ from __future__ import annotations
from pathlib import Path
-
-def _write_custom_provider(home: str, base_url: str, model: str, context_length: int) -> None:
- cfg = (
- ("custom_providers:\n"
- f" - name: test-route\n"
- f" base_url: {base_url}\n"
- f" key_env: TEST_FAKE_CONTEXT_ENV\n"
- f" model: {model}\n"
- " api_mode: chat_completions\n"
- f" models:\n"
- f" {model}:\n"
- f" context_length: {context_length}\n")
- )
- (Path(home) / "config.yaml").write_text(cfg, encoding="utf-8")
-
-
BASE_URL = "https://cp-ctx-selfresolve.invalid/v1"
MODEL = "router/auto"
OVERRIDE = 999_999 # non-power-of-two so it cannot be a catalog value
-class TestGetModelContextLengthSelfResolvesConfigOverride:
- def test_honored_when_caller_passes_no_custom_providers(self, tmp_path, monkeypatch):
- """The exact failing call shape (aux/CLI/TUI/gateway /status): override wins, probe-down default never reached."""
- import os
- from pathlib import Path as _P
-
- monkeypatch.setenv("HERMES_HOME", str(tmp_path))
- monkeypatch.setattr(_P, "home", lambda: tmp_path)
- _write_custom_provider(str(tmp_path), BASE_URL, MODEL, OVERRIDE)
-
- from agent.model_metadata import get_model_context_length
- from hermes_constants import get_hermes_home, display_hermes_home # noqa: F401 (cache isolation sanity)
-
- value = get_model_context_length(
- MODEL, base_url=BASE_URL, api_key="", provider="custom"
- )
- assert value == OVERRIDE
-
- def test_helper_self_resolves_without_any_args(self, tmp_path, monkeypatch):
- """get_custom_provider_context_length with neither list nor config dict."""
- from pathlib import Path as _P
-
- monkeypatch.setenv("HERMES_HOME", str(tmp_path))
- monkeypatch.setattr(_P, "home", lambda: tmp_path)
- _write_custom_provider(str(tmp_path), BASE_URL, MODEL, OVERRIDE)
-
- from hermes_cli.config_providers import get_custom_provider_context_length
-
- value = get_custom_provider_context_length(MODEL, BASE_URL)
- assert value == OVERRIDE
- value_slash = get_custom_provider_context_length(MODEL, BASE_URL + "/")
- assert value_slash == OVERRIDE
-
- def test_unknown_model_on_self_resolved_route_still_returns_none(self, tmp_path, monkeypatch):
- """A model with no per-model entry gets None from the helper — resolution continues downstream."""
- from pathlib import Path as _P
-
- monkeypatch.setenv("HERMES_HOME", str(tmp_path))
- monkeypatch.setattr(_P, "home", lambda: tmp_path)
- _write_custom_provider(str(tmp_path), BASE_URL, MODEL, OVERRIDE)
+def test_override_honored_when_caller_passes_no_custom_providers(tmp_path, monkeypatch):
+ """The exact failing call shape (aux/CLI/TUI/gateway /status): override wins, probe-down default never reached."""
+ monkeypatch.setenv("HERMES_HOME", str(tmp_path))
+ monkeypatch.setattr(Path, "home", lambda: tmp_path)
+ (tmp_path / "config.yaml").write_text(
+ "custom_providers:\n"
+ " - name: test-route\n"
+ f" base_url: {BASE_URL}\n"
+ " key_env: TEST_FAKE_CONTEXT_ENV\n"
+ f" model: {MODEL}\n"
+ " api_mode: chat_completions\n"
+ " models:\n"
+ f" {MODEL}:\n"
+ f" context_length: {OVERRIDE}\n",
+ encoding="utf-8",
+ )
- from hermes_cli.config_providers import get_custom_provider_context_length
+ from agent.model_metadata import get_model_context_length
- assert get_custom_provider_context_length("some/other-model", BASE_URL) is None
+ assert get_model_context_length(MODEL, base_url=BASE_URL, api_key="", provider="custom") == OVERRIDE