fix(xai): restore encrypted reasoning replay across turns - #29672
Merged
Conversation
xAI partner integration requires Hermes to thread `encrypted_content` reasoning items back to the Responses API on every turn so Grok can maintain cross-turn reasoning coherence. PR #26644 (May 15) gated this off for `is_xai_responses` on the theory that the OAuth/SuperGrok surface rejected replayed encrypted blobs and produced the multi-turn "Expected to have received \`response.created\` before \`error\`" failure. That diagnosis was wrong — the prelude-SSE fallback added in the same PR is what actually fixed that failure mode. Suppressing the replay was an unnecessary side-effect that broke the whole point of xAI's partnership integration. Changes: - agent/codex_responses_adapter.py — drop the `is_xai_responses` gate in `_chat_messages_to_responses_input`. Keep the kwarg in the signature for transport compatibility; update the docstring to document the May 2026 reversal. - agent/transports/codex.py — restore `kwargs["include"] = ["reasoning.encrypted_content"]` on the xAI Responses path so xAI echoes encrypted reasoning back to us. - tests/run_agent/test_codex_xai_oauth_recovery.py — flip the three xAI assertions (now: xAI MUST receive replayed reasoning AND we MUST include encrypted_content in the request). - tests/agent/transports/test_codex_transport.py — flip the `include` assertions on `test_xai_reasoning_effort_passed` and `test_xai_grok_4_omits_reasoning_effort`; update the allowlist block comment. The prelude-SSE fallback and the entitlement-403 surfacing fixes from #26644 are untouched — they were independent fixes that happened to ride along with the reasoning-replay gate. Validation: - Targeted: tests/run_agent/test_codex_xai_oauth_recovery.py + tests/agent/transports/test_codex_transport.py → 65/65 pass - Broader: tests/agent/transports/ + tests/run_agent/ → 1674 passed, 3 skipped, 0 failures - E2E (real imports, isolated HERMES_HOME, ResponsesApiTransport build_kwargs): turn-1 request carries `include: ["reasoning.encrypted_content"]`; turn-2 input replays the encrypted_content blob from turn-1's `codex_reasoning_items`; native Codex unchanged.
Contributor
🔎 Lint report:
|
19 tasks
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
xAI partner integration requires Hermes to thread
encrypted_contentreasoning items back to the Responses API on every turn so Grok can maintain cross-turn reasoning coherence — the whole point of the partnership. PR #26644 (May 15) suppressed that replay foris_xai_responseson the theory that xAI's OAuth/SuperGrok surface rejected replayed encrypted blobs. That diagnosis was wrong: the prelude-SSE fallback added in the same PR is what actually fixed the multi-turn failure mode, and the replay gate was unnecessary collateral that broke the partnership integration.Changes
agent/codex_responses_adapter.py— drop theis_xai_responsesgate in_chat_messages_to_responses_input. Kwarg stays in the signature for transport compatibility; docstring documents the May 2026 reversal.agent/transports/codex.py— restorekwargs["include"] = ["reasoning.encrypted_content"]on the xAI Responses path so xAI echoes encrypted reasoning back to us.tests/run_agent/test_codex_xai_oauth_recovery.py— flip the three xAI assertions (xAI now MUST receive replayed reasoning AND we MUST request encrypted_content back).tests/agent/transports/test_codex_transport.py— flip theincludeassertions ontest_xai_reasoning_effort_passedandtest_xai_grok_4_omits_reasoning_effort; update the allowlist block comment.The prelude-SSE fallback and the entitlement-403 surfacing fixes from #26644 are untouched — they were independent fixes that happened to ride along with the reasoning-replay gate.
Validation
test_codex_xai_oauth_recovery+test_codex_transport)tests/agent/transports/+tests/run_agent/)ResponsesApiTransport.build_kwargs)include: ["reasoning.encrypted_content"]; turn-2 input replays the encrypted_content blob from turn-1'scodex_reasoning_items; native Codex unchangedInfographic