Skip to content

The agent that grows with you

fix: accept pool-only Anthropic OAuth entries in the desktop picker filter

Teknium4f0e466e5d1c
diff --git a/hermes_cli/inventory.py b/hermes_cli/inventory.py
index 094a66a62db..2f426f67379 100644
--- a/hermes_cli/inventory.py
+++ b/hermes_cli/inventory.py
@@ -683,9 +683,29 @@ def _anthropic_oauth_credentials_present() -> bool:
if hermes_creds.get("accessToken"):
return True
cc_creds = read_claude_code_credentials() or {}
- return bool(cc_creds.get("accessToken"))
+ if cc_creds.get("accessToken"):
+ return True
except Exception:
return False
+ # Pool-only OAuth entries (auth.json credential_pool.anthropic) are the
+ # canonical location for wired tokens and equally deliberate — the
+ # discovery side accepts them via pool.has_credentials(), so the filter
+ # must too or those rows are built and then silently dropped. Read-only
+ # dict access (no load_pool) so a picker open never mutates auth.json.
+ try:
+ from agent.credential_pool import AUTH_TYPE_OAUTH
+ from hermes_cli.auth import read_credential_pool
+
+ for entry in read_credential_pool("anthropic"):
+ if (
+ isinstance(entry, dict)
+ and entry.get("auth_type") == AUTH_TYPE_OAUTH
+ and str(entry.get("access_token") or "").strip()
+ ):
+ return True
+ except Exception:
+ pass
+ return False
def _filter_explicit_provider_rows(rows: list[dict], ctx: ConfigContext) -> list[dict]:
diff --git a/tests/hermes_cli/test_inventory.py b/tests/hermes_cli/test_inventory.py
index 7b4ff6e575c..1441beaa84d 100644
--- a/tests/hermes_cli/test_inventory.py
+++ b/tests/hermes_cli/test_inventory.py
@@ -274,6 +274,54 @@ def test_explicit_only_drops_anthropic_row_without_oauth_credentials():
assert "anthropic" not in [row["slug"] for row in payload["providers"]]
+def test_anthropic_oauth_presence_accepts_pool_only_oauth_entry():
+ """A pool-only OAuth entry (auth.json credential_pool.anthropic) counts.
+
+ Wired/device-flow tokens land in the credential pool, not in
+ .anthropic_oauth.json or ~/.claude/.credentials.json. The presence
+ check must accept them or the row is built and then silently dropped.
+ """
+ from hermes_cli.inventory import _anthropic_oauth_credentials_present
+
+ with (
+ patch(
+ "agent.anthropic_adapter.read_hermes_oauth_credentials",
+ return_value=None,
+ ),
+ patch(
+ "agent.anthropic_adapter.read_claude_code_credentials",
+ return_value=None,
+ ),
+ patch(
+ "hermes_cli.auth.read_credential_pool",
+ return_value=[
+ {"auth_type": "oauth", "access_token": "sk-ant-oat01-pool"}
+ ],
+ ),
+ ):
+ assert _anthropic_oauth_credentials_present() is True
+
+ # api_key pool entries are NOT OAuth logins — presence must stay False
+ # (they are handled by the explicit-config gate / env var paths).
+ with (
+ patch(
+ "agent.anthropic_adapter.read_hermes_oauth_credentials",
+ return_value=None,
+ ),
+ patch(
+ "agent.anthropic_adapter.read_claude_code_credentials",
+ return_value=None,
+ ),
+ patch(
+ "hermes_cli.auth.read_credential_pool",
+ return_value=[
+ {"auth_type": "api_key", "access_token": "sk-ant-api03-key"}
+ ],
+ ),
+ ):
+ assert _anthropic_oauth_credentials_present() is False
+
+
# ─── picker_hints ──────────────────────────────────────────────────────