Skip to content

The agent that grows with you

fix(acp): isolate custom catalog identities

Vadelma9d2ba6c655c1
diff --git a/acp_adapter/server.py b/acp_adapter/server.py
index bfa5472d59c..51c47e4e160 100644
--- a/acp_adapter/server.py
+++ b/acp_adapter/server.py
@@ -772,6 +772,8 @@ class HermesACPAgent(acp.Agent):
raw = str(provider_id or "").strip().lower()
if raw in {"ollama", "custom:ollama"}:
return "ollama"
+ if raw.startswith("custom:"):
+ return raw
return normalize_provider(raw)
seen_semantic_ids: set[str] = set()
@@ -816,6 +818,8 @@ class HermesACPAgent(acp.Agent):
if raw_row_provider == "ollama"
else raw_row_provider
if raw_row_provider == "custom:ollama"
+ else raw_row_provider
+ if raw_row_provider.startswith("custom:")
else row_provider
)
choice_id = self._encode_model_choice(
@@ -848,7 +852,7 @@ class HermesACPAgent(acp.Agent):
named_empty_authoritative: set[str] = set(native_empty_rows)
for named_slug, named_label, named_catalog in _named_custom_provider_catalogs():
if not named_catalog:
- named_empty_authoritative.add(normalize_provider(named_slug))
+ named_empty_authoritative.add(str(named_slug).strip().lower())
continue
for named_model, named_desc in named_catalog:
named_choice = self._encode_model_choice(named_slug, named_model)
@@ -879,6 +883,13 @@ class HermesACPAgent(acp.Agent):
def empty_catalog_applies(provider_id: str) -> bool:
raw = str(provider_id or "").strip().lower()
normalized = normalize_provider(raw)
+ if normalized == "custom":
+ return any(
+ candidate == raw
+ or candidate == f"custom:{raw}"
+ or (raw == "custom" and candidate == "custom")
+ for candidate in named_empty_authoritative
+ )
return any(
candidate == raw
or candidate == f"custom:{normalized}"
diff --git a/hermes_cli/model_switch.py b/hermes_cli/model_switch.py
index 779cce08706..12f85d2e615 100644
--- a/hermes_cli/model_switch.py
+++ b/hermes_cli/model_switch.py
@@ -197,6 +197,17 @@ def _save_discovered_models_to_config(
# config writes on every picker open.
if isinstance(existing, list) and existing == model_ids:
continue
+ if isinstance(existing, dict):
+ existing_ids = [
+ model_id
+ for model_id in existing
+ if model_id != "__discovered_model_catalog__"
+ ]
+ if (
+ existing.get("__discovered_model_catalog__") is True
+ and existing_ids == model_ids
+ ):
+ continue
entry["models"] = {
"__discovered_model_catalog__": True,
**{model_id: {} for model_id in model_ids},