Skip to content

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

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-0e6e2eff
Jun 4, 2026
Merged

fix(auth): set active_provider after hermes auth add google-gemini-cli#39012
teknium1 merged 1 commit into
mainfrom
hermes/hermes-0e6e2eff

Conversation

@teknium1

@teknium1 teknium1 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

hermes auth add google-gemini-cli now sets active_provider in auth.json, so the setup wizard and status commands detect the provider after a successful OAuth login.

Previously the Gemini CLI path only called pool.add_entry() and never wrote active_provider, so _model_section_has_credentials() reported "No inference provider configured" even though the agent worked (runtime reads tokens from the Google OAuth credential file via agent.google_oauth, independent of auth.json).

Changes

  • hermes_cli/auth.py: new _mark_google_gemini_cli_active() — writes minimal provider state (email only) and sets active_provider. Deliberately does NOT copy access_token/refresh_token into auth.json; those are managed by agent.google_oauth in the Google credential file and would go stale.
  • hermes_cli/auth_commands.py: call it after the OAuth login completes.
  • tests/hermes_cli/test_auth_commands.py: new test asserting active_provider is set, state holds only email, and the pool entry still exists.

Validation

Before After
active_provider after login unset google-gemini-cli
Setup/status detection "No inference provider configured" provider detected
Tokens in auth.json n/a none (live in Google OAuth credential file)

Targeted suite: 47/47 test_auth_commands pass. E2E verified end-to-end with isolated HERMES_HOME — auth_add_command sets active_provider and get_active_provider() returns google-gemini-cli, with email-only state and no tokens copied.

Salvaged from #37601 by @AhmetArif0 (commit cherry-picked onto current main, authorship preserved). Same bug class as the codex path (_save_codex_tokens sets active).

Infographic

active-provider-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).
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-0e6e2eff vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9792 on HEAD, 9792 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 5085 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard area/auth Authentication, OAuth, credential pools provider/gemini Google Gemini (AI Studio, Cloud Code) P3 Low — cosmetic, nice to have labels Jun 4, 2026
@teknium1
teknium1 merged commit 34a2903 into main Jun 4, 2026
23 checks passed
@teknium1
teknium1 deleted the hermes/hermes-0e6e2eff branch June 4, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have provider/gemini Google Gemini (AI Studio, Cloud Code) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants