You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Codex can exit with Selected model is at capacity. Please try a different model. after starting a session. Headless previously returned that failure immediately, causing callers to exhaust task-level retries during the same capacity outage.
Automatically retry this exact native terminal failure up to three times, waiting 30/60/120 seconds with ±20% jitter. Preserve model, billing route, native session, and the original timeout; do not replay partial work without a session. HEADLESS_CAPACITY_RETRIES=0 disables retries, and values 1–3 set the limit.
Implementation
Keep capacity retries independent of the existing single billing fallback, with at most five executions and per-attempt usage provenance.
Emit structured retry events and stderr diagnostics; retain session storage across local, Docker, and Modal attempts.
Stop on timeouts, cancellation during backoff, and native/parent termination signals, including embedded callers whose child handles SIGTERM, with or without an explicit timeout.
50 focused core tests; affected core modules have 100% line and 97.24% branch coverage.
39 backend tests and 7 existing signal/lifecycle tests passed. Fake agents cover resume, exhaustion, billing fallback, cancellation, Docker persistence, and Modal sandbox reuse; no live model calls.
Independent review plus local security, reliability, and contract checks; git diff --check passed.
The initial full-suite run under this host's umask 0002 failed nine existing Docker-session permission tests; rerunning with 0022 passed. No package release or Scientist image update is included.
Fixed the cancellation review finding in 1b74091 (fix: preserve Codex cancellation without a timeout).
src/cli.ts:1921 now enables the existing parent signal handler for Codex independently of timeout configuration. An embedded caller forwarding SIGTERM to a child that catches it and exits 1 no longer triggers a capacity retry. Existing signal forwarding, external listeners, and cleanup remain intact.
Regression coverage in tests/capacity-cli.test.ts:160 exercises both timeout modes, checks one execution and no retry, verifies one delivery to the inherited listener, and confirms listener cleanup. The no-timeout case failed before the fix and passes afterward.
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
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.
Problem and behavior
Codex can exit with
Selected model is at capacity. Please try a different model.after starting a session. Headless previously returned that failure immediately, causing callers to exhaust task-level retries during the same capacity outage.Automatically retry this exact native terminal failure up to three times, waiting 30/60/120 seconds with ±20% jitter. Preserve model, billing route, native session, and the original timeout; do not replay partial work without a session.
HEADLESS_CAPACITY_RETRIES=0disables retries, and values 1–3 set the limit.Implementation
Validation
umask 0022; npm run check— build passed; 760 tests passed, 3 platform skips.git diff --checkpassed.The initial full-suite run under this host's
umask 0002failed nine existing Docker-session permission tests; rerunning with0022passed. No package release or Scientist image update is included.