Skip to content

The agent that grows with you

fix(metrics): local_model_provider_used sees bare aux endpoints and bare-named providers

teknium1f6f0d47d2b57
diff --git a/hermes_cli/observability/shared_metrics_install.py b/hermes_cli/observability/shared_metrics_install.py
index eb203fb0890..81e7d6a8033 100644
--- a/hermes_cli/observability/shared_metrics_install.py
+++ b/hermes_cli/observability/shared_metrics_install.py
@@ -136,6 +136,8 @@ def _is_local_endpoint(base_url: Any) -> bool:
def _custom_base_url(provider: str) -> Any:
+ """A ``providers:`` / ``custom_providers:`` entry's endpoint, by ``custom:<name>`` or bare name
+ (built-in ids shadow entries, as at runtime)."""
from hermes_cli.runtime_provider_custom import _get_named_custom_provider
entry = _get_named_custom_provider(provider)
@@ -152,7 +154,16 @@ def _slot_is_local(slot: Any) -> bool:
if provider in catalog_safe(user_named_model_providers) - {CUSTOM}:
return True
- return provider.startswith(f"{CUSTOM}:") and _is_local_endpoint(_custom_base_url(provider))
+ return provider not in _INHERITS_MAIN and _is_local_endpoint(_custom_base_url(provider))
+
+
+def _aux_slot_routes_itself(slot: dict[str, Any]) -> bool:
+ """An auxiliary task off the main model: a named provider, or (mirroring
+ ``agent.auxiliary_client._resolve_task_provider_model``) a bare ``base_url`` + ``api_key``,
+ which the runtime sends to that endpoint as ``custom`` even under ``provider: auto``."""
+ if _norm(slot.get("provider")) not in _INHERITS_MAIN:
+ return True
+ return all(isinstance(slot.get(k), str) and slot[k].strip() for k in ("base_url", "api_key"))
def local_model_provider_used(config: dict[str, Any]) -> str:
@@ -161,7 +172,7 @@ def local_model_provider_used(config: dict[str, Any]) -> str:
auxiliary = _sub(config, "auxiliary")
slots = [model] if isinstance(model, dict) else []
if isinstance(auxiliary, dict):
- slots += [s for s in auxiliary.values() if isinstance(s, dict) and _norm(s.get("provider")) not in _INHERITS_MAIN]
+ slots += [s for s in auxiliary.values() if isinstance(s, dict) and _aux_slot_routes_itself(s)]
return "yes" if any(_slot_is_local(slot) for slot in slots) else "no"
diff --git a/tests/hermes_cli/test_shared_metrics_install_v4.py b/tests/hermes_cli/test_shared_metrics_install_v4.py
index 90a72fe3721..72c008b26d5 100644
--- a/tests/hermes_cli/test_shared_metrics_install_v4.py
+++ b/tests/hermes_cli/test_shared_metrics_install_v4.py
@@ -270,6 +270,27 @@ def test_local_model_use_covers_main_and_auxiliary_slots(config, used):
assert install.local_model_provider_used(config) == used
[email protected](("aux", "used"), [
+ # The runtime routes a bare base_url + api_key to that endpoint even under provider auto.
+ ({"provider": "auto", "base_url": "http://localhost:11434/v1", "api_key": "k", "model": "q"}, "yes"),
+ ({"base_url": "http://127.0.0.1:8080/v1", "api_key": "k", "model": "q"}, "yes"),
+ ({"base_url": "https://api.example.com/v1", "api_key": "k", "model": "q"}, "no"),
+])
+def test_local_model_use_sees_a_bare_auxiliary_endpoint(aux, used):
+ assert install.local_model_provider_used({"model": {"provider": "openrouter"}, "auxiliary": {"vision": aux}}) == used
+
+
[email protected](("base_url", "used"), [("http://127.0.0.1:8080/v1", "yes"), ("https://llm.example.com/v1", "no")])
+def test_local_model_use_resolves_a_named_provider_used_by_bare_name(monkeypatch, base_url, used):
+ import hermes_cli.runtime_provider as rp
+
+ config = {"model": {"provider": "home-llama", "default": "q"},
+ "providers": {"home-llama": {"base_url": base_url, "api_key": "k"}}}
+ monkeypatch.setattr(rp, "load_config", lambda: config)
+
+ assert install.local_model_provider_used(config) == used
+
+
def test_snapshot_fields_degrade_to_unknown_when_a_reader_breaks(monkeypatch):
def _boom(*_a, **_k):
raise OSError("unreadable")