Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions apps/server/scripts/acp-mock-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,17 @@ function modeState(): AcpSchema.SessionModeState {
};
}

// Mirrors the real Grok ACP: it only accepts "grok-4.6"/"grok-4.5" as
// modelIds, never the CLI's own "grok-build" product name (see #7791).
const grokAcpModels: ReadonlyArray<AcpSchema.ModelInfo> = [
{ modelId: "grok-build", name: "Grok Build" },
{ modelId: "grok-4.6", name: "Grok 4.6" },
{ modelId: "grok-mock-alt", name: "Grok Mock Alt" },
];

function modelState(): AcpSchema.SessionModelState {
const modelId = grokAcpModels.some((model) => model.modelId === currentModelId)
? currentModelId
: "grok-build";
: "grok-4.6";
return {
currentModelId: modelId,
availableModels: grokAcpModels,
Expand Down
7 changes: 5 additions & 2 deletions apps/server/src/provider/acp/GrokAcpSupport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ import {

describe("resolveGrokAcpBaseModelId", () => {
it("normalizes empty and custom Grok model ids", () => {
expect(resolveGrokAcpBaseModelId(undefined)).toBe("grok-build");
expect(resolveGrokAcpBaseModelId(" ")).toBe("grok-build");
// "grok-build" is the CLI's product name, not a modelId its ACP accepts —
// it must resolve to a real model alias, not pass through verbatim.
expect(resolveGrokAcpBaseModelId(undefined)).toBe("grok-4.6");
expect(resolveGrokAcpBaseModelId(" ")).toBe("grok-4.6");
expect(resolveGrokAcpBaseModelId("grok-build")).toBe("grok-4.6");
expect(resolveGrokAcpBaseModelId(" grok-test-custom-model ")).toBe("grok-test-custom-model");
});
});
Expand Down
8 changes: 8 additions & 0 deletions packages/contracts/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,14 @@ export const MODEL_SLUG_ALIASES_BY_PROVIDER: Partial<
"opus-4.5-thinking": "claude-opus-4-5",
"opus-4.5": "claude-opus-4-5",
},
[GROK_DRIVER_KIND]: {
// "grok-build" is the Grok Build CLI's own product name, not a model id
// its ACP accepts — sending it verbatim as `session/set_model`'s modelId
// fails with "unknown model id". Grok's ACP only knows "grok-4.6" and
// "grok-4.5"; alias the default/display slug to the current one so the
// wire-level id is always valid.
"grok-build": "grok-4.6",
},
[OPENCODE_DRIVER_KIND]: {},
};

Expand Down
6 changes: 6 additions & 0 deletions packages/shared/src/model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,10 @@ describe("model slug normalization", () => {
expect(normalizeModelSlug("opus", claude)).toBe("claude-opus-5");
expect(normalizeCustomModelSlug(" opus ")).toBe("opus");
});

it("aliases Grok's product-name slug to a modelId its ACP accepts", () => {
const grok = ProviderDriverKind.make("grok");

expect(normalizeModelSlug("grok-build", grok)).toBe("grok-4.6");
});
});
Loading