Skip to content

The agent that grows with you

test(profiles): pin same-identity eviction of URL-less and disabled entries

kshitijk4poor0f447876cab9
diff --git a/hermes_cli/profile_model_seed.py b/hermes_cli/profile_model_seed.py
index b2703193be6..553daf48b13 100644
--- a/hermes_cli/profile_model_seed.py
+++ b/hermes_cli/profile_model_seed.py
@@ -1,4 +1,5 @@
-"""Copy the model and its selected custom endpoint when creating an independent profile."""
+"""Copy the model and its selected custom endpoint into a new profile, and merge that endpoint
+over same-identity entries the new profile already has."""
from hermes_cli.config import _expand_env_vars, find_provider_entry
from hermes_cli.config_providers import _normalize_custom_provider_entry
@@ -17,6 +18,7 @@ def _requested_provider(model_cfg) -> str | None:
def _resolve(provider: str, cfg: dict):
+ """Runtime named-endpoint lookup on *cfg* without reading any credential."""
return _get_named_custom_provider(provider, config=cfg, resolve_credentials=False)
@@ -90,7 +92,9 @@ def merge_endpoint_seed(dst_cfg: dict, seed: dict) -> dict:
claim any of its identities are dropped in both sections: Hermes has several name lookups with
different skip rules (URL validation, ``enabled``, keyed-first), so only removing every
same-identity entry guarantees each of them lands on the inherited endpoint. A URL-less tuning
- seed (``providers.custom``) claims no identity and replaces only its own key."""
+ seed (``providers.custom``) claims no identity and replaces only its own key. Dropped entries
+ include URL-less or disabled ones sharing a name (e.g. ``providers.openrouter`` tuning under a
+ custom endpoint named OpenRouter); this only runs for a new profile without a model."""
seed_providers = seed.get("providers") or {}
seed_custom = seed.get("custom_providers") or []
provider = _requested_provider(seed.get("model"))
diff --git a/tests/hermes_cli/test_profile_model_seed.py b/tests/hermes_cli/test_profile_model_seed.py
index 6f33446c501..8a2bb258f4c 100644
--- a/tests/hermes_cli/test_profile_model_seed.py
+++ b/tests/hermes_cli/test_profile_model_seed.py
@@ -197,13 +197,13 @@ LAB = {"provider": "custom:lab", "default": "synthetic-model"}
{"providers": {"stale": {"name": "lab", "base_url": URL + "x"}}},
{"providers": {}, "custom_providers": [{"name": "Lab", "base_url": URL}]},
),
- # A scheme-less keyed URL still matches at runtime, so it is evicted too.
+ # The same key claims the identity whatever its URL shape.
(
{"custom_providers": [{"name": "Lab", "base_url": URL}]},
{"providers": {"lab": {"base_url": "localhost:9999/v1"}}},
{"providers": {}, "custom_providers": [{"name": "Lab", "base_url": URL}]},
),
- # A camelCase ``baseUrl`` legacy seed is a live endpoint and still evicts its shadow.
+ # A camelCase ``baseUrl`` seed resolves, so it claims its identities.
(
{"custom_providers": [{"name": "Lab", "baseUrl": URL}]},
{"providers": {"lab": {"base_url": URL + "x"}}},
@@ -218,6 +218,18 @@ LAB = {"provider": "custom:lab", "default": "synthetic-model"}
"custom_providers": [{"name": "Lab", "base_url": URL, "enabled": False}],
},
),
+ # Same-identity destination entries go even when they could not win on their own:
+ # URL-less tuning and disabled entries (the pin step resolves names with other rules).
+ (
+ {"custom_providers": [{"name": "Lab", "base_url": URL}]},
+ {
+ "providers": {
+ "lab": {"request_timeout_seconds": 9},
+ "old": {"name": "lab", "base_url": URL + "x", "enabled": False},
+ }
+ },
+ {"providers": {}, "custom_providers": [{"name": "Lab", "base_url": URL}]},
+ ),
# Unrelated destination entries are kept.
(
{"custom_providers": [{"name": "Lab", "base_url": URL}]},