From 0741a2ab9f04b07e12c7cd127b79b6f4e7d8c453 Mon Sep 17 00:00:00 2001 From: bergeouss Date: Tue, 28 Apr 2026 10:58:23 +0000 Subject: [PATCH] fix: skip get_auth_status() fallback for known API-key providers Avoids unnecessary latency on the Settings page by restricting the OAuth auth-status fallback to providers that are not in _PROVIDER_ENV_VAR. Review feedback (PR #1221): the get_auth_status() call in the else branch was firing for every unconfigured API-key provider (openai, anthropic, etc.), adding a network round-trip per provider. Now it only runs for providers that are not known API-key providers (custom/OAuth-capable providers). --- api/providers.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/api/providers.py b/api/providers.py index de038552..20bc0c58 100644 --- a/api/providers.py +++ b/api/providers.py @@ -312,12 +312,17 @@ def get_providers() -> dict[str, Any]: key_source = "config_yaml" else: key_source = "config_yaml" - else: - # Fallback: provider may be authenticated via hermes auth even - # though it is not in the hardcoded _OAUTH_PROVIDERS set - # (e.g. Anthropic connected via OAuth). Check live auth - # status so the Providers tab agrees with the model picker - # (#1212). + elif pid not in _PROVIDER_ENV_VAR: + # Fallback: provider is not a known API-key provider and not in + # the hardcoded _OAUTH_PROVIDERS set. It may be a custom or + # newly-added OAuth provider (e.g. Anthropic connected via OAuth). + # Check live auth status so the Providers tab agrees with the + # model picker (#1212). + # + # IMPORTANT: we skip providers in _PROVIDER_ENV_VAR because they + # are pure API-key providers — calling get_auth_status() for every + # unconfigured API-key provider would add unnecessary latency + # (network round-trip per provider) on the Settings page. try: from hermes_cli.auth import get_auth_status as _gas status = _gas(pid)