Skip to content

The agent that grows with you

fix(picker): key the native Ollama cache entry on the caller's headers

teknium18294eff4ce5b
diff --git a/hermes_cli/model_switch_providers.py b/hermes_cli/model_switch_providers.py
index 36a56a55553..3af99e153e7 100644
--- a/hermes_cli/model_switch_providers.py
+++ b/hermes_cli/model_switch_providers.py
@@ -137,10 +137,13 @@ def _fetch_picker_live_models(
# Admit the native catalog to the SHARED disk cache: a no-probe picker open (every endpoint
# that is not the current one) reads ``provider_models_cache.json`` only, so a native probe
# that answered here but was never stored came back empty on the next open — the provider's
- # whole group vanished from the picker until the user hit Refresh Models.
+ # whole group vanished from the picker until the user hit Refresh Models. Key the entry on
+ # the caller's ``headers`` (what that cache_only read hashes), not ``resolved_headers``: the
+ # native probe's synthesized Authorization would otherwise land under a fingerprint the
+ # read side never computes, and a keyed endpoint kept flickering.
native_models = (
cached_fetch_api_models(
- api_key, api_url, timeout=timeout, headers=resolved_headers, api_mode=api_mode,
+ api_key, api_url, timeout=timeout, headers=headers, api_mode=api_mode,
fetch_models=_probe_native_catalog)
if cache else _probe_native_catalog())
if native_models is not None:
diff --git a/tests/hermes_cli/test_model_switch_custom_providers.py b/tests/hermes_cli/test_model_switch_custom_providers.py
index 9147cf048bb..c0f49ff3203 100644
--- a/tests/hermes_cli/test_model_switch_custom_providers.py
+++ b/tests/hermes_cli/test_model_switch_custom_providers.py
@@ -74,7 +74,9 @@ def test_picker_native_catalog_is_admitted_to_the_shared_model_cache(monkeypatch
never stored therefore read back empty on the next open, and the row's whole provider group
disappeared from the picker until someone hit Refresh Models. The round-trip stays a
``_NativePickerModelList``: the native flag is what lets a genuinely model-less Ollama
- persist an authoritative empty catalog.
+ persist an authoritative empty catalog. The entry is keyed on what the no-probe read hashes
+ (api_key + the caller's headers), not on the Authorization header the native probe
+ synthesizes from the key — a keyed endpoint otherwise wrote a row nobody could read back.
"""
monkeypatch.setattr(
"hermes_cli.models_local.should_use_ollama_native_catalog", lambda *a, **k: True
@@ -87,9 +89,9 @@ def test_picker_native_catalog_is_admitted_to_the_shared_model_cache(monkeypatch
from hermes_cli.models import cached_fetch_api_models
url = "http://127.0.0.1:11434/v1"
- assert _fetch_picker_live_models(None, url, "custom", False) == ["qwen3:8b"]
+ assert _fetch_picker_live_models("sk-ollama", url, "custom", False) == ["qwen3:8b"]
- no_probe = cached_fetch_api_models(None, url, cache_only=True, timeout=1.5)
+ no_probe = cached_fetch_api_models("sk-ollama", url, cache_only=True, timeout=1.5)
assert isinstance(no_probe, _NativePickerModelList)
assert no_probe == ["qwen3:8b"]