Repository navigation
Conversation
CCP_CODEX_EMPTY_COMPLETION=end_turn (or codex.emptyCompletion) applies the empty-completion acceptance from raine#122 to every request: one retry, then a valid empty end_turn instead of up to 11 full-context upstream calls and a 503. The default, retry, keeps the resolved-tool-results-only behavior. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Closes #208. This adds an opt-in setting,
CCP_CODEX_EMPTY_COMPLETION=end_turnorcodex.emptyCompletion: "end_turn", that applies the #122 rule to every Codex request. The rule is to retry an empty completion once and then return an emptyend_turn. Without the setting, behavior is unchanged: the rule covers only resolved tool results, and other empty completions get the full retry loop and a 503.Why. With Claude Code, some requests that don't end in tool results come back empty by design, for example a turn answering a Monitor event that needs no reply. Each one cost 11 full-context calls and 3–4 minutes before failing. Details and timings are in #208.
Change
config.rs:codex_empty_completion_end_turn()reads the env var, thencodex.emptyCompletion. It acceptsend_turn/end-turnorretry; anything else falls back toretry. The setting is also listed in the config summary.providers/codex/mod.rs: both places that calltail_is_successful_tool_result(&body)now callempty_completion_may_end_turn(&body), which is that check OR the setting.accept_empty_completionis untouched, so the one-retry discriminator from codex: treat an empty successful completion after a tool_result tail as a valid end_turn #122 still applies.Result. We ran the same change on top of v0.1.44 with #122's earlier version. Offline, against a stub upstream that always completes empty, a request costs 2 upstream calls and ~1.5 s instead of 11 calls and a 503, on both the buffered and the streaming path. Claude Code 2.1.293 accepts the empty
end_turn(-preturns success, one turn, no client retries). Live withgpt-6-astra, the next 270 requests over three weeks produced no empty-completion 503.Details for reviewers and agents: tests, scope
Tests
codex_empty_completion_mode_reads_env_and_config: default off, config on, envretryoverrides config, envend_turn.cargo fmt --all -- --check: clean.cargo clippy --all-targets --locked -- -D warnings: clean.cargo test --all --locked: 1175 passed, 0 failed (onmainat fe10718).Scope
Unrelated, noticed while testing: running
cargo testappends log lines to the real~/.local/state/claude-code-proxy/proxy.log, e.g.gpt-5.5503s at ~4 ms and ~11 s. Some test doesn't isolate the state dir. #164 has a similar leak: one of its tests wrotecodex-compaction/session.jsoninto the real state dir.Written by Claude Opus 5.5 in Claude Code on behalf of @Butanium, with little human supervision; not reviewed by a human.
https://claude.ai/code/session_01Xmx9RE7u4ZLBzSUjpjqyBM