fix(codex): retry empty buffered completions - #71
Merged
Conversation
Buffered Codex transports translated successful terminal events with no semantic output into empty HTTP 200 end_turn responses. Retry these responses instead so callers receive a usable completion or an explicit failure. Use reducer events to distinguish output text, thinking, tool calls, and web searches from terminal-only bodies. Message item framing without a text delta remains empty because the accumulator omits such blocks. Drop previous_response_id before each retry so WebSocket requests resend full context. Bound retries to ten after the initial attempt and return 503 after exhaustion. Abort continuation and pending compaction state when processing fails. Tests remove retry delays and cover buffered streaming, non-streaming, exhaustion, and empty message scaffolding. This changes empty successful completions from HTTP 200 end_turn responses to bounded retries and a 503.
raine
force-pushed
the
agent/retry-empty-buffered-completion
branch
from
July 28, 2026 14:12
7b932b4 to
1d9d216
Compare
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.done) with no semantic output, using the existing reducer (text, thinking, tool, and web-search events all count as semantic)previous_response_iddropped so the resend carries full context, bounded at 1 + 10 attemptsCodex completed without producing output) after exhaustion instead of a successful emptyend_turnresponse.incompletestays non-retryable (a max-tokens truncation would not improve on resend)Failure mode
The buffered transport path —
CCP_CODEX_TRANSPORT=http, and non-streaming client requests generally — translated a terminal-only upstream body into HTTP 200 with"content": []andstop_reason: "end_turn". Same class of failure as the live-stream path fixed in #70, on the other transport.TDD evidence
RED (all three smoke tests before the fix):
GREEN:
The detection helper was also grown test-first: six unit tests (terminal-only completed/done → empty; text / tool-call / incomplete-only / no-terminal → not empty) written against a stub and watched fail before implementation.
Relationship to #70
Independent branch from
main; complementary to #70 (live WebSocket path). Two hunks are intentionally identical to #70 so a later merge dedupes trivially: theEMPTY_CODEX_COMPLETION_DETAIL503 mapping branch, and the zero-delay retry test hook inretry.rs(same*_for_testspattern as the websocket pool/continuation helpers).Verification
cargo fmt --all -- --checkcargo test— 604 passed, 0 failed across unit and integration suites🤖 Generated with Claude Code