Skip to content

feat(cli): show codex rate limits in status bar - #6250

Closed
schin-300 wants to merge 12 commits into
NousResearch:mainfrom
schin-300:feat/codex-rate-limits
Closed

feat(cli): show codex rate limits in status bar#6250
schin-300 wants to merge 12 commits into
NousResearch:mainfrom
schin-300:feat/codex-rate-limits

Conversation

@schin-300

Copy link
Copy Markdown

Summary

Adds Codex rate-limit monitoring to the status bar. When the active provider is openai-codex, the bar shows remaining request quota and time until the rate window resets.

Example: ⚕ codex │ 12.4K/200K │ 6% │ 🎫 42 reqs (reset 15m) │ 14m

Changes

run_agent.py

  • Added _codex_rate_limits, _codex_rate_limits_ts, _codex_rate_limits_interval to agent init
  • Added _refresh_codex_rate_limits() — makes a HEAD request (falls back to GET /models) to the Codex API, parses x-ratelimit-* response headers, caches for 60s
  • Hooked into agent loop after each API call (no-op when cache is fresh or provider isn't codex)

cli.py

  • _get_status_bar_snapshot() — includes codex_rate_limits, codex_remaining_pct, codex_resets_in_min
  • _build_status_bar_text() — shows N reqs (reset Xm) in medium and wide terminals
  • _get_status_bar_fragments() — styled version with 🎫 prefix

tests/cli/test_cli_status_bar.py

  • TestCodexRateLimits.test_snapshot_includes_codex_limits_when_present
  • TestCodexRateLimits.test_snapshot_has_no_codex_limits_when_absent
  • TestCodexRateLimits.test_status_bar_shows_codex_reqs_on_wide_terminal

Testing

  • pytest tests/cli/test_cli_status_bar.py -v
  • Manual: connect with Codex provider, verify status bar shows rate limits
  • Manual: verify no display on non-Codex providers

Design Notes

  • 60s cache interval keeps quota cost minimal (1 extra request per minute max)
  • HEAD request preferred (no body transfer), falls back to GET if 405
  • Gracefully degrades: empty dict when limits unavailable, no errors shown
  • Narrow terminals (<52 cols) skip the display entirely

Hermes Local and others added 12 commits April 8, 2026 11:21
When using the Codex provider, the status bar now shows remaining
request quota and time until reset. Rate-limit info is fetched via
a lightweight HTTP request to the Codex API, cached for 60 seconds
to avoid burning quota on status polling.

- Add _codex_rate_limits tracking to the agent (run_agent.py)
- Add _refresh_codex_rate_limits() method with 60s cache
- Hook into agent loop to refresh after each API call
- Surface rate-limit data in _get_status_bar_snapshot()
- Display rate limits in status bar text + fragments
- Add 3 tests for the new feature
@schin-300 schin-300 closed this Apr 8, 2026
@schin-300
schin-300 deleted the feat/codex-rate-limits branch April 8, 2026 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant