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
{{ message }}
Repository navigation
Codex: exhausted empty-completion 503 is retried by Claude Code, so a deterministic empty turn hangs ~30 min #174
When Codex keeps finishing a turn with no output, the proxy retries the request up to 10 times (about 3 minutes), then answers HTTP 503 Codex completed without producing output (#70, #71). Claude Code treats that 503 as retryable and resends it up to 10 more times, and every resend repeats the proxy's full retry loop. If the empty completion is deterministic, one request is held for about 30 minutes (around 100 upstream calls) before it fails.
Where it happens
It reproduces with Claude Code background subagents on gpt-6-sol / gpt-5.6-luna. A subagent hands its report back to the parent and gets an ordinary tool result. The model then has nothing left to say, so the follow-up turn completes empty every time. The subagent shows as running until the parent kills it.
Proxy log from one session (v0.1.43, websocket transport). Two subagents, each producing a 503 every ~3 minutes:
03:53:05 fac0c607 503 187970 ms Codex completed without producing output
03:54:08 9d41c437 503 179387 ms
03:56:10 6d0a6573 503 184562 ms
03:57:14 23a211b2 503 186122 ms
... (one every ~3 min per agent)
04:08:43 44faf167 503 179514 ms
04:09:42 4065b3fd 503 181647 ms -> chains end only when the agents were killed at 04:12
Each chain starts within a second of its subagent's last tool result (03:49:57 and 03:51:09). Over the same period, about 370 subagents on Claude models always produced a short final text turn and completed normally.
Suggested fix
Return the exhausted-empty 503 with x-should-retry: false, the same signal usage_limit_response already sends. Claude Code 2.1.281's shouldRetry checks this header before checking the status code, so the request then fails once, after the proxy's own retries. A patch with that one change, plus a header assertion in the existing tests, is on gongx030/claude-code-proxy branch fix/empty-completion-no-client-retry. I will open it as a PR once its tests have run.
A separate question for you: whether the 10-attempt budget for empty completions (MAX_EMPTY_COMPLETION_RETRIES, and the shared live-stream budget the websocket path uses) should be smaller. A completion that comes back empty with the same full context is probably deterministic. I didn't change it because the live-stream budget also covers other errors.
Fixed by #175, released in v0.1.44 (verified: git merge-tree --write-tree v0.1.44 <patch-branch> equals the v0.1.44 tree). Claude Code now fails once instead of retrying for ~30 min. Thanks for merging.
One follow-up observation from production logs, in case it is useful: a repeatable empty completion still costs 185–223 s before the 503 is returned. In 33 empty-completion 503s out of ~10,900 requests, every one landed in that band. That matches the buffered retry loop in src/providers/codex/mod.rs: attempt starts at 0 and MAX_EMPTY_COMPLETION_RETRIES = 10, so it makes 11 upstream calls plus 157.5 s of backoff (1.5 + 3 + 6 + 12 + 6 × 22.5 s), then a few seconds per call.
Two small suggestions, if you want them:
Log each empty-completion retry. Right now the log shows one codex_upstream_request_started and then a 503 three minutes later, so the 11 attempts are invisible.
Consider a lower cap for empty completions specifically. When 11 consecutive calls come back empty, the empty answer looks repeatable for that input, and most of the three minutes is spent waiting.
Activity
gongx030 commentedon Oct 7, 2026
Tests have run (cargo test, clippy, and fmt all pass), and the patch is now open as #175.
gongx030 commentedon Oct 8, 2026
Fixed by #175, released in v0.1.44 (verified:
git merge-tree --write-tree v0.1.44 <patch-branch>equals the v0.1.44 tree). Claude Code now fails once instead of retrying for ~30 min. Thanks for merging.One follow-up observation from production logs, in case it is useful: a repeatable empty completion still costs 185–223 s before the 503 is returned. In 33 empty-completion 503s out of ~10,900 requests, every one landed in that band. That matches the buffered retry loop in
src/providers/codex/mod.rs:attemptstarts at 0 andMAX_EMPTY_COMPLETION_RETRIES = 10, so it makes 11 upstream calls plus 157.5 s of backoff (1.5 + 3 + 6 + 12 + 6 × 22.5 s), then a few seconds per call.Two small suggestions, if you want them:
codex_upstream_request_startedand then a 503 three minutes later, so the 11 attempts are invisible.