Repository navigation
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed August 1, 2026, 4:13 PM ET / 20:13 UTC. ClawSweeper reviewWhat this changesThe PR adds a static Grok client-version header to the xAI OAuth provider configuration, scopes it away from custom base URLs, and adds provider-catalog coverage. Merge readiness⛔ Blocked until stronger real behavior proof is added - 8 items remain Keep this PR open: current main still omits the required OAuth-proxy header, so the central xAI subscription inference failure remains unresolved. The branch is now conflicted with newer OAuth default-model selection code and needs a rebase that composes both behaviors, plus a redacted successful OpenClaw OAuth turn from the final head before merge. Priority: P1 Review scores
Verification
How this fits togetherThe bundled xAI provider resolves OAuth credentials, discovers available Grok models, and projects a provider configuration into the agent model registry. That registry combines provider headers with credentials before requests reach the Grok OAuth proxy for an agent turn. flowchart LR
A[xAI OAuth credential] --> B[xAI provider catalog]
B --> C[Model discovery and default selection]
C --> D[Provider configuration]
D --> E[Model registry request headers]
E --> F[Grok OAuth inference proxy]
F --> G[Agent response]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +31, Tests +76. Total +107 across 3 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Rebase the header change onto current xAI OAuth catalog logic, retain settings-derived auto-model selection, cover the composed result, and attach redacted output from a successful OpenClaw OAuth inference turn. Do we have a high-confidence way to reproduce the issue? No complete final-head OpenClaw reproduction is attached. The current source clearly omits the OAuth proxy header and the PR supplies redacted live proxy evidence, so the defect is source-reproducible with high confidence. Is this the best way to solve the issue? No: provider-level headers remain the correct delivery seam, but this branch is not the best merge-ready form because it predates current OAuth default-model selection and must compose with it rather than replace it. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a26df7153f81. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (30 earlier review cycles; latest 8 shown)
|
|
@clawsweeper automerge |
|
🦞✅ Source: Why human review is needed: What the maintainer can do as a next step: I added |
|
@clawsweeper approve |
|
@Takhoffman it seems claw sweeper died mid-review and never actually merged this PR |
1166ddc to
6b57d1d
Compare
|
🦞✅ Source: Why human review is needed: What the maintainer can do as a next step: I added |
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix(xai): Grok subscription inference fails with HTTP 426 on every request This is item 1/1 in the current shard. Shard 9/44. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
|
ClawSweeper 🐠 reef update Thanks for the contribution here. ClawSweeper could not safely push to this branch, so it opened a replacement PR from a writable branch and carried the contributor trail along with it. Why replacement: ClawSweeper could not update the source PR branch directly; GitHub did not grant sufficient push rights to the bot for that branch.
fish notes: reasoning high; reviewed against 6e1e9c5. |
Closes #113662
What Problem This Solves
Fixes an issue where users signed in to xAI with the Grok subscription (OAuth) could not run a single agent turn: every inference request returned HTTP 426 and the model never replied.
The failure is silent up to the first turn. Provider setup,
models list, and model discovery all succeed, because xAI gates only the inference endpoint. Users see a healthy, fully configured xAI provider and then an opaque 426 on their first message.Reproduced live against
https://cli-chat-proxy.grok.com/v1/responseswith a valid xAI OAuth bearer token:(none)is the literal client version the proxy read off the request. OpenClaw sends no client-version header on this route at all.Why This Change Was Made
extensions/xai/provider-catalog.tsbuilds the Grok OAuth provider (buildLiveXaiOAuthProvider,buildXaiOAuthFallbackProvider) withbaseUrl/api/auth/modelsand noheaders. The only place the xAI plugin adds client identity isxaiUserAgentHeaderFor()inextensions/xai/src/xai-user-agent.ts, which deliberately returns{}for every host outsideXAI_NATIVE_API_HOSTS = new Set(["api.x.ai"])and is only wired intotts.ts,realtime-voice-bridge.ts, andrealtime-transcription-provider.ts— never the text-inference path. So the OAuth proxy receives nothing.The fix attaches
x-grok-client-versionas a provider-level static header on the two Grok OAuth provider configs only, next toXAI_GROK_OAUTH_BASE_URL. Design notes:xaiUserAgentHeaderFor. Extending theapi.x.aihost allowlist there would not fix the bug (that helper is not on the inference path) and would blur its stated purpose of withholding OpenClaw identity from user-configured proxies. Putting the header on the provider config that ownscli-chat-proxy.grok.comkeeps the scope exact: the API-key route (https://api.x.ai/v1) is untouched and stays header-free, which the tests assert.headersis the existing seam, and it reaches the wire.MODEL_PROVIDER_CONFIG_KEYSinsrc/plugins/provider-catalog-result.tsretainsheaderswhen projecting a plugin catalog result into provider config;buildInlineProviderModels(src/agents/embedded-agent-runner/model.inline-provider.ts) folds them throughresolveProviderRequestConfiginto each runtime model, andModelRegistry.getApiKeyAndHeaders(src/agents/sessions/model-registry.ts) merges them into the outbound request.extensions/kimi-coding/provider-catalog.tsalready uses exactly this seam to satisfy a vendor-gated endpoint.0.1.202is the minimum xAI's proxy currently names in its own 426 body. It is a compatibility floor from an external service, so it needs a comment and a single place to bump, not a scattered literal.buildXaiOAuthFallbackProvider()is the path taken when live discovery fails, and it still routes inference to the same gated proxy, so omitting the header there would leave a live 426 path behind.buildLiveXaiOAuthProvider()now destructures that fallback (const { models, ...providerConfig }) instead of pickingbaseUrl/api/auth, which is the same shapebuildOpenAICompatibleLiveModelProviderConfiguses. The live path therefore cannot silently drop a provider-level setting the fallback declares.headerssurvive an operator'smodels.providers.xai.baseUrloverride, becausemergeImplicitProviderConfig(src/agents/models-config.providers.implicit.ts:271) merges as{ ...implicit, ...existing }andxaihas no entry inPROVIDER_IMPLICIT_MERGERS: the operator'sbaseUrlwins while the catalog'sheaderssurvive. The catalog now reads that override fromctx.configand withholds the header whenever the effective route is nothttps://cli-chat-proxy.grok.com/v1, so a custom proxy never receives vendor identity it did not ask for. Tests cover the override, the canonical-pin case, and the untouched API-key route.Non-goal: this does not add a config option. The value is dictated by xAI, not by the operator, and
AGENTS.mdsets a high bar for new config surface.Accepted tradeoff: if an operator overrides
models.providers.xai.baseUrlwhile on the OAuth route, this constant version string follows to that base URL. It carries no identity or secret — it is a Grok CLI compatibility token — and adding a second host allowlist to guard a version literal would cost more surface than it protects.User Impact
xAI OAuth / Grok subscription users can actually use the provider. Before this change, every inference request on that route failed with HTTP 426 and the only workaround was switching to a paid API key, which defeats the purpose of the subscription path. API-key users on
api.x.aiare unaffected — no new header is sent there.Evidence
Live HTTP proof (valid xAI OAuth bearer token, redacted;
POST https://cli-chat-proxy.grok.com/v1/responses):x-grok-client-version: 0.1.202Your Grok CLI version (none) is outdated...User-Agent: grok-cli/0.1.202version (none)x-grok-cli-version: 0.1.202version (none)x-client-version: 0.1.202version (none)x-app-version: 0.1.202version (none)grok-cli-version: 0.1.202version (none)x-grok-version: 0.1.202version (none)x-cli-version: 0.1.202version (none)grok-version: 0.1.202version (none)x-grok-cli: 0.1.202version (none)Verbatim 426 body:
x-grok-client-versionis the only name the proxy reads; every other candidate still reportsversion (none)./v1/modelsis not gated.GET https://cli-chat-proxy.grok.com/v1/modelssucceeds without the header on the same token. That is why discovery, catalog, and setup all look healthy while inference is dead — and why this bug does not surface until the user's first message.Local validation (Ubuntu 24.04.3, Node 24.16.0, source checkout at
main):New tests in
extensions/xai/provider-catalog.test.tscover the live-discovery OAuth provider, the discovery-failure fallback provider, and a negative assertion that the API-keyapi.x.airoute still carries no Grok CLI header. They drivebuildLiveXaiOAuthProviderthrough its injectedfetchGuard, so no network or module-barrel mocking is involved.Proof gaps, stated plainly:
401 Invalid or expired credentialsfor every header variant, with or withoutx-grok-client-version. The 426 evidence above comes from a run with a valid OAuth token. The endpoint's reachability and the auth-before-version-check ordering are reproducible without credentials.src/plugins/provider-catalog-result.ts,src/agents/embedded-agent-runner/model.inline-provider.ts, andsrc/agents/sessions/model-registry.ts, and by the shipped precedent inextensions/kimi-coding/provider-catalog.ts.