Skip to content

feat: add Codex quota usage indicator - #19063

Open
safzanpirani wants to merge 1 commit into
NousResearch:mainfrom
safzanpirani:feat/codex-quota-indicator
Open

feat: add Codex quota usage indicator#19063
safzanpirani wants to merge 1 commit into
NousResearch:mainfrom
safzanpirani:feat/codex-quota-indicator

Conversation

@safzanpirani

@safzanpirani safzanpirani commented May 3, 2026

Copy link
Copy Markdown

Summary

  • add a shared Codex quota usage fetcher for ChatGPT's wham usage endpoint
  • add /codex-quota with /quota alias for primary and secondary quota windows
  • show Codex quota pace bars in the CLI status bar for openai-codex sessions
  • add configurable status-bar detail levels via display.codex_quota

Configuration

The status-bar indicator defaults to the compact/minimal view:

display:
  codex_quota: minimal

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:

hermes config set display.codex_quota detailed
hermes config set display.codex_quota minimal

The slash command output remains detailed regardless of this setting:

/codex-quota
/quota

Minimal preview

Minimal Codex quota indicator preview

Detailed preview

Detailed Codex quota indicator preview

Test Plan

  • venv/bin/python -m pytest tests/test_codex_quota.py tests/hermes_cli/test_commands.py tests/cli/test_cli_status_bar.py tests/hermes_cli/test_config.py -q -o 'addopts='

@alt-glitch alt-glitch added type/feature New feature or request comp/cli CLI entry point, hermes_cli/, setup wizard provider/openai OpenAI / Codex Responses API P3 Low — cosmetic, nice to have labels May 3, 2026
@safzanpirani
safzanpirani force-pushed the feat/codex-quota-indicator branch 2 times, most recently from 5e86a54 to c2e8800 Compare May 3, 2026 03:41

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:261 broadly catches resolver failures and then selects a pooled credential. A transient refresh failure can therefore show limits for another account. Main explicitly prevents that in agent/account_usage.py:459-464; the guard test is tests/agent/test_account_usage.py:121-152 (130e2337c24810bc0afa793495795b832cf593be).
  • Current CLI /usage already passes live provider/base-URL/API-key context into the shared fetcher at cli.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_usage and 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.

Comment thread agent/codex_quota.py


def _codex_usage_headers(api_key: str, account_id: Optional[str]) -> dict[str, str]:
headers = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 12, 2026
@teknium1 teknium1 added the area/usage-cost Token accounting, usage reporting, billing, cost tracking label Jul 19, 2026

@GottZ GottZ left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-only wham/usage client 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 current agent.account_usage code.
  • #19063 related — (+625/-1) — salvage only, not merge as-is: it adds quota commands, configurable pace bars, and a new agent/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 on agent.account_usage.fetch_account_usage with transient-failure coverage.
  • #20493 [closed] related — (+299/-20) — duplicate implementation: this closed PR adds cached 5h/weekly status-bar bars by spawning codex 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 on agent.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 same codex app-server JSON-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 using agent.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, uses agent.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"
Loading

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/usage-cost Token accounting, usage reporting, billing, cost tracking comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have provider/openai OpenAI / Codex Responses API sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants