GeezerVison is showing github.com — fix(server): Codex native model-capacity reconnects are no longer interrupted at 10 minutes by zhanex · Pull Request #41346 · pingdotgg/t3code
Conversation
Problem
When Codex CLI 0.171.0 encounters a server-directed capacity overload (ServerOverloaded / PolicyCapacityUnavailable), it honors the server's Retry-After deadline (which can exceed 10 minutes) and emits an error notification with willRetry: true, codexErrorInfo: { responseStreamDisconnected: { httpStatusCode } }, and the overload display text in additionalDetails (e.g. "Selected model is at capacity. Please try a different model.").
CodexAdapterV2 previously armed the 10-minute failStalledProviderRetry watchdog (PROVIDER_RETRY_BUDGET_MS) on every willRetry: true notification, terminating the turn and sending turn/interrupt at 10 minutes before Codex's native capacity retry could finish.
Change
apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts:
- Added
codexNativeCapacityRetry(code, additionalDetails) to recognize structured capacity codes (serverOverloaded, policyCapacityUnavailable) and the exact upstream ServerOverloaded / PolicyCapacityUnavailable display strings when wrapped in responseStreamDisconnected by Codex's notify_stream_error. Narrowing to responseStreamDisconnected keeps non-capacity errors (such as usageLimitExceeded or HTTP 429 retries) on the existing 10-minute watchdog.
- Added
watchdogStartedAt on ActiveCodexProviderRetry separate from startedAt:
- Native capacity reconnects omit
watchdogStartedAt and do not arm failStalledProviderRetry.
- Transitioning from a non-capacity retry to a capacity reconnect replaces the
providerRetries state object, so the prior watchdog exits as a no-op via the existing identity check in finalizeCodexTurn.
- Transitioning from a capacity reconnect back to a non-capacity retry starts a fresh 10-minute watchdog window from that notice rather than inheriting the earlier capacity
startedAt.
apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts:
Scope
Bug fix only. Fixes #41249.
Verification
- Reproduced on
main (red first): Added the [Bug]: T3 interrupts Codex during a native model-capacity reconnect #41249 protocol replay test against unmodified CodexAdapterV2.ts and ran:
vp test run apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts -t "keeps a native Codex capacity reconnect running past the retry watchdog budget"
Observed failure at TestClock.adjust("10 minutes"):
AssertionError: expected [ { type: 'turn.terminal', ..., status: 'failed' } ] to be empty (the 10-minute watchdog terminated the turn before the 11-minute turn/completed event).
- Verified after fix (green): Re-ran the targeted retry/capacity replay tests and
vp run check:changed:
keeps a native Codex capacity reconnect running past the retry watchdog budget: no terminal event and interruptCount === 0 at 10 minutes; status === "completed" with interruptCount === 0 at 11 minutes.
resets the retry watchdog window around a native Codex capacity reconnect: no interrupt at 10 minutes or 21 minutes; fails as usage_limit with interruptCount === 1 at 22 minutes (10 minutes after the 12-minute 429 notice).
vp run check:changed: format pass, lint pass (0 warnings, 0 errors), knip 1/2 & 2/2 pass, graphql (apps/server) pass, typecheck (3 packages) pass, test pass (CodexAdapterV2.test.ts 219/219, AgentContextBudget.test.ts 2/2).
- Not checked: Did not reproduce against a live >10-minute OpenAI server overload in production; verified via deterministic Codex app-server protocol replay matching Codex CLI 0.171.0 (
notify_stream_error and CodexErr::ServerOverloaded / PolicyCapacityUnavailable).
Implemented with Gemini 4 Neon in T3 Code (Antigravity) and independently reviewed with Codex (GPT-6.2 Astra).
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Nov 23, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Walkthrough
-
CodexAdapterV2 now excludes recognized native capacity retries from its retry watchdog. Other retry notices use a deadline based on the first watchdog-eligible notice. Stalled-retry finalization verifies the expected retry before changing retry state. Replay tests cover delayed capacity completion and a later non-capacity retry.
Changes: Codex retry watchdog
| Layer / File(s) |
Summary |
Classify retries and manage watchdog deadlines apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts, apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts |
Capacity retry codes and exact capacity details bypass the watchdog. Other retries preserve the first watchdog-eligible timestamp, so repeated notices do not extend the deadline. Replay tests cover successful completion after 11 minutes and a later non-capacity retry that fails after its own ten-minute window. |
Verify stalled retry before finalization apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts |
Finalization stops when the turn is already interrupting or the stored retry no longer matches the stalled retry. It removes the expected retry before recording its failure. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related PRs
- pingdotgg/t3code#33076: Adds the Codex retry watchdog that this change exempts for capacity reconnects.
- pingdotgg/t3code#29208: Adds the shared retry budget and interruption behavior that this change adjusts for Codex capacity retries.
- pingdotgg/t3code#33130: Starts a watchdog for each Codex retry notice; this change adjusts that behavior for capacity reconnects.
Suggested reviewers: jieyuexing, juliusmarminge, macroscopeapp
Merge Risk: Minimal · up to 23ac3
-
Native Codex capacity reconnects are no longer interrupted at 10 minutes, and other retry types such as usage-limit and 429 retries keep their watchdog. The change is localized to the Codex adapter retry handling and has replay tests for both behaviors. No actionable merge-blocking risk remains. Real-world validation against a long server overload was not performed.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title names the main change: Codex native model-capacity reconnects are no longer interrupted by the 10-minute retry watchdog. The raw summary, the description, and the objectives all describe thi… |
| Description check |
 |
