feat: forward account rate limits to clients as session metadata - #426
Open
ortwinvanderstappen wants to merge 1 commit into
Open
Conversation
ortwinvanderstappen
force-pushed
the
feat/forward-account-rate-limits
branch
from
August 22, 2026 16:07
5ce4743 to
172549e
Compare
`account/rateLimits/updated` was already handled -- the snapshot is stored in `sessionState.rateLimits` and rendered by `/status` -- but the handler returned null, so nothing reached the client and the numbers were only visible if the user typed a command. Forward them as session metadata too, via the existing createCodexSessionInfoUpdate helper, so clients see the snapshot under `_meta.codex.rateLimits`. This makes usage indicators free to build. A client that wants to show how much of the plan is left otherwise has to spawn its own `codex app-server` and poll `account/rateLimits/read`: a second Codex process and a duplicate request per refresh, for data the adapter already receives, parses and keeps. /status keeps working, since the state is still recorded.
ortwinvanderstappen
force-pushed
the
feat/forward-account-rate-limits
branch
from
August 22, 2026 16:07
172549e to
ee85ba9
Compare
ortwinvanderstappen
marked this pull request as ready for review
August 22, 2026 16:16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
account/rateLimits/updatedis already handled: the snapshot is stored insessionState.rateLimitsand rendered by/statusviaformatRateLimitLines.But the handler returns
null, so nothing reaches the client — the numbers areonly visible if the user types a command.
This forwards them as session metadata too, using the existing
createCodexSessionInfoUpdatehelper.Why
It makes usage indicators free to build. A client that wants to show how much of
the plan is left has no way to learn it from the stream today, so it has to spawn
its own
codex app-serverand pollaccount/rateLimits/read— a second Codexprocess and a duplicate request per refresh, for data the adapter already
receives, parses and keeps.
Forwarding it removes both: no extra process, no extra requests, no polling
machinery, and the figures update exactly when Codex says they changed.
Nothing is removed.
/statuskeeps working, since the state is still recorded.Change
One case in
src/CodexEventHandler.ts:case "account/rateLimits/updated": this.handleRateLimitsUpdated(notification.params); - return null; + return this.createCodexSessionInfoUpdate({ + rateLimits: notification.params.rateLimits, + });Clients see the snapshot under
_meta.codex.rateLimits, the same_meta.codexconvention as the other codex-specific session metadata.
Tests
src/__tests__/CodexACPAgent/rate-limit-events.test.ts— one snapshot of whatthe client receives, so the wire format is visible in review.
npm run typecheck— cleannpx vitest run— 440 passed, 28 skipped, nothing else affected