Skip to content

Commit d539bd6

Browse files
committed
fix(xai): declare grok image input so combos are not advertised text-only
xAI's registry entry had no modelInputModalities, so catalog rows for xai/grok-4.5 carried inputModalities: undefined. deriveComboCatalogModel intersects member modalities and defaults an undefined member to ["text"], so every combo containing an xAI target was published to Codex with input_modalities ["text"]. The Codex app gates attachments client-side on that field, so images were rejected before a request was ever routed, even though both combo members accept images. This was visible with the documented xai -> cursor grok-4.5 failover combo: cursor/grok-4.5 advertised ["text","image"] (via the noVisionModels sidecar augmentation in applyProviderConfigHints) while xai/grok-4.5 advertised nothing, and the resulting combo collapsed to text-only. Declare the vision lineup for the grok-4.x chat models per docs.x.ai model capabilities. grok-build-0.1 and grok-composer-2.5-fast are intentionally omitted; they remain in noVisionModels. Intersection semantics are unchanged: a member whose modalities are unknown still narrows a combo to text, which the added regression test pins.
1 parent 0ebb8fc commit d539bd6

2 files changed

Lines changed: 71 additions & 0 deletions

File tree

‎src/providers/registry.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,18 @@ export const PROVIDER_REGISTRY: readonly ProviderRegistryEntry[] = [
390390
// transport returns 400 ("Multi Agent requests are not allowed on chat completions").
391391
models: ["grok-4.5", "grok-4.3", "grok-4.20-0309-reasoning", "grok-4.20-0309-non-reasoning", "grok-build-0.1", "grok-composer-2.5-fast"],
392392
defaultModel: "grok-4.5",
393+
// Vision lineup per docs.x.ai model-capabilities/images/understanding: the grok-4.x chat
394+
// models accept image input (JPEG/PNG, URL or base64). Without this the catalog leaves
395+
// inputModalities undefined, and deriveComboCatalogModel defaults an undefined member to
396+
// ["text"] — so any combo containing an xAI target is advertised to Codex as text-only and
397+
// the app blocks attachments client-side. grok-build-0.1 / grok-composer-2.5-fast stay out
398+
// (they are already listed in noVisionModels below).
399+
modelInputModalities: {
400+
"grok-4.5": ["text", "image"],
401+
"grok-4.3": ["text", "image"],
402+
"grok-4.20-0309-reasoning": ["text", "image"],
403+
"grok-4.20-0309-non-reasoning": ["text", "image"],
404+
},
393405
noReasoningModels: ["grok-4.20-0309-non-reasoning", "grok-build-0.1", "grok-composer-2.5-fast"],
394406
// Replay assistant reasoning_content for grok reasoning models: xAI documents dropped
395407
// reasoning_content as the top cause of prompt-cache misses on multi-turn conversations

‎tests/catalog-vision-sidecar-modalities.test.ts‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import { afterEach, describe, expect, test } from "bun:test";
22
import { applyProviderConfigHints, gatherRoutedModels } from "../src/codex/catalog";
33
import { clearModelCache } from "../src/codex/model-cache";
44
import type { OcxProviderConfig } from "../src/types";
5+
import { deriveComboCatalogModel } from "../src/codex/catalog";
6+
import { PROVIDER_REGISTRY } from "../src/providers/registry";
7+
import type { CatalogModel } from "../src/types";
58

69
const base: OcxProviderConfig = {
710
adapter: "openai-chat",
@@ -142,3 +145,59 @@ describe("vision-sidecar custom-model override (#349/#344)", () => {
142145
}
143146
});
144147
});
148+
149+
describe("vision-capable provider models feed combo modalities", () => {
150+
// Regression: xAI declared no modelInputModalities, so xai/grok-4.5 reached
151+
// deriveComboCatalogModel with inputModalities undefined. The combo aggregator
152+
// defaults an undefined member to ["text"], so every combo containing an xAI
153+
// target was advertised to Codex as text-only and the app refused image
154+
// attachments client-side before any request was made.
155+
test("xAI grok chat models declare image input in the registry", () => {
156+
const xai = PROVIDER_REGISTRY.find(entry => entry.id === "xai");
157+
expect(xai?.modelInputModalities?.["grok-4.5"]).toEqual(["text", "image"]);
158+
// Text-only members stay out of the vision map (they are already in noVisionModels).
159+
expect(xai?.modelInputModalities?.["grok-build-0.1"]).toBeUndefined();
160+
expect(xai?.noVisionModels).toContain("grok-build-0.1");
161+
});
162+
163+
test("a combo of two vision-capable members still advertises image", () => {
164+
const member = (provider: string, contextWindow: number): CatalogModel => ({
165+
provider,
166+
id: "grok-4.5",
167+
contextWindow,
168+
inputModalities: ["text", "image"],
169+
} as CatalogModel);
170+
const derived = deriveComboCatalogModel(
171+
"xai_grok_fallback",
172+
{
173+
targets: [
174+
{ provider: "xai", model: "grok-4.5" },
175+
{ provider: "cursor", model: "grok-4.5" },
176+
],
177+
defaultEffort: "high",
178+
} as never,
179+
[member("xai", 500_000), member("cursor", 200_000)],
180+
);
181+
expect(derived?.inputModalities).toEqual(["text", "image"]);
182+
});
183+
184+
test("a member with unknown modalities still narrows the combo to text", () => {
185+
// Intersection semantics are intentional: a member we cannot prove is
186+
// vision-capable must not let the combo advertise image input.
187+
const derived = deriveComboCatalogModel(
188+
"mixed",
189+
{
190+
targets: [
191+
{ provider: "xai", model: "grok-4.5" },
192+
{ provider: "other", model: "text-only" },
193+
],
194+
defaultEffort: "high",
195+
} as never,
196+
[
197+
{ provider: "xai", id: "grok-4.5", contextWindow: 500_000, inputModalities: ["text", "image"] } as CatalogModel,
198+
{ provider: "other", id: "text-only", contextWindow: 100_000 } as CatalogModel,
199+
],
200+
);
201+
expect(derived?.inputModalities).toEqual(["text"]);
202+
});
203+
});

0 commit comments

Comments
 (0)