fix(auth): set active_provider after hermes auth add google-gemini-cli

hermes auth add google-gemini-cli called pool.add_entry() but never wrote
to providers["google-gemini-cli"] or set active_provider in auth.json.
_model_section_has_credentials() checks get_active_provider() first; with
active_provider unset and no api_key_env_vars configured for oauth_external
providers, the setup wizard reported "No inference provider configured" even
after a successful OAuth login.

Add _mark_google_gemini_cli_active() in auth.py: writes a minimal provider
state entry (email for display only) and calls _save_provider_state() to set
active_provider. The function deliberately does not copy access_token or
refresh_token — those are managed by agent.google_oauth in the Google
credential file and must not be duplicated in auth.json where they would
become stale.

pool.add_entry() is retained so "hermes auth list" continues to show the entry.
Runtime credential resolution continues to use agent.google_oauth directly.

Mirrors the fix applied to openai-codex (#37517) and xai-oauth (#37576).
This commit is contained in:
AhmetArif0
2026-06-04 05:44:22 -07:00
committed by Teknium
parent 9fbfeb31b9
commit 34a2903527
3 changed files with 64 additions and 0 deletions
+18
View File
@@ -2100,6 +2100,24 @@ def get_qwen_auth_status() -> Dict[str, Any]:
# Actual HTTP traffic goes to https://cloudcode-pa.googleapis.com/v1internal:*.
# =============================================================================
def _mark_google_gemini_cli_active(creds: Dict[str, Any]) -> None:
"""Set active_provider to google-gemini-cli in auth.json.
The actual OAuth tokens live in the Google credential file managed by
agent.google_oauth. This function only writes a minimal provider-state
entry (email for display) and sets active_provider so that
get_active_provider() and _model_section_has_credentials() detect the
provider for the setup wizard and status commands.
"""
with _auth_store_lock():
auth_store = _load_auth_store()
state: Dict[str, Any] = {}
if creds.get("email"):
state["email"] = str(creds["email"])
_save_provider_state(auth_store, "google-gemini-cli", state)
_save_auth_store(auth_store)
def resolve_gemini_oauth_runtime_credentials(
*,
force_refresh: bool = False,
+1
View File
@@ -353,6 +353,7 @@ def auth_add_command(args) -> None:
from agent.google_oauth import run_gemini_oauth_login_pure
creds = run_gemini_oauth_login_pure()
auth_mod._mark_google_gemini_cli_active(creds)
label = (getattr(args, "label", None) or "").strip() or (
creds.get("email") or _oauth_default_label(provider, len(pool.entries()) + 1)
)