Skip to content

The agent that grows with you

fix(left-core): a custom endpoint named like a Copilot alias is not Copilot use

Tekniumee929f7684b0
diff --git a/hermes_cli/left_core_migration.py b/hermes_cli/left_core_migration.py
index 007f3e619c3..d4b568c1492 100644
--- a/hermes_cli/left_core_migration.py
+++ b/hermes_cli/left_core_migration.py
@@ -283,9 +283,23 @@ def _delegation_backend_routes(delegation: dict) -> list[dict]:
def providers_selected(home: Path, names: tuple[str, ...], *, process_env: bool = False) -> set[str]:
"""The provider *names* (ids or aliases) *home* routes inference through (:func:`_provider_choices`),
or names in its ``HERMES_INFERENCE_PROVIDER`` (dotenv layers; the process env too for the launch home
- with *process_env*). A credential alone is not a choice: core never routed to a provider for a key."""
+ with *process_env*). A credential alone is not a choice: core never routed to a provider for a key, and
+ a name that is the user's own custom endpoint (``custom_providers: [{name: github, ...}]``) is not one."""
chosen = _provider_choices(home) | {_home_env(home, "HERMES_INFERENCE_PROVIDER", process_env=process_env).lower()}
- return chosen & {name.lower() for name in names}
+ chosen &= {name.lower() for name in names}
+ return {name for name in chosen if not _names_custom_endpoint(home, name)} if chosen else chosen
+
+
+def _names_custom_endpoint(home: Path, name: str) -> bool:
+ """*name* resolves to one of *home*'s own ``providers:`` / ``custom_providers:`` endpoints (the
+ resolver's named-custom rung: ``named_custom_provider_config_path``), not to the provider it aliases."""
+ from gateway import config_loader
+ from hermes_cli.runtime_provider_custom import named_custom_provider_config_path
+ try:
+ return named_custom_provider_config_path(name, config_loader.read_yaml_layers(home)) is not None
+ except Exception: # malformed config.yaml: the resolver finds no custom entry in it either
+ logger.debug("left-core: unreadable config for %s", home, exc_info=True)
+ return False
# GitHub Copilot: the API provider and the Copilot CLI over ACP, ids and every alias their profiles declared.
diff --git a/tests/hermes_cli/test_left_core_provider_rows.py b/tests/hermes_cli/test_left_core_provider_rows.py
index 24852cf7925..8901d63fd06 100644
--- a/tests/hermes_cli/test_left_core_provider_rows.py
+++ b/tests/hermes_cli/test_left_core_provider_rows.py
@@ -78,6 +78,11 @@ def test_copilot_in_use_is_any_provider_slot_naming_it(tmp_path, config, env, au
("model:\n provider: openrouter\n default: github/copilot-like\n", "", None),
("", "", {"credential_pool": {"copilot": [{"source": "gh_cli", "access_token": "t"}]}}),
("model: copilot\n", "", None), # a bare model string names a model, not a provider
+ # the user's own endpoint under a name that is also a Copilot alias: the resolver serves it as custom
+ ("model:\n provider: github\ncustom_providers:\n - name: github\n"
+ " base_url: https://llm.example.test/v1\n", "", None),
+ ("model:\n provider: github-models\nproviders:\n github-models:\n"
+ " base_url: https://llm.example.test/v1\n", "", None),
])
def test_copilot_credentials_alone_are_not_use(tmp_path, config, env, auth):
assert lcm.copilot_in_use(_home(tmp_path, config=config, env=env, auth=auth)) is False