fix(server): OpenCode ChatGPT usage limits keep their reset time #26264
main fromrefs/pull/26264/head·opened View on GitHubProblem#
When OpenCode runs an OpenAI model through a ChatGPT subscription and the Codex usage window is exhausted, the turn now fails as usage_limit (since https://git.cafe/pingdotgg/t3code/pulls/18315) but without resetAt. The thread shows "Reset time unavailable; retry manually", the resume-at-reset and snooze actions are hidden, and auto-resume never arms.
ChatGPT already says when the limit lifts. Its 429 body is:
{"error":{"type":"usage_limit_reached","message":"The usage limit has been reached","plan_type":"plus","resets_at":1788753614,"resets_in_seconds":57361}}
OpenCode 2 forwards that body on session.execution.failed as error.response.body, but the adapter ignored it.
Change#
When the OpenCode 2 adapter classifies a failure as a usage limit, it decodes error.resets_at (Unix seconds) from response.body and passes it as resetAt to makeProviderFailure, which already validates it and keeps it only for usage_limit. Claude limits keep the message-based reset from https://git.cafe/pingdotgg/t3code/pulls/29301, which takes precedence. Other bodies without that field (OpenCode Go, Zen, other providers) still produce no reset time, as before. No contract, client, or orchestration changes; the existing reset UI and auto-resume worker pick it up.
Scope and approval#
Fixes https://git.cafe/pingdotgg/t3code/issues/26265.
Follow-up to https://git.cafe/pingdotgg/t3code/issues/16366, which was closed by https://git.cafe/pingdotgg/t3code/pulls/18315 with the note that "OpenCode doesn't send a reset time in these events, so none is shown yet". For ChatGPT-backed models it does send one, in the response body. This is a small, focused fix in one adapter branch: it fills a field the failure contract already has, for the one provider shape that reports it. Separate from the Codex-provider fix in https://git.cafe/pingdotgg/t3code/pulls/18721 / https://git.cafe/pingdotgg/t3code/issues/14169.
Verification#
- Added a ChatGPT 429 row to the existing
classifies $name as $failureClasstable inOpenCode2AdapterV2.test.ts, expectingresetAt: "2026-10-27T15:25:41.000Z". With the adapter change stashed it fails on exactly that row (missingresetAt); the other rows pass. With the change, the file passes (89/89 after merging currentmain). vp run check:changed: format, lint, knip, typecheck (36 packages), and the changed test file all pass.- Payload shape: taken from a real ChatGPT Plus usage-limit 429 recorded in my local OpenCode store (
responseBodyon an OpenCode 1.x message). I confirmed that OpenCode 2.1.3's execution-failure mapper includesresponse: { body }when the HTTP error has a body, and the@opencode/schema2.0.28Session.StructuredErrorused here declaresresponse.body. - Not checked: a live end-to-end ChatGPT quota refusal through T3. My quota had already reset when I wrote this, and I couldn't get OpenCode 2 to route to a local mock 429 endpoint. Server-only change, so there are no screenshots.
Implementation, tests, and PR: Claude Opus 5.5 via Claude Code in T3 Code.
🤖 Generated with Claude Code
Fixes pingdotgg/t3code#26265
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Approvability#
Verdict: Approved at
b5e2a29Macroscope's review found this PR approvable — Preserves provider-reported usage-limit reset times for existing display and recovery flows. Invalid timestamps are ignored, and automatic recovery remains controlled by existing preferences, disabled by default.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).Note
Reviews paused#
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.- Last reviewed commit: 7500e4b6c15798b8bb139f6fe501e7057547c469
- Latest commit, not reviewed: 1df0d957db231c9b30d38010c07b2e8c4e0b46f4
Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.
Use the checkboxes below for quick actions:
- Resume reviews
- Trigger review
No actionable comments were generated in the recent review.
Walkthrough
-
The OpenCode 2 adapter parses a reset timestamp from a usage-limit response body and uses it when no Claude-specific reset time is available. A test covers a ChatGPT quota error and checks the expected reset time.
Changes: OpenCode 2 reset-time handling
Layer / File(s) Summary Parse and attach reset time
packages/provider-opencode/src/server/v2/adapter.ts,apps/server/src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.tsThe adapter converts a finite Unix-seconds resets_atvalue to an ISO timestamp. It returnsnullif decoding or date conversion fails, and uses the parsed timestamp when a Claude-specific reset time is unavailable. The test checks the ChatGPT quota-error case and conditionally expectsresetAt.Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers:
juliusmarminge,fixfon
Merge Risk:
Minimal · previous review7500e-
OpenCode ChatGPT usage-limit failures now keep their reset time, so the reset UI and auto-resume can use it. Other failures behave as before. No merge-blocking risk was found.
Pre-merge checks:
4-
Check name Status Explanation Title check The title names the main change: OpenCode ChatGPT usage-limit failures now keep their reset time, which matches the adapter change that reads error.resets_at from the response body and passes it as re… Description check The description follows the template's sections (Problem, Change, Scope, Verification) and fills each one with specific content. It explains the failure, the 429 payload shape, the adapter fix, and th… Linked Issues check Issue #26265requires OpenCode 2 ChatGPT usage-limit failures to carry the reset time from the 429 body. The whole-PR diff (merge base to reviewed head 7500e4b6) in `packages/provider-opencode/src/ser…Out of Scope Changes check The whole-PR diff changes two files: packages/provider-opencode/src/server/v2/adapter.ts(theusageLimitResetAthelper and theresetAtfallback in the usage-limit branch) and `apps/server/src/or…Full details: Title check
-
Explanation
The title names the main change: OpenCode ChatGPT usage-limit failures now keep their reset time, which matches the adapter change that reads error.resets_at from the response body and passes it as resetAt. It follows conventional commit format and is specific.
Full details: Description check
-
Explanation
The description follows the template's sections (Problem, Change, Scope, Verification) and fills each one with specific content. It explains the failure, the 429 payload shape, the adapter fix, and the precedence with the Claude reset path. It links the issue and the prior work. It gives focused test results and states what was not checked. The template's agent attribution line is present, and the description notes that the change is server-only, so no screenshots are needed. The description is mostly complete and clear.
Full details: Linked Issues check
-
Explanation
Issue
#26265requires OpenCode 2 ChatGPT usage-limit failures to carry the reset time from the 429 body. The whole-PR diff (merge base to reviewed head 7500e4b6) inpackages/provider-opencode/src/server/v2/adapter.tsaddsdecodeUsageLimitBody, which decodeserror.resets_at(Finite, Unix seconds) fromresponse.bodywithSchema.decodeUnknownOption.usageLimitResetAtconverts it to ISO withDateTime.makeandDateTime.formatIso, and returns null when the body or field is absent or invalid. The usage-limit failure now setsresetAt: claudeLimit?.resetAt ?? usageLimitResetAt(response?.body), so the Claude message-based reset keeps precedence. The previous review also confirmed a ChatGPTprovider.quota429 row inOpenCode2AdapterV2.test.tsexpectingresetAt: "2026-10-27T15:25:41.000Z", which matches1793114741Unix seconds. The head changed through a merge of main. The current adapter diff matches the earlier reviewed logic. The test diff was not re-read at this head. The UI and auto-resume paths were not re-verified in this review; the PR states they are unchanged and read the field.
Full details: Out of Scope Changes check
-
Explanation
The whole-PR diff changes two files:
packages/provider-opencode/src/server/v2/adapter.ts(theusageLimitResetAthelper and theresetAtfallback in the usage-limit branch) andapps/server/src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.ts(one ChatGPT row, and a runner that passesresetAtonly when a row defines it). All changes serve issue#26265. No contract, client, orchestration, or unrelated provider changes appear in the reviewed evidence. The adapter diff at this head shows no import change, so theOptionandDateTimereferences rely on imports already present at the merge base.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: 0d51d5b
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
1fd8c57e-33df-47b6-b6ec-6d18737f555f
Commits-
Reviewing files that changed from the base of the PR and between 513453f4491a4a91b6a12fbaf27eee3ef4143d99 and 7500e4b6c15798b8bb139f6fe501e7057547c469.
Files selected for processing: 2-
apps/server/src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.tspackages/provider-opencode/src/server/v2/adapter.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
juliusmarminge added labelsbugfix
juliusmarminge added labelspr:gate-failed
Note
Claude Code (Claude Opus 5.5) is posting this comment for the PR author.
I merged current
maininto the branch (29c81724). The diff againstmainis still the same two files, +31/−2.The earlier Agent context budget failure (
claudeSystemAppendBytes: 5135 -> 5258) came from the PR being 254 commits behind.mainhad shrunkagentContextBudget.jsonsince this branch was created, and this PR doesn't touch agent context. On the new head, Agent Context Budget, CI, Mobile Fingerprint, PR Vouch and PR Size all pass, and the branch merges cleanly.The
pr:gate-failedlabel seems to be left over from that run. Could a maintainer clear it? The bug report is #26265.tanstack-source added labelsbug
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:
- Permanent blocker: verification requires OpenCode 2.x connected through first-party OpenAI OAuth to a ChatGPT subscription with an exhausted usage window; first-party ChatGPT OAuth usage, limit, and renewal flows are unavailable on every VM. This prevents observing reset-time retention, Resume at reset, Snooze until reset, and automatic recovery on both commits. Replay cannot substitute because the scenario runner excludes provider-specific behavior and usage-limit stops.
It stays open for a person to finish or close.
This PR conflicts with
main. Rebase it or mergemaininto it. If it still conflicts after 7 days with no activity, it will be closed automatically.See the conflict window.
github-actions[bot](GitHub profile, opens in a new tab) added labelsneeds-rebase
Note
Claude Code is posting this comment for the PR author.
Merged current
mainagain and resolved the conflict with the newisUsageLimithelper (1df0d957). The diff againstmainis still the same two files. Claude's message-based reset still takes precedence, then ChatGPT'sresets_atfrom the 429 body. The adapter tests andcheck:changedpass locally.@juliusmarminge, I saw that the pipeline stopped because it can't verify a ChatGPT usage-limit stop. Is there anything you need from me to move this forward, or should I leave it with you?
Real ChatGPT usage-limit verification is now in progress using the same account on the baseline and fixed builds. Both hit the actual limit:
Baseline: shows “Reset time unavailable; retry manually,” with no auto-resume control.
Fixed: shows “Resumes 11:14 PM,” with auto-resume armed.
Screenshots and provider/event logs are saved. We’re waiting for the provider-reported reset at 15:14:35 UTC on November 15 to verify that the fixed build resumes and completes without a manual retry. I’ll update this comment with the recovery result and evidence afterward.
Automatic recovery is not yet verified.
Update: real ChatGPT automatic recovery verified#
The provider-reported reset was 15:14:35 UTC (11:14:35 PM Asia/Kuala_Lumpur). Both builds used the same ChatGPT OAuth account.
- Fixed: the server automatically created a continuation at 15:14:35.656 UTC, and it completed successfully at 15:14:48.823 UTC, returning
USAGE_PROOF_OK. The UI shows Sent by T3 Code above the continuation message. No manual retry was sent: orchestration logs identify the command aslimit-resumeand link it to the usage-limited run throughusageLimitContinuationOfRunId.
- Baseline: after the same reset, it still shows Reset time unavailable; retry manually, with no automatic continuation.
Provider/event logs are saved locally. This verifies real reset-time retention and successful automatic recovery on the fixed build.
Short recovery log (sanitized)
Selected fields from the recorded provider and orchestration events. All timestamps are UTC on November 15, 2026. Identifiers use consistent placeholders; unrelated fields are omitted. The full logs are retained locally.
{"capturedAt":"2026-11-15T13:26:49.789381+00:00","type":"session.execution.failed","errorType":"provider.quota","quota":{"type":"usage_limit_reached","resets_at":1794755675}} {"occurredAt":"2026-11-15T13:26:49.803Z","type":"turn-item.updated","payload":{"runId":"<limited-run>","failure":{"class":"usage_limit","message":"The usage limit has been reached","code":"provider.quota","retryable":null,"resetAt":"2026-11-15T15:14:35.000Z"}}} {"occurredAt":"2026-11-15T13:26:53.650Z","type":"thread.metadata-updated","actor":"server","payload":{"limitRecovery":{"runId":"<limited-run>","resetAt":"2026-11-15T15:14:35.000Z","autoResume":true,"snooze":true}}} {"occurredAt":"2026-11-15T15:14:35.656Z","type":"run.created","commandId":"limit-resume:<redacted>","actor":"server","payload":{"id":"<resumed-run>","status":"starting","usageLimitContinuationOfRunId":"<limited-run>"}} {"occurredAt":"2026-11-15T15:14:48.823Z","type":"run.updated","actor":"server","payload":{"id":"<resumed-run>","status":"completed","completedAt":"2026-11-15T15:14:48.823Z","usageLimitContinuationOfRunId":"<limited-run>"}}- Fixed: the server automatically created a continuation at 15:14:35.656 UTC, and it completed successfully at 15:14:48.823 UTC, returning
github-actions[bot](GitHub profile, opens in a new tab) removed labelsneeds-rebase
Sign in to join this conversation.
Codex Review Summary#
This comment shows the latest Codex review activity on this pull request.
We couldn’t complete this review. Comment
@codex reviewto try again.b5e2a29ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.