fix(codex): retry terminal-only live completions - #70
Merged
Conversation
HM-Silvey
approved these changes
Jul 20, 2026
Aotricx
marked this pull request as ready for review
July 20, 2026 15:12
Contributor
Author
|
Reviewed the full diff (all three commits) plus an independent second-model pass. Approving. Correctness — verified in code:
Test evidence (ran locally on this branch):
Noted, non-blocking:
|
raine
force-pushed
the
agent/retry-empty-codex-completion
branch
from
July 28, 2026 14:15
a1b60a0 to
7d0fd4a
Compare
raine
force-pushed
the
agent/retry-empty-codex-completion
branch
from
July 28, 2026 14:19
7d0fd4a to
062b305
Compare
Add a smoke test where the upstream answers every attempt with a terminal-only completion: the proxy must stop after the initial attempt plus MAX_RETRYABLE_LIVE_STREAM_RETRIES full-context retries and surface the explicit 503 instead of an empty end_turn. A zero-delay test hook in retry::sleep (same pattern as the existing *_for_tests helpers) keeps the exhaustion run instant; a Drop guard restores real backoff even on panic. Also document the pending_chunk single-flush invariant.
Live stream translation writes traffic artifacts while initial Anthropic framing is still buffered. Empty completion retries discard those bytes, but the capture previously presented them as events delivered to the client. Translate the buffered prefix without a live capture sink, then parse and record its Anthropic SSE events only when the prefix is committed downstream. Later stream events continue to use direct capture. Extend the retry smoke test to prove discarded end-turn framing stays out of downstream artifacts. Client-visible streaming and retry behavior is unchanged.
raine
force-pushed
the
agent/retry-empty-codex-completion
branch
from
July 28, 2026 14:25
062b305 to
23d22ea
Compare
Owner
|
Thanks |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
response.completed/response.doneevents as retryable empty completionsprevious_response_idso retries send full contextend_turn*_for_testspattern as the websocket pool/continuation helpers)Scope: this covers the WebSocket live-stream path (
CCP_CODEX_TRANSPORT=websocket, the default). The buffered HTTP transport translates a terminal-only completion through the reducer and would still return an empty 200; left untouched here since the failure was only ever observed on the live path.Failure mode
A live Codex request could end with only
response.completed. The proxy translated that into HTTP 200 SSE containingmessage_startwithcontent: [], followed byend_turn. Claude Code then exited mid-turn; its resume repair inserted the syntheticNo response requested.message, making the failure look like model nonsense.The new smoke fixture reproduces that exact empty response before the fix and proves a full-context retry afterward.
TDD evidence
RED:
GREEN:
Assertions cover retry text, three upstream attempts, prior-response use on the failed attempt, and full-context retry without
previous_response_id.Verification
cargo fmt --all --checkcargo test --all— 600 tests passed across unit and integration suites (includes the new exhaustion smoke test,smoke_codex_websocket_empty_completions_exhaust_to_service_unavailable, 0.03s)cargo build --release --lockedpatched-proxy-okand normalend_turncargo clippy --all-targets -- -D warningsremains blocked by 33 pre-existing stable-1.97 warnings outside changed files.Independent from #68; no merge or deployment performed.