Skip to content

The agent that grows with you

fix(model): show copilot-acp in pickers when its executable resolves

Solitud1nem1e8f829f1a4c
diff --git a/hermes_cli/model_switch.py b/hermes_cli/model_switch.py
index bb025c95a57..f70c71f30f7 100644
--- a/hermes_cli/model_switch.py
+++ b/hermes_cli/model_switch.py
@@ -3364,6 +3364,19 @@ def list_authenticated_providers(
if any(os.environ.get(ev) for ev in pcfg.api_key_env_vars):
has_creds = True
break
+ # External-process providers (copilot-acp) hold no API key, OAuth
+ # token, or pool entry by design — the spawned ACP subprocess brings
+ # its own auth. "Configured" means the executable resolves, which is
+ # exactly what get_auth_status() reports for them; without this branch
+ # the has_creds filter below unconditionally hides the provider from
+ # every picker (#63662).
+ if not has_creds and overlay.auth_type == "external_process":
+ try:
+ from hermes_cli.auth import get_auth_status
+ _ext_status = get_auth_status(hermes_slug) or {}
+ has_creds = bool(_ext_status.get("logged_in") or _ext_status.get("configured"))
+ except Exception as exc:
+ logger.debug("External-process check failed for %s: %s", pid, exc)
# Check auth store and credential pool for non-env-var credentials.
# This applies to OAuth providers AND api_key providers that also
# support OAuth (e.g. anthropic supports both API key and Claude Code
diff --git a/tests/hermes_cli/test_copilot_in_model_list.py b/tests/hermes_cli/test_copilot_in_model_list.py
index 83832b0c332..ff039f0a781 100644
--- a/tests/hermes_cli/test_copilot_in_model_list.py
+++ b/tests/hermes_cli/test_copilot_in_model_list.py
@@ -3,6 +3,8 @@
import os
from unittest.mock import patch
+import pytest
+
from hermes_cli.model_switch import list_authenticated_providers
@@ -20,3 +22,58 @@ def test_copilot_picker_uses_live_catalog_when_available():
assert copilot is not None
assert copilot["models"] == live_models
assert copilot["total_models"] == len(live_models)
+
+
+# --- copilot-acp: external_process availability (#63662) -------------------
+#
+# copilot-acp holds no API key, OAuth token, or credential-pool entry by
+# design — the spawned `copilot --acp --stdio` subprocess brings its own auth.
+# The picker loop used to filter it out unconditionally (has_creds never had
+# an external_process branch), so the provider was invisible in every picker
+# even with a perfectly resolvable executable.
+
+
+def _no_other_copilot_creds(monkeypatch):
+ """Make sure copilot-acp visibility comes ONLY from executable resolution:
+ no env tokens, no auth-store entry, no seeded credential pool."""
+ for var in ("GH_TOKEN", "GITHUB_TOKEN", "HERMES_COPILOT_ACP_COMMAND", "COPILOT_CLI_PATH"):
+ monkeypatch.delenv(var, raising=False)
+ import hermes_cli.auth as auth
+ import hermes_cli.model_switch as model_switch
+
+ monkeypatch.setattr(auth, "_load_auth_store", lambda: {})
+ monkeypatch.setattr(model_switch, "_credential_pool_is_usable", lambda *a, **k: False)
+
+
+def test_copilot_acp_listed_when_executable_resolves(tmp_path, monkeypatch, _no_other_copilot_creds):
+ fake = tmp_path / ("copilot.exe" if os.name == "nt" else "copilot")
+ fake.write_text("", encoding="utf-8")
+ fake.chmod(0o755)
+ monkeypatch.setenv("HERMES_COPILOT_ACP_COMMAND", str(fake))
+
+ with patch("agent.models_dev.fetch_models_dev", return_value={}), \
+ patch("hermes_cli.models._resolve_copilot_catalog_api_key", return_value=None), \
+ patch("hermes_cli.models._fetch_github_models", return_value=[]):
+ providers = list_authenticated_providers(current_provider="openrouter", max_models=50)
+
+ acp = next((p for p in providers if p["slug"] == "copilot-acp"), None)
+
+ assert acp is not None, "copilot-acp must be listed when its executable resolves"
+ assert acp["models"], "copilot-acp row must offer at least the curated fallback models"
+
+
+def test_copilot_acp_hidden_when_executable_missing(monkeypatch, _no_other_copilot_creds):
+ # `copilot` may genuinely be installed on a dev machine — force the
+ # resolution miss so the test pins behaviour, not the host's PATH.
+ import hermes_cli.auth as auth
+
+ monkeypatch.setattr(auth.shutil, "which", lambda *_a, **_k: None)
+
+ with patch("agent.models_dev.fetch_models_dev", return_value={}), \
+ patch("hermes_cli.models._resolve_copilot_catalog_api_key", return_value=None), \
+ patch("hermes_cli.models._fetch_github_models", return_value=[]):
+ providers = list_authenticated_providers(current_provider="openrouter", max_models=50)
+
+ assert all(p["slug"] != "copilot-acp" for p in providers), \
+ "copilot-acp must stay hidden when no executable resolves"