Codex retry time limit counts time the Mac is asleep, and the error still says "2/5 retries" #37567
What happened#
A Codex turn in a scheduled thread failed with "Provider error after 2/5 retries — request timed out" while my MacBook was asleep. The counter stayed at 2/5, so it looked like the thread was stuck with three retries left. In fact the turn had already been given up on.
Diagnosis#
Codex retries for a turn get 10 minutes in total (PROVIDER_RETRY_BUDGET_MS in packages/provider-core/src/server/failure.ts). CodexAdapterV2 sets a timer for that deadline, and when it fires, failStalledProviderRetry fails the turn as not retryable, however many attempts Codex has left.
The timer counts time the Mac spends asleep. Here the first retry notice arrived during a short DarkWake, the Mac went back to sleep, and the 10 minutes ran out while it slept. The turn failed within half a second of the next wake, so Codex never got a retry with the network back.
The error item keeps the last notice's attempt: 2, maxAttempts: 5, which is why the UI says "after 2/5 retries" instead of saying the time limit ran out.
No log line names the budget, but the server trace has nothing on this thread between the retry notice and the failure, and the only other timeout (PROVIDER_RETRY_STALL_TIMEOUT, 15 minutes) wasn't due yet.
Steps to reproduce#
- On macOS, start a Codex turn and drop the network so Codex starts retrying.
- Put the Mac to sleep for more than 10 minutes.
- Wake it.
Expected: retries continue once the network is back, or the error says the retry time limit was reached. Actual: the turn fails immediately, and the error reads "after 2/5 retries".
Version#
0.1.10-nightly.20261115.4749
Environment#
Desktop app with its local server, macOS 27.0 on Apple Silicon, on battery. codex-cli 0.169.0. The code is unchanged on main (16695c8).
Evidence#
error item first seen 05:48:53.88Z failed 06:01:23.74Z
transport_error, responseStreamDisconnected, retryable: false
retry: { attempt: 2, maxAttempts: 5 }
pmset -g log (UTC)
05:48:13 DarkWake (45 s) retry notice arrives
05:48:58 Sleep 10-min deadline passes at 05:58:53
06:01:23 DarkWake turn fails
Related issues#
#28936, #17503 and #31446 (closed) were Codex retries hanging for hours, which the 10-minute limit seems to address. This is the other side of it: the limit ends a turn too early when the clock includes sleep. The stalled automation that followed is a separate issue.
Fix applied or workaround#
None.
Filed by#
Claude Opus 5.5 in Claude Code, following the t3 triage playbook.
EtanHey(GitHub profile, opens in a new tab) added labelsvia-triage
tanstack-source added labelsbug
I tried to reproduce this on the current build and could not.
On origin/main d68a2fa673 I ran the existing CodexAdapterV2 replay test 'fails a stalled 429 provider retry as a usage limit and stops the Codex turn' (
vp test run apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts -t "fails a stalled 429"). Codex sends retry notices 1/5 and 2/5, and the test clock moves past the 10-minute PROVIDER_RETRY_BUDGET_MS. The turn fails with retry.attempt 2 and failure.message 'exceeded retry limit, last status: 429 Too Many Requests'. Nothing says the retry time limit ended it, so the web label reads 'Usage limit reached/Provider error after 2/5 retries'. I added one assertion that the message names the time limit; it fails on main (branch factory/repro-37567, commit 06e92eafc1). I could not run the reporter's real case: macOS sleep during a live Codex retry needs a Mac and Codex ChatGPT auth, and this Linux VM has neither. Linux CLOCK_MONOTONIC also does not count suspend.Closing as not planned. If it still happens for you, reply with the exact steps and the version you are on and it will be looked at again.
juliusmarminge closed this
@juliusmarminge Thanks for checking. Your test reproduces half of it: the assertion that the message names the time limit fails on main, so the "after 2/5 retries" label is confirmed.
The other half is macOS-only, which is why a Linux VM can't show it (as you noted, CLOCK_MONOTONIC there doesn't count suspend). On my Mac the deadline clearly counted sleep:
- 05:48:53Z: retry notice 2/5, during a 45 s DarkWake
- 05:48:58Z: Mac sleeps; the 10-min deadline (05:58:53Z) passes while asleep
- 06:01:23Z: DarkWake; the turn fails 0.4 s later, with no provider event in between (server trace)
The Mac was awake for about 5 s in total after the retry notice. A deadline that excluded sleep could not have fired then.
Steps (macOS, Codex with ChatGPT auth):
- Start a Codex turn, then turn off Wi-Fi so Codex starts retrying ("Reconnecting… 1/5").
- Close the lid on battery for 11+ minutes.
- Open it. The turn fails immediately with "Provider error after N/5 retries", not retryable.
Version: 0.1.10-nightly.20261115.4749 (desktop app + local server), macOS 27.0, Apple Silicon. Could you reopen?
It happened again last night, this time on a Claude turn, on a newer build (0.1.10-nightly.20261116.4800). So it isn't Codex-only:
ClaudeAdapterV2.tsarms the same 10-minutePROVIDER_RETRY_BUDGET_MSwithEffect.delay, and that timer also keeps counting while the Mac sleeps.Lid closed on battery at 20:00Z. Server records and
pmset -g log(UTC):- 20:26:05Z: turn starts during a 2 s DarkWake
- 20:41:08Z: retry notice 5/10 ("Claude API unknown"), during another 2 s DarkWake; Mac sleeps again at 20:41:10
- 20:50:00–20:50:45Z: the only other time the Mac is awake
- 20:57:07Z: DarkWake; the turn fails in the same second,
retryable: false, labelled "Provider error after 5/10 retries"
Between the retry notice and the failure the Mac was awake for about 47 s, yet the 10-minute limit (and the 15-minute stall timer) both ran out. Nothing resumes the turn after wake, so the thread just sits failed until someone sends a message.
Sign in to join this conversation.
Related issues and pull requests. None of them reports this bug.
A fix could pause or restart the limit across sleep and wake, and say "retry time limit reached" when it fires, instead of "after 2/5 retries".