The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section explains the 10-minute watchdog interrupting native Codex capacity retries. The Chan… |
| Linked Issues check |
 |
Linked issue #41249 requires that T3 not interrupt a native Codex capacity retry at 10 minutes and accept a later successful completion. The current head adds codexNativeCapacityRetry in CodexAdapterV… |
| Out of Scope Changes check |
 |
All changes relate to #41249 and the retry watchdog path in CodexAdapterV2.ts. The changes are: (1) the codexNativeCapacityRetry classifier, which gates the watchdog; (2) watchdogStartedAt, which sepa… |
Full details: Title check
-
Explanation
The title names the main change: Codex native model-capacity reconnects are no longer interrupted by the 10-minute retry watchdog. The raw summary, the description, and the objectives all describe this same change. The title is in the conventional commit format from the template. It is 91 characters, which is long but still within a single readable sentence.
Full details: Description check
-
Explanation
The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section explains the 10-minute watchdog interrupting native Codex capacity retries. The Change section lists the adapter and test file changes. The Scope section links issue #41249 and states that this is a bug fix. The Verification section gives the red-then-green test results, the check:changed results, and a note on what was not checked. The description does not include the optional model/harness line in the required form beyond a trailing attribution line, which is present. All required sections are filled in.
Full details: Linked Issues check
-
Explanation
Linked issue #41249 requires that T3 not interrupt a native Codex capacity retry at 10 minutes and accept a later successful completion. The current head adds codexNativeCapacityRetry in CodexAdapterV2.ts. It recognizes serverOverloaded and policyCapacityUnavailable codes, and the exact capacity display strings, when wrapped in responseStreamDisconnected. Such reconnects omit watchdogStartedAt and do not arm failStalledProviderRetry. The test 'keeps a native Codex capacity reconnect running past the retry watchdog budget' replays the issue scenario: no interrupt at 10 minutes, and completed with interruptCount 0 at 11 minutes. The test 'resets the retry watchdog window around a native Codex capacity reconnect' checks that a later non-capacity 429 retry gets a fresh 10-minute window and is interrupted at 22 minutes. Limits: the text diff of CodexAdapterV2.ts was unavailable, and the head file read was truncated before the retry logic. The conclusion rests on the PR description, the AI summary of the code, and the test names. Test results are author-reported and were not re-run. The issue's own steps use protocol replay, so the replay tests match the issue's reproduction method. The commenter's note about missing live-app evidence does not change the issue's stated reproduction steps.
Full details: Out of Scope Changes check
-
Explanation
All changes relate to #41249 and the retry watchdog path in CodexAdapterV2.ts. The changes are: (1) the codexNativeCapacityRetry classifier, which gates the watchdog; (2) watchdogStartedAt, which separates the watchdog window from startedAt; (3) state replacement on transitions between capacity and non-capacity retries, which makes a stale watchdog exit as a no-op; (4) the finalization change that checks interruption before changing retry state and then atomically verifies and removes the expected retry, which supports the stale-watchdog no-op; and (5) two protocol replay tests. Each change supports the stalled-retry behavior the issue covers. The AI summary says repeated non-capacity notices keep the first watchdog deadline. The PR description says a capacity-to-non-capacity transition starts a fresh window. These rules do not conflict, and test 2 covers the second rule. The head file read was truncated, so the finalization change is confirmed only by the AI summary and not by a direct code read. No unrelated files or features appear in the summary.
Finishing Touches
-
Generate unit tests (beta)
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info
-
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between 853a4fd and 23ac32a.
Files selected for processing: 1
-
apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.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.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
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: The reported reproduction requires first-party ChatGPT access through Codex CLI 0.171.0 and an upstream server-directed capacity overload exceeding ten minutes. First-party ChatGPT OAuth is explicitly unavailable on these workers; generic Replay cannot reproduce this Codex-specific protocol path.
- Capacity retry survival and eventual completion on head, and preservation of the ordinary retry watchdog, were not demonstrated in the real app. Existing protocol tests were not counted as evidence.
It stays open for a person to finish or close.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This branch has not been deployed
No deployments
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.
|