Repository navigation
Conversation
The adapter keeps the Codex rate limits of each session, but clients only see them as /status text. Push them as numbers instead: when the app-server reports changed rate limits, send `_quota/update` with the session id and a full snapshot of pools and meters, shaped and mapped as the quotas & limits RFD (agentclientprotocol/agent-client-protocol#2316) describes for Codex. The initialize response advertises `_meta.quota`. An unchanged snapshot is not sent again, and `updatedAt` never decreases. When the RFD lands, the same snapshot becomes the `quota_update` session update.
This branch has not been deployed
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
The adapter already keeps the Codex rate limits of each session (
account/rateLimits/updated), but a client can only see them as/statustext. This pushes them as numbers.When the app-server reports changed rate limits, the adapter sends
_quota/updatewith the session'ssessionIdand a full snapshot of pools and meters. The shape and the mapping are the ones the quotas & limits RFD describes for Codex: agentclientprotocol/agent-client-protocol#2316{ "sessionId": "sess_abc123", "updatedAt": "2026-10-06T13:10:00.000Z", "pools": [ {"id": "codex", "meters": [ {"id": "primary", "usedPercent": 42, "window": "PT5H", "resetsAt": "2026-10-06T18:00:00.000Z"}, {"id": "secondary", "usedPercent": 17, "window": "P7D", "resetsAt": "2026-10-11T09:00:00.000Z"} ]}, {"id": "credits", "label": "Credits", "state": "available", "meters": [ {"id": "balance", "remaining": {"value": "118.5", "unit": "credits"}} ]} ] }limitId), with theprimaryandsecondarywindows as meters; acreditspool for the balance and the per-user spend cap._meta.quota: {}(v1 and v2). The client sends nothing and only listens.updatedAtnever decreases within the process.When the RFD lands, the same snapshot becomes the
quota_updatesession update and only the message name changes.The wire contract is in
docs/quota.md.Why this shape
Issue #227 asks for the rate limits over ACP instead of
/statustext, and #334, #426 and #524 propose three different interim shapes (onusage_update, as session metadata, as a vendor notification). The RFD warns against putting quota onusage_update, whoseusedis context occupancy. This PR uses the RFD's own snapshot shape, so a client can parse it once for Codex now and for every agent later.We use it in an orchestrator that picks the agent and the model for each run by the remaining weekly limits of Claude Code and Codex. Claude's adapter already sends its numbers (
_claude/rateLimitonusage_update); for Codex we readaccount/rateLimits/readourselves today.Tests
QuotaSnapshot.test.ts: the mapping (file snapshot), only reported values, durations, monotonicupdatedAt.CodexAcpClient.test.ts: a changed update is pushed as_quota/update, an identical one is not.quota: {}; the scenario baseline comparison lists it as a feature change.npm run typecheckandnpm test: 2806 passed.