feat: add Codex quota usage indicator - #19063
Conversation
5e86a54 to
c2e8800
Compare
c2e8800 to
c187d19
Compare
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the Codex quota status-bar work. Current main now has a shared Codex account-usage client, so this needs a focused salvage rather than a parallel fetcher.
Problems
agent/codex_quota.py:261broadly catches resolver failures and then selects a pooled credential. A transient refresh failure can therefore show limits for another account. Main explicitly prevents that inagent/account_usage.py:459-464; the guard test istests/agent/test_account_usage.py:121-152(130e2337c24810bc0afa793495795b832cf593be).- Current CLI
/usagealready passes live provider/base-URL/API-key context into the shared fetcher atcli.py:9681-9698. The proposed separate client should not bypass that established resolution path.
Suggested changes
- Build the status-bar view from
agent.account_usage.fetch_account_usageand retain its fail-open credential handling. - Add status-bar coverage in
tests/cli/test_cli_status_bar.py, including non-Codex and transient-credential-failure cases.
Automated hermes-sweeper review.
|
|
||
|
|
||
| def _codex_usage_headers(api_key: str, account_id: Optional[str]) -> dict[str, str]: | ||
| headers = { |
There was a problem hiding this comment.
Do not catch every resolver failure and fall back to pool.select(): a transient refresh/network failure can make this display quota for a different ChatGPT account. Current main fixed this exact class by limiting pool fallback to AuthError in agent/account_usage.py:459-464 (guarded by tests/agent/test_account_usage.py:121-152).
GottZ
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
Summary
Eight PRs address or reference Codex quota visibility, but no Verify verdicts are recorded; the supplied diffs range from direct status-bar implementations to broader or superseded account-usage work. The strongest current fit is #44506, which reuses the shared account-usage fetcher and adds a scoped, nonblocking Codex session-limit segment, whereas several alternatives introduce parallel fetch paths or are based on obsolete status-bar code.
Related pull requests
- #6250 [closed]
related— (+6189/-333) — do not consolidate: although titled as Codex rate-limit status-bar work, the supplied broad diff mixes credential-pool, vision-provider, worktree-cleanup, plugin, and other unrelated changes, so it is not an isolated fix for the quota-visibility cause; its closed state remains relevant because this high-risk patch is not a focused implementation. - #11177 [closed]
related— (+539/-3) — superseded reference: this closed PR added a Codex-onlywham/usageclient and exposed quota windows through CLI and Gateway/usage, not a focused current status-bar implementation. Contributor review records it as superseded by merged #13428, whose documented relevance is the broader three-provider implementation; the supplied evidence does not establish lineage from #13428 to the currentagent.account_usagecode. - #19063
related— (+625/-1) — salvage only, not merge as-is: it adds quota commands, configurable pace bars, and a newagent/codex_quota.py, but its broad resolver exception can fall through to a different pooled account and it duplicates the established account-usage fetch path. Despite the keep_open review on #19063, the diff shows the specifically reviewed cross-account fallback hazard, so only its UI/formatting concepts should be retained unless it is rebuilt onagent.account_usage.fetch_account_usagewith transient-failure coverage. - #20493 [closed]
related— (+299/-20) — duplicate implementation: this closed PR adds cached 5h/weekly status-bar bars by spawningcodex app-server, creating a second quota acquisition path instead of reusing shared account usage. It remains relevant as the original version of the same-author re-submission #20953. - #20786 [closed]
duplicate— (+125/-0) — useful shared-path reference: this closed PR correctly builds a compact asynchronous label onagent.account_usage.fetch_account_usage, directly addressing status-bar visibility without a parallel client. It remains relevant because its implementation is the closest architectural precursor, but contributor discussion closed it as a duplicate of #19063 and its display is limited to one terse primary/session percentage. - #20953 [closed]
related— (+300/-20) — close/keep closed as duplicate: it is the rebased re-submission of #20493, with the samecodex app-serverJSON-RPC probe and status-bar formatting. Contributor discussion explicitly identifies it as a duplicate of #20493 and overlapping #19063 and #20786. - #33836
related— (+207/-0) — broader salvage, not the focused merge candidate: it generalizes an opt-in badge across Codex, Anthropic, and OpenRouter usingagent.account_usage, but the diff targets an old status-bar/config layout and lacks tests for single-flight refresh, retry, and fetch exceptions. Despite the keep_open review on #33836, those diff-level integration and cache-coverage gaps make it less merge-ready than #44506; its multi-provider scope can be pursued separately after rebasing. - #44506
related— (+581/-0) — preferred merge candidate after required approval: the current diff adds a wide-tier Codex session percentage/reset segment, performs no render-thread network I/O, usesagent.account_usage.fetch_account_usage, scopes cached results to an immutable runtime-client credential fingerprint, and tests provider switches, credential failover, single-flight refresh, width fallback, and formatting. This aligns with the keep_open review on #44506, and the subsequent update directly addresses that review's unsafe-fallback objection without introducing a separate quota resolver.
Duplicates
#20493 and #20953 are effectively the same codex app-server status-bar implementation; #19063, #20786, #33836, and #44506 overlap on asynchronously surfacing account quota in the status bar, but differ materially in fetch-path safety, provider scope, and UI detail.
Suggested consolidation
Merge #44506 after its pending CI/maintainer approval because its supplied current diff is the most focused implementation and explicitly protects provider and credential scope while reusing shared account usage. Keep #11177 and #20786 closed as superseded/reference work, keep #20493 and #20953 closed as duplicates, and do not revive #6250. Close #19063 as superseded by #44506 despite its keep_open review because its present diff retains the reviewed parallel-fetch and cross-account fallback defect; close or retarget #33836 despite its keep_open review because its broader multi-provider idea is separable, while its supplied diff is stale and does not test the cache/failure paths required by that review.
Complex graph
flowchart LR
classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d
classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937
classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151
classDef best stroke-width:3px,stroke:#b45309
classDef target stroke-width:3px,stroke:#4338ca
subgraph Dup19063 ["PRs duplicating each other"]
P19063["PR #19063 (open)"]
P20786["PR #20786 (closed)"]
end
class P19063 open
class P20786 closed
class P19063 target
click P19063 "https://github.com/NousResearch/hermes-agent/pull/19063"
click P20786 "https://github.com/NousResearch/hermes-agent/pull/20786"
Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed (state tag in the node label).
Cross-PR triage: Reviewed 8 pull requests and 0 issues in this complex. Each diff was read against this issue; Assessment working set: 140 kB of PR diffs, 13 kB of issue/PR text, 7 kB of discussion (9 comments), 0 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.
Summary
/codex-quotawith/quotaalias for primary and secondary quota windowsdisplay.codex_quotaConfiguration
The status-bar indicator defaults to the compact/minimal view:
Available values:
minimal— default. Shows compact quota pace bars plus used percentages.detailed— shows quota pace bars plus reset countdown/clock metadata, e.g.2%·4h39m→1:49pm.Switch with:
The slash command output remains detailed regardless of this setting:
Minimal preview
Detailed preview
Test Plan