feat(auth): add credential pool switch command - #45513
Conversation
|
Verification: clean security/reliability review Reviewed the
No issues found. LGTM. |
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
New CLI command hermes auth switch that moves a pooled credential to the first position in the pool, making it the active credential. Also adds a CredentialPool.activate_index() method.
Design: The approach (reordering the entries list, then re-prioritizing from 0) is sound — it's essentially a list move-to-front operation. Persisting after reordering ensures durability. CLI help text is updated, and the implementation correctly uses the pool lock during the operation.
Code Quality: Clean. The reordering uses enumerate for priority assignment, which is idiomatic. The return of self._entries[0] (the moved credential) is useful for CLI feedback.
Reviewed by Hermes Agent (cron batch)
|
Small follow-up after the review: this keeps the core The new commit adds:
Local focused check: |
|
I tested this PR locally because I’m building a standalone A few findings that may help the rebase/review:
Local evidence: focused switch selection/health/ambiguity tests passed; the two full-file failures on the old PR base were existing Codex pool-only rate-limit tests already addressed on newer main, not switch regressions. I’m avoiding a competing auth-switch PR because this one already covers the core CLI primitive. |
|
Thanks for the focused CLI primitive. Current main still lacks an Problems
Suggested changes
Automated hermes-sweeper review. |
|
Followed up on the sweeper review in a rebased branch:
Branch: https://github.com/eonewg/hermes-agent/tree/review/pr-45513-followup Verification:
One PR-metadata change remains for the author: please remove |
|
Opened #67285 as the current- |
Summary
Adds a focused
hermes auth switch <provider> <target>command for manually choosing which credential in a same-provider credential pool should be tried first.The command:
hermes auth remove: 1-based index, credential id, or exact label0instead of adding a second active-credential stateleast_used,round_robin, orrandom) may choose a different credential laterFor
openai-codex, switching an OAuth credential also keeps the singleton Codex auth block aligned with the selected pool entry, because some Codex paths still read that singleton state. That path is intentionally guarded so it:device_codesourcedevice_codeentry tomanual:device_codeso the old account is preservedactive_providerIssues / relation to existing work
Fixes #22407.
Fixes #37224.
Related: #22916, #42798, #43747.
This is a smaller, refreshed alternative to stale PR #17527. It keeps the public surface to one command plus docs/tests, and adds extra Codex regression coverage around singleton/pool drift and independent account preservation.
Verification
scripts/run_tests.sh tests/hermes_cli/test_auth_commands.py tests/hermes_cli/test_auth_codex_provider.pypython -m py_compile agent/credential_pool.py hermes_cli/auth_commands.py hermes_cli/subcommands/auth.py hermes_cli/_parser.pygit diff --checkpython -m hermes_cli.main auth switch openrouter secondagainst a tempHERMES_HOMEreordered the pool to['second', 'first']python -m hermes_cli.main auth switch openai-codex account-Bagainst a tempHERMES_HOMEpromoted account-B todevice_code, demoted account-A tomanual:device_code, and kept both credentials afterload_pool('openai-codex')Review
Independent review was run after implementation. Initial review found Codex singleton/pool edge cases; those were fixed with additional regression tests. Final focused review passed with no remaining blockers.