Repository navigation
Expose Codex subscription usage limits over the fold-codex transport - #46
Open
PepijnSenders wants to merge 2 commits into
Open
PepijnSenders wants to merge 2 commits into
PepijnSenders wants to merge 2 commits into
Conversation
Add a provider-neutral usage-limits snapshot to fold-core and populate it from the Codex rate-limit response headers the ChatGPT backend attaches to every /responses reply. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> HumanLayer-Session: https://app.humanlayer.com/sessions/01a0bf0d-c4bd-787c-b350-a30c562a74d6
Match the comment density of the sibling Usage.ts: the window and snapshot blocks read as one line each, since the names already carry the intent. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> HumanLayer-Session: https://app.humanlayer.com/sessions/01a0bf0d-c4bd-787c-b350-a30c562a74d6
K-Mistele
approved these changes
Sep 26, 2026
PepijnSenders
marked this pull request as ready for review
September 27, 2026 14:28
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.
Downstream consumer: humanlayer/synclayer#2663
Why the change
HumanLayer needs to show Codex subscription usage-limit alerts the way it now does for Claude, but Fold exposed no usage-limit data, so this reads what the ChatGPT backend already returns and surfaces it in a provider-neutral shape.
Special things to note
x-codex-<primary|secondary>-used-percent/-window-minutes/-reset-at, plusx-codex-credits-*) on every reply, verified against a real 429 on this machine, so no new client, endpoint, or websocket was neededonUsageLimitscallback, not a durable EventLog entry: the model descriptor produces aLanguageModel.Servicewith no EventLog access and the existingonStreamRetryseam is the only precedent; a durable entry would need cross-cutting runtime plumbing and is left as a follow-upcodexlimit family only (not per-modelrateLimitsByLimitId) and fires on successful acquisition only; the 429 path keeps its existing retry-after handlingChange outline
A provider-neutral, best-effort snapshot type in fold-core, modeled on the existing
Usage.The codex client already returns the response at acquisition, so headers are read at that seam and handed to the callback.
Files by responsibility.
Tested:
RateLimitHeaders.vi.test.ts(6 cases: primary+secondary parse, seconds-to-ms, partial windows, credits + limit name, no-headers None, unparsable/out-of-range dropped) andUsageLimits.vi.test.ts(4 cases: sparse windows, empty windows, percent bound, non-positive duration). Typecheck, oxlint, and oxfmt clean; the two failingCodexLivetests are pre-existing live-network cases that 429 because this account's limit is reached.