Fix Codex CLI sync clobbering manual pool entries#12924
Conversation
|
Repro context from production use: an pool contained both shared CLI/device-code credentials and manual dashboard-added credentials. After a 429, the exhausted manual entry could be synced from , immediately become selectable again, and appear to rotate back to the same label. In the affected state, labels could also drift away from the actual token identity, and duplicate polluted entries could remain in the pool. |
|
Repro context from production use: an openai-codex pool contained both shared CLI/device-code credentials and manual dashboard-added credentials. After a 429, the exhausted manual entry could be synced from ~/.codex/auth.json, immediately become selectable again, and appear to rotate back to the same label. In the affected state, labels could also drift away from the actual token identity, and duplicate polluted entries could remain in the pool. |
|
Thanks for the submission @Alex-giao. Closing as superseded — fixed Hermes's Codex auth design was reworked in #12360 ("Hermes owns its own Codex auth; stop touching The valid adjacent fixes from this batch (error parsing, fallback chain on auth failure, reauth UX) landed together in #15104. |
Summary
This fixes an
openai-codexcredential-pool bug where~/.codex/auth.jsoncould overwrite manual pool entries, causing 429-rotated entries to appear to rotate but then immediately select the same logical slot again.Root cause
_sync_codex_entry_from_cli()treated any exhausted Codex OAuth entry as eligible for CLI token sync. In mixed pools, that allowed shared CLI/device-code tokens to clobber manual dashboard entries, drift labels away from the underlying token identity, and leave duplicated polluted entries in the pool.Changes
~/.codex/auth.jsonproviders.openai-codex.tokensTest plan
venv/bin/python -m pytest tests/agent/test_credential_pool.py -qvenv/bin/python -m pytest tests/agent/test_credential_pool_routing.py -q