fix(auth): merge credential pool entries on persist, preserve exhaustion on sync - #7202
Closed
mvanhorn wants to merge 1 commit into
Closed
fix(auth): merge credential pool entries on persist, preserve exhaustion on sync#7202mvanhorn wants to merge 1 commit into
mvanhorn wants to merge 1 commit into
Conversation
…ion on sync Two fixes for credential pool concurrency: 1. _persist() now reads disk entries and merges by ID instead of replacing the entire provider list. Entries added by other processes (e.g., hermes auth add in another terminal) survive a persist from a running session. 2. _sync_codex_entry_from_cli() now skips manual-source entries and preserves exhaustion status when syncing tokens. Fresh tokens from ~/.codex/auth.json don't imply the rate limit has lifted. Fixes NousResearch#6907
|
👍🏻 I want this! |
Contributor
Author
|
Thanks @PavelPancocha - covers the exhaustion-on-sync case from #6907. Still waiting on a maintainer pass. |
1 task
Contributor
|
Thanks for the focused concurrency investigation. This is now redundant on current
This is an automated hermes-sweeper review. |
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.
What does this PR do?
Fixes two concurrency bugs in the credential pool that cause credential loss and stale token injection when multiple Hermes instances share the same auth store.
_persist()now does a read-merge-write by entry ID instead of replacing the entire provider's entry list. Entries added by another process (e.g.,hermes auth add openai-codex --label chatgpt-2in another terminal) are preserved across persists._sync_codex_entry_from_cli()now skips manual-source entries entirely (they use Hermes-native tokens, not CLI tokens) and preserves exhaustion status when syncing - fresh tokens from~/.codex/auth.jsondon't mean the provider rate limit has lifted.Related Issue
Fixes #6907
Type of Change
Changes Made
agent/credential_pool.py: Changed_persist()(line 389) fromwrite_credential_pool()to a merge-by-ID pattern under_auth_store_lock(). Disk entries with IDs not in memory are preserved.agent/credential_pool.py: Added early return in_sync_codex_entry_from_cli()forSOURCE_MANUALentries. Changed token sync to preserve exhaustion markers (STATUS_EXHAUSTEDentries keep their status).tests/agent/test_credential_pool.py: Added 30 tests covering merge persistence, manual entry skip, and exhaustion preservation.How to Test
hermessession withopenai-codexas the providerhermes auth add openai-codex --label chatgpt-2chatgpt-2credential survives and rotation workshermes auth list openai-codexto confirm both entries are presentChecklist
Code
pytest tests/ -qand all tests passDocumentation & Housekeeping
This contribution was developed with AI assistance (Codex).