fix(xai): stream OAuth Grok through Responses - #2104
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe change adds authentication-scoped xAI wire defaults for Grok 4.5 and 4.6. OAuth requests use native Responses passthrough. Native Responses OAuth requests now refresh credentials and replay once after a pre-stream 401. ChangesxAI authentication-aware wire selection
Native Responses OAuth recovery
Estimated code review effort: 4 (Complex) | ~45 minutes Merge Risk: 🔵 Low · up to This change extends OAuth authentication replay to native Responses streaming requests; the stated checks are complete, but merge should wait for the required maintainer security approval because retry behavior is security-sensitive. Sequence Diagram(s)sequenceDiagram
participant Client
participant ResponsesCore
participant OAuthProvider
participant xAIResponses
Client->>ResponsesCore: Send native Responses request
ResponsesCore->>xAIResponses: Forward request
xAIResponses-->>ResponsesCore: Pre-stream 401
ResponsesCore->>OAuthProvider: Force-refresh OAuth credential
OAuthProvider-->>ResponsesCore: Refreshed credential
ResponsesCore->>xAIResponses: Replay rebuilt request once
xAIResponses-->>Client: Responses stream
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Deterministic PR hygiene checks passed. |
✅ READY
Review readiness checklist
✅ 4/4 boxes ticked. This pull request is already Ready for Review. |
Summary
xai/grok-4.5andxai/grok-4.6through the Responses backend declared by the official Grok CLI model catalog.structure/04_transports-and-sidecars.md.The previous xAI OAuth preset intentionally followed the older Grok CLI Chat Completions contract. The current official model catalog reports
api_backend: "responses"for Grok 4.5 and 4.6, while OpenCodex still selected its provider-wideopenai-chatadapter. That compatibility drift could leave Codex waiting until the reasoning turn was effectively complete before seeing output.Security boundary: this reuses the existing generation-checked, singleflight OAuth refresh and permits only one pre-stream replay. It does not add credential persistence, forwarding destinations, request-body logging, or new OAuth scopes. Because it touches the OAuth replay path, it still requires explicit maintainer security review before merge.
Verification
At commit
3c5a34f73, based directly onupstream/devcommit63bfd149d:bun run typecheckbun run test— 13,404 pass / 10 skip / 0 failbun run privacy:scangit diff --check upstream/dev...HEAD/responses, preserves Responses request fields, and delivers the first SSE text delta while upstream completion is still blocked.openai-responses.Live canary latency is not a controlled benchmark: TTFT was
0.656s,0.598s,77.824s,0.733s, and31.169s. Three calls streamed promptly; two retained xAI-side long-tail latency. The deterministic regression therefore asserts the proxy property this PR owns—first-delta relay before completion—rather than claiming that it removes upstream generation variance.Checklist
structure/04_transports-and-sidecars.mddocuments the routing and replay boundaries; there is no new user configuration.)Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
All CI tests are green on my local testing.
I pushed my PR to the latest dev commit.
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.
Summary by CodeRabbit
New Features
Bug Fixes