Skip to content

feat: add /codex-usage command - #33998

Open
Padanerd wants to merge 1 commit into
NousResearch:mainfrom
Padanerd:feat/codex-usage
Open

feat: add /codex-usage command#33998
Padanerd wants to merge 1 commit into
NousResearch:mainfrom
Padanerd:feat/codex-usage

Conversation

@Padanerd

Copy link
Copy Markdown

Summary

  • Add /codex-usage to show OpenAI Codex / ChatGPT subscription usage
  • Expose remaining percentage and reset timing in CLI and gateway
  • Update docs and add targeted tests

Verification

  • python -m pytest tests/agent/test_gemini_cloudcode.py tests/cli/test_codex_usage_command.py tests/gateway/test_usage_command.py -q
  • 99 passed

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery provider/openai OpenAI / Codex Responses API labels May 28, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #33094 (feature request this addresses). Competing with open PRs #19063 (Codex quota indicator) and #24040 (pooled Codex usage). Also see #15167 (credential pool gap in /usage).

@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 focused Codex quota command.

Problems

  • Current main already renders the underlying Codex subscription windows through /usage: cli.py:9691-9710 and gateway/slash_commands.py:3965-3996 call the shared agent/account_usage.py path. The dedicated /codex-usage surface is still distinct, but its gateway handler must be salvaged into GatewaySlashCommandsMixin (gateway/slash_commands.py:87); the handler location targeted by this PR was extracted from gateway/run.py.
  • The added tests invoke handlers directly, so they do not verify either newly added dispatch branch.

Suggested changes

  • Re-home the gateway handler in gateway/slash_commands.py and add CLI/gateway dispatch coverage for /codex-usage.
  • Preserve the shared account-usage helper, which current main hardens for Codex credential-pool resolution in agent/account_usage.py:439-542.

Automated hermes-sweeper review.

Comment thread gateway/run.py Outdated
@@ -13910,6 +13913,23 @@ async def _handle_usage_command(self, event: MessageEvent) -> str:
return "\n".join(account_lines)

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.

Current main extracted in-session handlers into GatewaySlashCommandsMixin (gateway/slash_commands.py:87), where /usage now lives at line 3943. Please salvage this handler into that mixin rather than restoring a new handler in gateway/run.py.

)
monkeypatch.setattr("agent.account_usage.fetch_account_usage", lambda provider, base_url=None, api_key=None: snapshot)

cli._handle_codex_usage_command("/codex-usage")

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.

This calls the private handler directly. Add a dispatch-level assertion through process_command("/codex-usage") so the registry and CLI routing added by this PR are covered together.

@teknium1 teknium1 added the sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users label Jul 13, 2026
Expose OpenAI Codex / ChatGPT subscription usage in CLI and gateway, including remaining percentage and reset time.

Add docs and targeted tests for registry, CLI, and gateway rendering.
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 comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have provider/openai OpenAI / Codex Responses API sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants