fix(auxiliary): xai-oauth uses chat.completions, not Responses API (#34171) - #34376
Closed
Bartok9 wants to merge 1 commit into
Closed
fix(auxiliary): xai-oauth uses chat.completions, not Responses API (#34171)#34376Bartok9 wants to merge 1 commit into
Bartok9 wants to merge 1 commit into
Conversation
…ousResearch#34171) xAI OAuth tokens are scoped to /v1/chat/completions only — they are NOT authorized for the Responses API. Wrapping the client in CodexAuxiliaryClient (which translates chat.completions.create() calls to responses.stream()) caused every auxiliary task on an xai-oauth session to fail with HTTP 403: 'The OAuth2 access token could not be validated. [WKE=unauthenticated:bad-credentials]' Same token works fine on direct /v1/chat/completions, confirming the mode (not the credential) was the problem. Affected tasks: context compression, vision, web_extract, title generation, goal judge, summary — anything routed through auxiliary_client.get_text_auxiliary_client() for an xai-oauth session. Fix: _build_xai_oauth_aux_client returns a plain OpenAI client pointed at the xAI base URL. Every other auxiliary task already expects a chat.completions client, so no upstream caller changes are needed. Tests (4 in test_xai_oauth_aux_client_chat_completions.py): - test_xai_oauth_aux_returns_plain_openai_client_not_codex_wrapper The NousResearch#34171 fix: client is a plain OpenAI, NOT a CodexAuxiliaryClient. - test_xai_oauth_aux_returns_none_when_no_model Defensive: empty model returns (None, None) + warning. - test_xai_oauth_aux_returns_none_when_unauthenticated No OAuth token → (None, None) cleanly. - test_xai_oauth_aux_uses_correct_base_url Plain client hits api.x.ai, not api.openai.com. Refs: NousResearch#34171 Closes: NousResearch#34171 Co-authored-by: Cursor <cursoragent@cursor.com>
Collaborator
Contributor
Author
|
Closing as duplicate of #34241 — thanks @alt-glitch for flagging. Confirmed via diff: PR #34241 (by @LeonSGP, opened 23 min before this one at 01:45 UTC) makes the same surgical fix in I missed #34241 when I scanned open PRs against issue list before I started \u2014 my bad. #34241 is the canonical fix; this can be closed safely. Apologies for the noise on the maintainer queue. \u2014 Bartok9 |
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 #34171
Problem
xAI OAuth tokens are scoped to
/v1/chat/completionsonly — NOT authorized for the Responses API. Wrapping the client inCodexAuxiliaryClient(which translates chat.completions calls to /v1/responses) caused every auxiliary task on an xai-oauth session to fail with HTTP 403:Same token works fine on direct
/v1/chat/completions, confirming the mode (not the credential) was the problem.Affected tasks: context compression, vision, web_extract, title generation, goal judge, summary — anything routed through
get_text_auxiliary_client()for an xai-oauth session.Fix
_build_xai_oauth_aux_clientnow returns a plainOpenAIclient pointed at the xAI base URL. Every other auxiliary task already expects a chat.completions client → no upstream caller changes needed.Tests (4)
api.x.ai, notapi.openai.com$ python -m pytest tests/agent/test_xai_oauth_aux_client_chat_completions.py === 4 passed in 0.35s ===🎻 Co-authored-by: Cursor cursoragent@cursor.com