Preserve Codex encrypted reasoning across Claude turns#52
Merged
Conversation
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
CCP already requests
reasoning.encrypted_contentfrom the Codex Responses API, but the Claude translation previously discarded it:signature;As a result, encrypted reasoning could not survive stateless multi-turn replay when
previous_response_idwas disabled.This PR round-trips the Codex reasoning item through a CCP-owned, namespaced Claude thinking signature:
The encrypted payload is preserved byte-for-byte. CCP does not decrypt or interpret it.
Protocol rationale
OpenAI documents that reasoning items should be included in subsequent input when application code manages conversation history manually. Requesting
reasoning.encrypted_contentmakes the opaque reasoning payload available for this purpose:reasoning.encrypted_contentClaude's extended-thinking protocol provides an opaque
signaturefield. During streaming, Anthropic specifies thatsignature_deltais emitted immediately beforecontent_block_stop:This PR uses that field only as a transport for a namespaced CCP envelope. Foreign, malformed, or oversized signatures are ignored.
Prior art
Other Codex-to-Claude adapters use the same general round-trip pattern.
CLIProxyAPI translates Claude thinking signatures into Codex
encrypted_content, requests encrypted reasoning from Responses, and maps it back into Claude thinking blocks:reasoning.encrypted_contentThe pi-mono multi-provider adapter independently stores complete Responses reasoning items in
thinkingSignatureand restores them on the next request:thinkingSignatureImplementation
ccp:codex:v1:signature envelope containing the reasoning item ID and encrypted payload.idandencrypted_contentfrom Responses streaming events.signature_deltabeforecontent_block_stop.reasoningitems in their original transcript position.Validation
cargo test --all-targets: 559 passed, 0 failedrustfmt 1.96 --check: passed18766.CCP_CODEX_PREVIOUS_RESPONSE_ID=0was used to force full transcript replay./v1/messages/count_tokensaccepted the signed transcript.18765was not touched.Scope
This PR only changes encrypted-reasoning round-trip behavior. It does not change HTTP transport,
previous_response_idhandling, Docker configuration, authentication, or diagnostic logging.