fix(auth): set active_provider after hermes auth add google-gemini-cli - #39012
Merged
Conversation
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).
Contributor
🔎 Lint report:
|
2 tasks
Open
19 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
hermes auth add google-gemini-clinow setsactive_providerin 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 wroteactive_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 viaagent.google_oauth, independent of auth.json).Changes
hermes_cli/auth.py: new_mark_google_gemini_cli_active()— writes minimal provider state (emailonly) and setsactive_provider. Deliberately does NOT copyaccess_token/refresh_tokeninto auth.json; those are managed byagent.google_oauthin 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 assertingactive_provideris set, state holds onlyemail, and the pool entry still exists.Validation
active_providerafter logingoogle-gemini-cliTargeted suite: 47/47
test_auth_commandspass. E2E verified end-to-end with isolated HERMES_HOME —auth_add_commandsetsactive_providerandget_active_provider()returnsgoogle-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_tokenssets active).Infographic