fix(auth): scope Codex quota cooldown clearing by token - #70208
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for tracing the cleanup scope through both recovery paths. The production premise is confirmed on current main: hermes_cli/auth.py:3916 and agent/account_usage.py:710 both omit the token, while the helper already filters correctly when given one at hermes_cli/auth.py:4157.
Problems
- The regression-test hunks need manual salvage. Current main retains the probe recovery test at
tests/hermes_cli/test_auth_codex_quota_probe.py:221, but the reset-redemption section is empty after line 280 following test pruning; the PR's old test locations no longer exist.
Suggested changes
- Port the two-account probe assertion into the current recovery test and recreate the successful reset-redemption two-account regression in a current account-usage or quota-probe test location.
Automated hermes-sweeper review.
| @@ -340,9 +357,11 @@ def test_resolver_recovers_when_probe_confirms_reset(tmp_path, monkeypatch): | |||
| assert resolved["source"] == "credential_pool" | |||
There was a problem hiding this comment.
Current main retains this recovery test but has pruned and renumbered it to lines 221-240. Port this two-account assertion into that surviving test during salvage so the token-scoping regression remains covered.
| @@ -498,11 +534,13 @@ def post(self, url, headers=None, json=None): | |||
|
|
|||
There was a problem hiding this comment.
Current main has no remaining reset-redemption test in this file after its test-pruning change. Recreate this two-account reset regression in a current test location when salvaging the production call change.
What does this PR do?
Keeps Codex quota recovery scoped to the credential whose quota was actually
confirmed restored.
The early-reset recovery added in #69494 already accepts an optional
access_tokeninclear_codex_pool_quota_cooldowns(), but its two runtimecallers omitted that argument. In a multi-account credential pool, a positive
usage probe or successful reset redemption for account A therefore cleared
the persisted 429 cooldown for unrelated account B as well. If account B was
still at 100% usage, it re-entered rotation only to fail and be quarantined
again.
Related Issue
Follow-up to #69494 and the multi-account behavior reported in #43747.
Type of Change
Changes Made
hermes_cli/auth.py: pass the positively probedstale_tokenwhen clearinga stale Codex pool cooldown.
agent/account_usage.py: pass the token used for a successful/usage resetredemption.
tests/hermes_cli/test_auth_codex_quota_probe.py: cover a two-account poolcontaining a separate
manual:device_codecredential that must remainexhausted.
administrative reset.
How to Test
openai-codexpool entries with different accesstokens.
429 status and future
last_error_reset_at.Before the fix, the two strengthened regressions failed because both entries
were cleared. After the fix:
Checklist
Code
pytest tests/ -qsuiteDocumentation & Housekeeping
cli-config.yaml.exampleupdate is N/ACONTRIBUTING.md/AGENTS.mdupdate is N/AScreenshots / Logs
N/A — credential state is covered by hermetic regression tests; no secrets or
live authentication data are included.