From dbafb59227ceba22ef1e46214618e85b9c7d1aa6 Mon Sep 17 00:00:00 2001 From: frohsinnllc <231045016+frohsinnllc@users.noreply.github.com> Date: Mon, 13 Jul 2026 01:14:48 +0200 Subject: [PATCH] perf(cli): check local auth.json/config before slow provider registry sweep _has_any_provider_configured() probed every api_key provider (gh subprocess for copilot alone takes 5s; full sweep ~18s) before consulting auth.json and config.yaml, which are instant local reads. Desktop setup.status calls blocked past the UI's timeout, causing the connect/disconnect boot loop. Reorder so cheap local checks run first. Same semantics, ~35x faster here. --- hermes_cli/main.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/hermes_cli/main.py b/hermes_cli/main.py index 28d3009325dde..624d0f10109f7 100644 --- a/hermes_cli/main.py +++ b/hermes_cli/main.py @@ -1013,16 +1013,9 @@ def _has_any_provider_configured() -> bool: except Exception: pass - # Check provider-specific auth fallbacks (for example, Copilot via gh auth). - try: - for provider_id, pconfig in PROVIDER_REGISTRY.items(): - if pconfig.auth_type != "api_key": - continue - status = get_auth_status(provider_id) - if status.get("logged_in"): - return True - except Exception: - pass + # Cheap local checks first: auth.json and config.yaml are on-disk lookups, + # while the PROVIDER_REGISTRY sweep below spawns subprocesses (gh) and can + # take 15-20s — long enough that desktop setup.status calls time out. # Check for Nous Portal OAuth credentials auth_file = get_hermes_home() / "auth.json" @@ -1050,6 +1043,17 @@ def _has_any_provider_configured() -> bool: if cfg_provider or cfg_base_url or cfg_api_key: return True + # Check provider-specific auth fallbacks (for example, Copilot via gh auth). + try: + for provider_id, pconfig in PROVIDER_REGISTRY.items(): + if pconfig.auth_type != "api_key": + continue + status = get_auth_status(provider_id) + if status.get("logged_in"): + return True + except Exception: + pass + # Check for Claude Code OAuth credentials (~/.claude/.credentials.json) # Only count these if Hermes has been explicitly configured — Claude Code # being installed doesn't mean the user wants Hermes to use their tokens.