From 5b4c5b00946967fea999324a9a9590f78460194d Mon Sep 17 00:00:00 2001 From: nesquena-hermes Date: Mon, 6 Apr 2026 14:35:30 -0700 Subject: [PATCH] fix: exclude ambient gh-cli token from model dropdown provider detection (#158) Co-authored-by: Nathan Esquenazi --- api/config.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/api/config.py b/api/config.py index ee64438..1a9ba93 100644 --- a/api/config.py +++ b/api/config.py @@ -496,9 +496,20 @@ def get_available_models() -> dict: _hermes_auth_used = False try: from hermes_cli.models import list_available_providers as _lap + from hermes_cli.auth import get_auth_status as _gas for _p in _lap(): - if _p.get('authenticated'): - detected_providers.add(_p['id']) + if not _p.get('authenticated'): + continue + # Exclude providers whose credential came from an ambient token + # (e.g. 'gh auth token' for Copilot on a machine with gh CLI auth). + # Only include providers with an explicit, dedicated credential. + try: + _src = _gas(_p['id']).get('key_source', '') + if _src == 'gh auth token': + continue + except Exception: + pass + detected_providers.add(_p['id']) _hermes_auth_used = True except Exception: pass