fix(openai-codex): omit encrypted reasoning replay for native responses#87151
fix(openai-codex): omit encrypted reasoning replay for native responses#87151baanish wants to merge 2 commits into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed May 30, 2026, 9:44 PM ET / 01:44 UTC. Summary PR surface: Source +8, Tests +73. Total +81 across 2 files. Reproducibility: yes. for the request-shape bug from source: current main preserves matching Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Refresh the regression test and real behavior proof to the current native Codex identity, then land the sanitizer if custom/proxy replay coverage still preserves encrypted replay. Do we have a high-confidence way to reproduce the issue? Yes for the request-shape bug from source: current main preserves matching Is this the best way to solve the issue? No as submitted: the production change is the right narrow shape, but the PR must update the stale test/proof identity to demonstrate the current native Codex path. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 26913e60a42e. Label changesLabel justifications:
Evidence reviewedPR surface: Source +8, Tests +73. Total +81 across 2 files. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
ClawSweeper PR egg ✨ Hatched: 🥚 common Velvet Branchling Hatch commandComment Hatchability rules:
Rarity: 🥚 common. What is this egg doing here?
|
83c2ae0 to
697dce5
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Superseded by #90682, merged as This PR proposed stripping native encrypted reasoning replay before dispatch. The landed fix addresses the underlying corruption instead: transcript redaction now preserves only validated, provenance-bound provider replay ciphertext and signatures while continuing to redact malformed, nested, unknown, and credential-shaped values. That is the better current behavior because valid OpenAI reasoning replay remains available for continuity rather than being removed unconditionally. Exact-head live proof on #90682 ran The original fixture here also uses the retired Thank you, @baanish, for isolating the first-request replay shape and supplying the original live evidence. |
Summary
openai-codexResponses turns can replay prior reasoning items withencrypted_contentwhen replay provenance matches.[responses] retrying without encrypted reasoning content ..., strips the field, and sends a second request.encrypted_contentduring nativeopenai-codex-responsesrequest sanitization before the first request is sent.openai/gpt-5.5auth/profile routing, model aliases, fallback behavior, prompt cache keys, or custom Responses backends.Motivation
This removes an avoidable failed first request on
openai-codex/gpt-5.5Pi runs. The successful retry already runs without encrypted reasoning replay; this patch makes the first attempt use the same backend-compatible shape.Related to #87099 and complementary to #87123. That PR addresses
/model ...@profilesession auth persistence; this PR addresses the separate transport retry churn.Change Type
Scope
Linked Issue/PR
Real behavior proof
Behavior or issue addressed: native
openai-codex/gpt-5.5Responses requests no longer send encrypted reasoning replay that the backend rejects.Real environment tested: macOS arm64, OpenClaw 2026.5.22 local gateway patched with this transport change, Pi harness,
openai-codex/gpt-5.5, Codex OAuth auth profile.Exact steps or command run after this patch: rebuilt the local gateway from this branch, installed it as the local OpenClaw gateway, confirmed gateway status, ran two no-delivery agent turns in the same session with
openai-codex/gpt-5.5andthinking low, then scanned gateway logs after patched startup for encrypted-reasoning retry markers.Evidence after fix (copied live output and redacted runtime log excerpt):
Observed result after fix: replayable encrypted reasoning material can exist in session history, but native Codex request sanitization removes it before dispatch, so the second same-session turn succeeds on the first request instead of hitting the encrypted-reasoning retry path.
What was not tested: maintainer-owned live production credentials or non-native proxy Codex-compatible backends.
Proof limitations or environment constraints: evidence is from Aanish's local macOS OpenClaw gateway with private paths/secrets redacted; no Discord delivery was used.
Before evidence (optional but encouraged): current main preserves matching native Codex encrypted replay in source-level reproduction, so the request can include
encrypted_contentbefore this sanitizer runs.Root Cause
prepareOpenAIResponsesReasoningItemForReplaypreservesencrypted_contentwhen replay metadata matches provider, API, model, base URL, session, and auth profile. That is correct for compatible Responses backends, but nativeopenai-codex-responsesstill rejects the encrypted replay field.The retry wrapper already handled this after failure by stripping encrypted content and resending. The missing guardrail was that native Codex request sanitization stripped unsupported top-level/text fields but did not strip encrypted reasoning replay before the first send.
Regression Test Plan
strips native Codex encrypted reasoning replay even when provenance matches.openai-codex-responsesrequest with matching replay provenance and asserts the reasoning item keepstype: "reasoning"but drops both replayidandencrypted_content.User-visible / Behavior Changes
Native
openai-codex/gpt-5.5Pi turns should stop paying the avoidable failed-request/retry tax caused by encrypted reasoning replay. The successful request content shape matches the existing retry fallback behavior.Security Impact
Repro + Verification
Environment
origin/mainfor testsopenai-codex/gpt-5.5--deliveromittedCommands
node scripts/run-vitest.mjs run src/agents/openai-transport-stream.test.ts -t "strips native Codex encrypted reasoning replay even when provenance matches" node scripts/run-vitest.mjs run src/agents/openai-transport-stream.test.ts npx oxfmt --check src/agents/openai-transport-stream.ts src/agents/openai-transport-stream.test.ts npx oxlint src/agents/openai-transport-stream.ts src/agents/openai-transport-stream.test.ts node scripts/run-tsgo.mjs -p tsconfig.jsonResults
oxfmt: clean.oxlint: clean.tsgo: currentorigin/mainfails in unrelatedextensions/memory-core/src/dreaming.test.tsbecause a test mock is missing requiredgetSession; this PR does not touch that file.Human Verification
Compatibility / Migration
Risks and Mitigations