Skip to content

fix(providers): route unknown grok-cli ids through the Responses wire format - #14583

Merged
diegosouzapw merged 2 commits into
cheaper-inference:release/v3.8.51from
VIPKaiser:fix/grok-cli-passthrough-responses-format
Sep 24, 2026
Merged

diegosouzapw merged 2 commits into
cheaper-inference:release/v3.8.51from
VIPKaiser:fix/grok-cli-passthrough-responses-format

Conversation

@VIPKaiser

Copy link
Copy Markdown
Contributor

Problem

grok-cli/<id> for any model id that is not in the static grok-cli seed (e.g. grok-4.7 on its release day, grok-4.7-build-fast) gets HTTP 400 from Grok Build until the connection has run a model sync.

  • GrokCliExecutor always POSTs to Grok Build's /v1/responses, and live discovery only keeps responses backends, so every grok-cli model is a Responses model.
  • But getModelTargetFormat("gc", id) returns null for ids missing from the seed, so resolveChatCoreTargetFormat falls back to the provider format ("openai") and the translator builds a chat-completions body (messages / max_tokens) that is posted to /v1/responses.
  • Seeded ids (grok-4.5 / 4.6) work only because they carry targetFormat: "openai-responses" explicitly.

Observed live on release/v3.8.51: grok-cli/grok-4.7 returned 400 on both pooled accounts (the upstream still echoed x-grok-context-window: 500000, so the model itself was recognised) while grok-cli/grok-4.6 succeeded. After a sync, the synced entry's apiFormat: "responses" masks the bug, but connections that never synced (existing ones; new ones before the first sync) keep hitting it.

Fix

One fallback in getModelTargetFormat, next to the existing openai *-pro heuristic (#5842): for the gc alias, return "openai-responses" when the seed has no explicit tag. The registry entry's format: "openai" is left alone on purpose (its comment keeps the generic translate-path contract stable).

  • Seeded ids keep their explicit targetFormat (unchanged).
  • xai / xai-oauth unknown ids still return null (their executors choose /chat/completions vs /responses themselves).

Relationship to open PRs

Complementary, no file overlap:

Tests

  • New tests/unit/grok-cli-passthrough-responses-format.test.ts: alias and provider-id lookups for unknown ids, seeded ids unchanged, resolveChatCoreTargetFormat end-to-end for an unsynced id, and a negative check that xai / xai-oauth are unaffected.
  • Existing grok-cli-*, *target-format*, xai*, chatcore-upstream-body suites: 287 + 38 pass locally. Typecheck and lint clean for the touched files.

A changelog fragment will follow once the PR number is assigned.

GrokCliExecutor always POSTs to Grok Build's /v1/responses, and live
discovery only keeps `responses` backends, but getModelTargetFormat()
returned null for any id missing from the static seed. chatCore then fell
back to the provider format ("openai") and sent a chat-completions body,
which Grok Build rejects with HTTP 400. That broke grok-4.7 on release day
for every connection that had not run a model sync yet.

Scoped to the grok-cli alias; seeded ids keep their explicit tags and
xai / xai-oauth unknown ids are unchanged.
@diegosouzapw

Copy link
Copy Markdown
Collaborator

Nice catch — the live 400 you observed on release/v3.8.51 (with the upstream echoing the
context-window header, confirming the model itself was fine) makes a strong case, and the fix
mirrors the existing *-pro heuristic pattern closely. The negative test for xai/xai-oauth
staying null is a good touch — it proves the scoping claim rather than just asserting it. No
file overlap with #14525 or #14237, so all three can land independently. Couldn't get a
dedicated live test run in during this pass due to heavy shared-devbox contention; marking
PLAUSIBLE on that basis. Merge-ready.

@diegosouzapw
diegosouzapw merged commit f2293e9 into cheaper-inference:release/v3.8.51 Sep 24, 2026
3 checks passed
deptrai pushed a commit to deptrai/OmniRoute that referenced this pull request Sep 28, 2026
… format (cheaper-inference#14583)

Validated in the round-3 combined board (release/v3.8.51 @ e3b152badd + 59 PRs, gates on the 192.168.0.113 box): typecheck/open-sse/dashboard typecheck, complexity, cognitive, changelog integrity, route-validation, docs-counts, cycles, changed node:test files and vitest green except the inherited base-reds tracked in cheaper-inference#14496/cheaper-inference#14547 and file-size ratchet drift (rebaselined in a follow-up).

Thanks @VIPKaiser!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants