fix(codex): adopt refresh_token from auth.json even without access_token (#70097) - #70111
Closed
JonthanaHanh wants to merge 1 commit into
Closed
Conversation
…ken (NousResearch#70097) Two defects in the openai-codex credential pool recovery path: Defect 1 — adoption path silently no-ops when store_access is empty _sync_codex_entry_from_auth_store() skipped adoption when the auth store had no access_token (only last_refresh). When another process rotated the token pair, the stale profile's entry kept the consumed refresh_token and replayed it, getting refresh_token_reused and going terminally DEAD. Fix: also adopt when store_refresh differs from entry_refresh, even when store_access is empty. Keep the entry's existing access_token in that case (store_access or entry.access_token). Defect 2 — false 'auth refreshed' success log _try_refresh_codex_client_credentials() returned True whenever resolve_codex_runtime_credentials() returned any non-empty credentials, including the same stale token when the underlying refresh failed. The conversation loop then logged 'auth refreshed after 401' right before the retry failed with the identical token_expired. Fix: compare the access token before/after the refresh. If unchanged, return False so the 401-retry path logs the truth. Fixes NousResearch#70097
This was referenced Jul 23, 2026
25 tasks
Contributor
|
Thanks for isolating the refresh-token-only adoption case. The Codex pool defect is still present on current Problems
Suggested changes
This is an automated hermes-sweeper review. |
Collaborator
|
Merged via #77028. Your fix for both defects (refresh_token adoption without access_token + false auth-refreshed log) was cherry-picked with authorship preserved. A follow-up commit widens the source guard to also cover |
kshitijk4poor
added a commit
that referenced
this pull request
Aug 2, 2026
The _sync_codex_entry_from_auth_store source guard returned early for source='manual:device_code', which is the recommended quarantine-safe configuration (hermes auth add openai-codex produces SOURCE_MANUAL_DEVICE_CODE). The PR's fix for refresh_token adoption was unreachable for these entries. Widen the guard to accept both 'device_code' and 'manual:device_code'. Follow-up to #70111. Issue reporter (imgyf) confirmed this caused a 12-of-16 fleet outage on Aug 1. Co-authored-by: imgyf <imgyf@users.noreply.github.com>
randlee
pushed a commit
to randlee/hermes-agent
that referenced
this pull request
Aug 11, 2026
The _sync_codex_entry_from_auth_store source guard returned early for source='manual:device_code', which is the recommended quarantine-safe configuration (hermes auth add openai-codex produces SOURCE_MANUAL_DEVICE_CODE). The PR's fix for refresh_token adoption was unreachable for these entries. Widen the guard to accept both 'device_code' and 'manual:device_code'. Follow-up to NousResearch#70111. Issue reporter (imgyf) confirmed this caused a 12-of-16 fleet outage on Aug 1. Co-authored-by: imgyf <imgyf@users.noreply.github.com>
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.
Summary
Fixes two defects in the openai-codex credential pool recovery path that cause profiles to go terminally DEAD when a sibling profile rotates the shared token pair.
Defect 1 — adoption path silently no-ops
Root cause:
_sync_codex_entry_from_auth_store()(credential_pool.py:768) skips adoption whenstore_accessis empty. When another process rotated the token pair and the auth store only haslast_refresh+ a newrefresh_token(noaccess_token), the stale profile's entry keeps the consumedrefresh_tokenand replays it, gettingrefresh_token_reused→ terminally DEAD.Fix: Also adopt when
store_refreshdiffers fromentry_refresh, even whenstore_accessis empty. Preserve the entry's existingaccess_tokenviastore_access or entry.access_token.Defect 2 — false "auth refreshed" success log
Root cause:
_try_refresh_codex_client_credentials()(run_agent.py:4583) returnsTruewheneverresolve_codex_runtime_credentials()returns any non-empty credentials — including the same stale token when the underlying refresh failed (failure islogger.debug-only). The conversation loop then logs "auth refreshed after 401" right before the retry fails with the identicaltoken_expired.Fix: Compare the access token before/after the refresh. If unchanged, return
Falseso the 401-retry path doesn't claim success.Changes
agent/credential_pool.pyrun_agent.pyFixes #70097