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 (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 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 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: ⚪ Minimal · up to The PR changes xAI OAuth routing, streaming, replay, and service-tier handling with regression coverage and documented behavior; no actionable merge-blocking risk remains after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant Client
participant ResponsesCore
participant OAuthCredentialProvider
participant xAIResponses
Client->>ResponsesCore: Send native Responses request
ResponsesCore->>xAIResponses: Forward request
xAIResponses-->>ResponsesCore: Pre-stream 401
ResponsesCore->>OAuthCredentialProvider: Force-refresh OAuth credential
OAuthCredentialProvider-->>ResponsesCore: Refreshed credential
ResponsesCore->>xAIResponses: Replay rebuilt request once
xAIResponses-->>Client: Responses stream
Possibly related PRs
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. |
리뷰 · 우선순위 63 / 80OAuth 레지스트리 계약이 중심이다.
테스트는 계약을 꽤 정확히 고정한다. #2072가 API 키 수송의 Priority/Fast를 열고 OAuth는 미분류로 둔다. 이 PR은 OAuth Responses 와이어만 바꾼다. 두 개가 겹치면 Fast가 OAuth 게이트웨이로 새지 않는지 한 번 더 봐야 한다. 라이브 카나리는 5/5 완료지만 TTFT가 0.6s와 77s로 갈라져서, 이 PR이 주장하는 건 첫 델타 중계이지 업스트림 지연 제거가 아니다. 해결방안메인테이너가 OAuth 401 replay 쌍둥이 경로를 Chat 구현과 나란히 읽고 이 댓글은 grok-bot이 작성했습니다 |
806c9ff to
5a1fc91
Compare
|
Addressed the requested Fast/#2072 boundary in
Compatibility evidence: a common-base synthetic composition with #2072 passed Final-head verification on latest |
|
Thanks for this, @olddonkey — closing as superseded by #2147, which carries your PR unchanged. Nothing needed correcting: an independent read-only audit of the diff came back clean, and CodeRabbit had no actionable comments either. Two things worth recording for whoever reviews #2147: The streaming test is the load-bearing one. Asserting the first The 401 replay you added is structurally one-shot, not a loop, so a second 401 cannot trigger a second refresh; your I verified your Your work is credited in #2147's description. |
OAuth xai/grok-4.5 and grok-4.6 Codex /v1/responses traffic still used the provider-wide openai-chat adapter, while the official Grok CLI catalog declares api_backend: "responses". Chat Completions compatibility holds the stream until the reasoning turn finishes, so Codex sat blank until the turn was effectively done. Declare the Responses wire default for those two models, scoped to OAuth and to responses-shaped inbound traffic. API-key xAI, Chat/Anthropic translation, other Grok models, and any explicit modelAdapters override all stay on Chat. Native Responses returns before the generic recovery loop, so the OAuth 401 replay never ran on this path. Add the equivalent one-shot: refresh once, rebuild the provider and adapter, replay once. It is a single branch rather than a loop, so a second 401 cannot refresh again. Refresh failures go through the existing public OAuth error projector, which the tests pin against path canaries. Carries @olddonkey's lidge-jun#2104 unchanged. Closes lidge-jun#1886
Summary
xai/grok-4.5andxai/grok-4.6through the Responses backend declared by the official Grok CLI model catalog.service_tieron the xAI OAuth gateway. The registry default explicitly denies forwarding it, and that denial applies only when the registry default wins; API-key Fast and explicit overrides remain isolated.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
5a1fc91a7, rebased directly ontoupstream/devcommitcd8f9b8ab:bun run typecheckbun run test— 13,540 pass / 10 skip / 0 fail across 856 filesbun run privacy:scangit diff --check upstream/dev...HEADfastMode: trueand inboundservice_tier: "priority", the OAuth xAI/responsesrequest contains noservice_tier; generic Responses passthrough and explicit overrides retain their existing contracts.bun run typecheckplus 337 focused tests passed / 0 failed, covering API-key Fast remaining enabled while OAuth stays unclassified and blocks caller tier forwarding. The current feat(xai): B2 — enable Priority Processing on the API-key transport (#1886, closes #1875) #2072 head is 136 commits behinddevand has unrelated merge conflicts against the latest tree, so this PR also carries the combined boundary as a direct regression test.Five authenticated Grok 4.6 canaries were run on the preceding streaming commit
3c5a34f73: 5/5 completed, and all selectedopenai-responses. Those calls validate the transport change, while the final service-tier guard is covered deterministically on5a1fc91a7.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, replay, and caller-tier 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
Tests