Repository navigation
fix(server): a zero Codex credit cap no longer delays usage-limit recovery on seat-based plans - #35025
fix(server): a zero Codex credit cap no longer delays usage-limit recovery on seat-based plans#35025juliusmarminge wants to merge 2 commits into
Conversation
…ge-limit reset Fails on main: codexUsageLimitResetAt returns the monthly credit reset instead of the plan window's reset (repro for #34974). AI-assisted; verified with the tests and tools listed above.
…overy on seat-based plans The credit cap blocks only plans without plan windows, matching exhaustedUsageWindow. AI-assisted; verified with the tests and tools listed above.
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — Codex usage-limit recovery now follows plan-window resets instead of an unrelated exhausted credit cap when plan windows exist. This aligns recovery with the existing blocking rule without changing quotas, billing, or resume preferences. You can add or adjust custom eligibility rules. Learn more. |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
The automated pipeline stopped on this pull request and will not merge it: the fix is written and reviewed, but proving it needs something no worker has:
It stays open for a person to finish or close. |
|
Note 🤖 Claude Opus 5.5 responding on behalf of @someone6783 Real-app confirmation of the defect this PR fixes, on T3 Code desktop 0.1.3 (Linux), which does not include this change. Two ChatGPT workspace seats, each signed into Codex. I could not check the "after" state because this branch is not built here. Usage → Limits at the time (both seats):
Four threads stopped on a Codex usage limit, two per seat:
The weekly windows still had room, so the session reset is the correct resume time. The two ❌ threads would wait about 4.5 days for no reason. The fact that the same seat produces both outcomes fits the root cause described above. |
codexUsageLimitResetAt treated the
individualcredit-cap window at 100% as blocking even when plan windows (primary/secondary) were present, unlike exhaustedUsageWindow's seat-based rule in packages/shared/src/usageLimits.ts. CodexAdapterV2's failureResetAt therefore attached the monthly credit reset to usage_limit failures, and emitRootTerminal's awaitsReset check skipped the account read that would find the plan reset, so UsageLimitRecoveryWorker waited for the monthly renewal. The helper now drops theindividualwindow from the exhausted set whenever a plan window exists (the same rule exhaustedUsageWindow uses), so the plan window's reset drives recovery. Free and Go plans with only the credit cap behave as before. One-file change of a few lines. No new regex or parser.Fixes #34974
Reproduction on main
On origin/main b68aedf (fresh worktree, vp i) I ran the reporter's repro.sh unchanged, taken from the issue body. It is a Vite+ test that replays Codex app-server frames through the real CodexAdapterV2, provider-event ingestion, orchestrator, SQLite projections and the production limitRecoveryCommand. It passed with 'DEFECT PRESENT'. Plan room with the cap: helperReset, the stored failure resetAt and the shell usageLimitResetAt are all 2026-12-01 (monthly credit reset), no account/rateLimits/read is sent, and recovery returns nothing 1 ms after the plan reset (2026-11-11T05:00Z) and message.dispatch only after the credit reset. Primary at 100% with the cap: also stores 2026-12-01 and waits past the plan reset. The no-cap controls store the plan reset and dispatch right after it. The successful-turn and manual-continuation controls behave correctly. I then added a case to codexUsageLimits.test.ts (team plan, primary at 100%, individualLimit remainingPercent 0). It fails on main: Expected 2026-07-14T03:33:20.000Z (primary reset), Received 2026-12-01T00:00:00.000Z.
Evidence
Being captured: before and after in the real app. This section is filled in before the pull request can merge.
Tests
vp test run apps/server/src/provider/codexUsageLimits.test.ts: on the repro base, 1 failed / 15 passed (expected 2026-07-14T03:33:20.000Z, received 2026-12-01). With the fix, 16/16 passed. vp run check:changed: format, lint, knip, graphql, typecheck (3 packages) and test (2 files) all passed.
Not in this change
AI-assisted; verified with the tests and tools listed above.