feat(transports/codex): pass reasoning.effort to xAI Responses API - #22055
Closed
Julientalbot wants to merge 1 commit into
Closed
feat(transports/codex): pass reasoning.effort to xAI Responses API#22055Julientalbot wants to merge 1 commit into
Julientalbot wants to merge 1 commit into
Conversation
The is_xai_responses branch only sent include=[reasoning.encrypted_content] without forwarding the resolved reasoning_effort. Other Responses providers (OpenAI, GitHub) already get effort forwarded — this aligns the xAI path. Without this, agent.reasoning_effort is silently dropped on the xAI direct path, making Hermes unable to control reasoning depth on grok-4.x via api.x.ai. Tests added to TestCodexBuildKwargs cover effort passthrough, disabled state, and minimal-clamp parity with non-xAI.
This was referenced May 8, 2026
Open
Contributor
Collaborator
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.
Problem
The xAI direct path (
is_xai_responses=True) inagent/transports/codex.pyonly forwardsinclude=["reasoning.encrypted_content"]and silently drops the resolvedreasoning_effort. The sibling non-xAI Responses branch already passeskwargs["reasoning"] = {"effort": ..., "summary": "auto"}.This means
agent.reasoning_effort(and anyreasoning_config.effortinjected by callers) is silently ignored on the xAI direct route. Settinglow,medium, orhighin config has zero effect — xAI receives noreasoningfield and uses its server-side default.Why this matters
For agentic tool-calling on grok-4.x, xAI's docs explicitly recommend
reasoning_effort: low(model-capabilities/text/reasoning). When Hermes can't transmit this, users running Telegram bots / CLIs report:A 100-call benchmark across efforts on a real-world Alfred-style session showed pass rate variance:
none=58%, low=87%, medium=82%, high=86%— variance that's currently inaccessible from config on the xAI direct path.Fix
One-line change: in the
is_xai_responsesbranch, also passkwargs["reasoning"] = {"effort": reasoning_effort}. We deliberately omitsummary: "auto"(used by the OpenAI Responses branch) since xAI's Responses API documentation does not mention it — conservative posture pending confirmation.Tests
3 new tests in
tests/agent/transports/test_codex_transport.py::TestCodexBuildKwargs:test_xai_reasoning_effort_passed— assertskw["reasoning"] == {"effort": "high"}and the encrypted-content include remains.test_xai_reasoning_disabled_no_reasoning_key— asserts"reasoning" not in kwwhenreasoning_config={"enabled": False}.test_xai_minimal_effort_clamped— parity with the existing non-xAI clamp test (minimal -> low).pytest tests/agent/transports/test_codex_transport.py -v→ 29 passed.Live verification
Real call to
https://api.x.ai/v1/responseswith the patched payload + a single dummyechotool:Without the patch, the equivalent request produces no
reasoningoutput item andreasoning_tokens=0.Tangential note
While building the live test, I confirmed that xAI rejects requests with
tool_choiceset buttools=[](HTTP 400 "A tool_choice was set on the request but no tools were specified") — exact symptom of #20606 (still open). Independent of this PR but worth flagging.