Skip to content

The agent that grows with you

fix(providers): overlay aliases are declared, and mirrored alias keys keep the overlay route

Teknium10312d0c9cef
diff --git a/hermes_cli/providers.py b/hermes_cli/providers.py
index d4392165281..c3789277ae5 100644
--- a/hermes_cli/providers.py
+++ b/hermes_cli/providers.py
@@ -168,11 +168,11 @@ def _overlay_profiles() -> list:
def _overlay_profile(name: str):
- """The overlay-declaring profile *name* (its id, models.dev id or an alias) belongs to, or None."""
+ """The overlay-declaring profile *name* (its id, models.dev id or an overlay alias) belongs to, or None."""
if not name:
return None
return next((prof for prof in _overlay_profiles()
- if name in (prof.name, prof.models_dev_id, *prof.aliases)), None)
+ if name in (prof.name, prof.models_dev_id, *prof.overlay_aliases)), None)
def _profile_overlay_key(prof) -> str:
@@ -526,7 +526,11 @@ def _lossy_alias_registry_pdef(raw: str, canonical: str) -> Optional[ProviderDef
_pcfg = _AUTH_PROVIDER_REGISTRY.get(raw)
if _pcfg is None:
return None
- if sum(1 for _rid in _AUTH_PROVIDER_REGISTRY if normalize_provider(_rid) == canonical) > 1:
+ _rows = [_row for _rid, _row in _AUTH_PROVIDER_REGISTRY.items() if normalize_provider(_rid) == canonical]
+ # A profile-declared overlay routes its own mirrored alias keys through the built-in chain.
+ if all(_row is _pcfg for _row in _rows) and _overlay_profile(canonical) is not None:
+ return None
+ if len(_rows) > 1:
return ProviderDef(id=_pcfg.id, name=_pcfg.name, transport="openai_chat",
api_key_env_vars=tuple(_pcfg.api_key_env_vars or ()), base_url=_pcfg.inference_base_url or "",
source="hermes-auth-registry")
diff --git a/plugins/model-providers/copilot-acp/picker.py b/plugins/model-providers/copilot-acp/picker.py
index da9a89a0974..897d76d5b9f 100644
--- a/plugins/model-providers/copilot-acp/picker.py
+++ b/plugins/model-providers/copilot-acp/picker.py
@@ -12,4 +12,5 @@ PICKER_FIELDS = dict(
catalog_aliases=True,
provider_overlay={"transport": "codex_responses", "auth_type": "external_process",
"base_url_override": "acp://copilot", "base_url_env_var": "COPILOT_ACP_BASE_URL"},
+ overlay_aliases=("github-copilot-acp",),
)
diff --git a/plugins/model-providers/copilot/picker.py b/plugins/model-providers/copilot/picker.py
index 7ee3dc0d09a..3c9f31afba6 100644
--- a/plugins/model-providers/copilot/picker.py
+++ b/plugins/model-providers/copilot/picker.py
@@ -16,4 +16,5 @@ PICKER_FIELDS = dict(
aggregator=True,
# models.dev lists GitHub Copilot under GITHUB_TOKEN only; Hermes also reads these two.
provider_overlay={"extra_env_vars": ("COPILOT_GITHUB_TOKEN", "GH_TOKEN")},
+ overlay_aliases=("github",),
)
diff --git a/providers/base.py b/providers/base.py
index e618cc64848..34ee369d092 100644
--- a/providers/base.py
+++ b/providers/base.py
@@ -718,6 +718,8 @@ class ProviderProfile:
# HermesOverlay fields (transport, auth_type, extra_env_vars, base_url_override, base_url_env_var) for
# the provider's models.dev-keyed definition, keyed by ``models_dev_id`` or ``name``; {} = none.
provider_overlay: dict = field(default_factory=dict)
+ # Extra names that normalize to the ``provider_overlay`` definition (its id, else ``name``); () = none.
+ overlay_aliases: tuple = ()
# --- I2-auth: hermes-auth registry row mirrored from this profile (hermes_cli/auth_plugin_providers.py) ---
# auth_type of the registry row when credential resolution differs from the setup flow ``auth_type`` names
diff --git a/tests/hermes_cli/test_provider_table_placement.py b/tests/hermes_cli/test_provider_table_placement.py
index e7829f88e6b..c57a9825b49 100644
--- a/tests/hermes_cli/test_provider_table_placement.py
+++ b/tests/hermes_cli/test_provider_table_placement.py
@@ -70,8 +70,8 @@ def test_provider_overlay_defines_the_models_dev_keyed_provider(monkeypatch):
from hermes_cli import providers as prov
overlaid = ProviderProfile(
- name="zz-acp", aliases=("zz-acp-agent",), display_name="ZZ ACP", base_url="acp://zz",
- auth_type="external_process",
+ name="zz-acp", aliases=("zz-acp-agent", "zz-acp-cli"), display_name="ZZ ACP", base_url="acp://zz",
+ auth_type="external_process", overlay_aliases=("zz-acp-agent",),
provider_overlay={"transport": "codex_responses", "auth_type": "external_process",
"base_url_override": "acp://zz", "base_url_env_var": "ZZ_ACP_BASE_URL"})
plain = ProviderProfile(name="zz-plain", aliases=("zzp",), base_url="https://zz.test/v1")
@@ -80,6 +80,7 @@ def test_provider_overlay_defines_the_models_dev_keyed_provider(monkeypatch):
assert prov.normalize_provider("ZZ-ACP-Agent") == "zz-acp"
assert prov.normalize_provider("zzp") == "zzp" # no overlay: the providers layer leaves it alone
+ assert prov.normalize_provider("zz-acp-cli") == "zz-acp-cli" # only overlay_aliases name the overlay
pdef = prov.get_provider("zz-acp-agent")
assert (pdef.id, pdef.name, pdef.transport, pdef.base_url, pdef.base_url_env_var, pdef.source) == (
"zz-acp", "ZZ ACP", "codex_responses", "acp://zz", "ZZ_ACP_BASE_URL", "hermes")
@@ -87,6 +88,28 @@ def test_provider_overlay_defines_the_models_dev_keyed_provider(monkeypatch):
assert "zz-acp" in prov.hermes_overlays() and "zz-plain" not in prov.hermes_overlays()
+def test_mirrored_alias_keys_keep_the_overlay_route(monkeypatch):
+ """An overlay-declaring profile's own alias keys in the auth registry share its one row: resolving
+ an alias goes through the overlay (transport, base-URL env var), not the lossy-collapse registry rung."""
+ from types import SimpleNamespace
+
+ from hermes_cli import auth
+ from hermes_cli import providers as prov
+
+ overlaid = ProviderProfile(
+ name="zz-acp", aliases=("zz-acp-agent",), display_name="ZZ ACP", base_url="acp://zz",
+ overlay_aliases=("zz-acp-agent",), provider_overlay={"transport": "codex_responses",
+ "base_url_override": "acp://zz"})
+ _use_profiles(monkeypatch, overlaid)
+ monkeypatch.setattr(prov, "_models_dev_info", lambda canonical, allow_network=True: None)
+ row = SimpleNamespace(id="zz-acp", name="ZZ ACP", api_key_env_vars=(), inference_base_url="acp://zz")
+ monkeypatch.setattr(auth, "PROVIDER_REGISTRY", {"zz-acp": row, "zz-acp-agent": row})
+
+ pdef = prov.resolve_provider_full("zz-acp-agent")
+
+ assert (pdef.id, pdef.transport, pdef.source) == ("zz-acp", "codex_responses", "hermes")
+
+
def test_profile_models_dev_id_resolves_at_lookup_time(monkeypatch):
import agent.models_dev as md