Skip to content

Commit 9677a8b

Browse files
chasehuhcursoragent
andcommitted
fix(cursor): accept trailing -fast Grok wire ids
Cursor GetUsableModels now returns grok-4.5-{effort}-fast instead of grok-4.5-fast-{effort}, so live discovery dropped Fast and requests used not_found wire ids. Match both shapes and emit the trailing-fast form. Co-authored-by: Cursor <[email protected]>
1 parent d1f544b commit 9677a8b

5 files changed

Lines changed: 46 additions & 9 deletions

File tree

‎src/adapters/cursor/discovery.ts‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,28 @@ function stripCursorWirePrefix(id: string): string {
6767
/**
6868
* True when a configured Cursor base model should remain exposed after live GetUsableModels filtering.
6969
* Live ids are full effort-suffixed variants (`claude-4.6-opus-high`); base ids match exactly or by prefix.
70+
*
71+
* Fast families currently use a trailing mode marker after the effort tier
72+
* (`grok-4.5-high-fast`) rather than the older `{base}-fast-{effort}` form
73+
* (`grok-4.5-fast-high`). Accept both so live discovery does not drop Fast when
74+
* Cursor only returns the trailing-fast wire ids.
7075
*/
7176
export function isCursorModelAvailableForAccount(modelId: string, liveIds: readonly string[]): boolean {
7277
return liveIds.some(raw => {
7378
const id = stripCursorWirePrefix(raw);
7479
if (id === modelId) return true;
7580
const effortPrefix = `${modelId}-`;
76-
return id.startsWith(effortPrefix) && CANONICAL_EFFORT_SUFFIXES.has(id.slice(effortPrefix.length));
81+
if (id.startsWith(effortPrefix) && CANONICAL_EFFORT_SUFFIXES.has(id.slice(effortPrefix.length))) {
82+
return true;
83+
}
84+
// `{stem}-fast` base ↔ `{stem}-{effort}-fast` wire (current Cursor GetUsableModels shape).
85+
if (modelId.endsWith("-fast") && id.endsWith("-fast")) {
86+
const stem = modelId.slice(0, -"-fast".length);
87+
if (!id.startsWith(`${stem}-`)) return false;
88+
const middle = id.slice(stem.length + 1, -"-fast".length);
89+
return CANONICAL_EFFORT_SUFFIXES.has(middle);
90+
}
91+
return false;
7792
});
7893
}
7994

‎src/adapters/cursor/effort-map.ts‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ const CURSOR_MODEL_EFFORT_TIERS: Record<string, readonly string[]> = {
2727
"claude-opus-5": ["low", "medium", "high", "xhigh", "max"],
2828
"claude-sonnet-5": ["low", "medium", "high", "xhigh", "max"],
2929
"glm-5.2": ["high", "max"],
30-
// GetUsableModels (2026-07-09) lists grok-4.5-{medium,high,xhigh} and grok-4.5-fast-{medium,high,xhigh};
31-
// the bare "grok-4.5-fast" id was removed upstream and now returns not_found.
30+
// GetUsableModels currently lists grok-4.5-{low,medium,high} and grok-4.5-{low,medium,high}-fast.
31+
// Older snapshots used grok-4.5-fast-{medium,high,xhigh}; wire construction prefers the trailing
32+
// `-fast` form (see cursorWireModelIdWithEffort). The bare "grok-4.5-fast" id still returns not_found.
3233
"grok-4.5": ["medium", "high", "xhigh"],
3334
"grok-4.5-fast": ["medium", "high", "xhigh"],
3435
"gpt-5.1": ["low", "high"],
@@ -110,3 +111,17 @@ export function cursorModelEffortLadder(baseModelId: string): string[] | undefin
110111
export function cursorModelHasEffortTiers(baseModelId: string): boolean {
111112
return (CURSOR_MODEL_EFFORT_TIERS[baseModelId]?.length ?? 0) > 0;
112113
}
114+
115+
/**
116+
* Compose a Cursor wire model id from a Codex-facing base id and an effort tier.
117+
*
118+
* Fast families encode the mode after the effort (`grok-4.5-high-fast`). Non-fast
119+
* reasoning models keep the historical `{base}-{effort}` shape (`claude-opus-4-8-high`).
120+
*/
121+
export function cursorWireModelIdWithEffort(baseModelId: string, effortSuffix: string): string {
122+
if (baseModelId.endsWith("-fast")) {
123+
const stem = baseModelId.slice(0, -"-fast".length);
124+
return `${stem}-${effortSuffix}-fast`;
125+
}
126+
return `${baseModelId}-${effortSuffix}`;
127+
}

‎src/adapters/cursor/request-builder.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {
1010
import { isAllowedToolChoice, namespacedToolName, toolChoiceAliases, type OcxTool, type OcxToolChoice } from "../../types";
1111
import type { CursorRequestMessage, CursorRunRequest } from "./types";
1212
import { cursorWireModelSelection, type CursorRoutingLevel } from "./discovery";
13-
import { cursorEffortSuffix } from "./effort-map";
13+
import { cursorEffortSuffix, cursorWireModelIdWithEffort } from "./effort-map";
1414
import {
1515
cursorMcpToolEncodedSize,
1616
cursorMcpToolsEncodedSize,
@@ -127,7 +127,7 @@ function normalizeCursorModelId(modelId: string, reasoning?: string): { modelId:
127127
const selection = cursorWireModelSelection(modelId);
128128
const id = selection.modelId;
129129
const suffix = cursorEffortSuffix(id, reasoning);
130-
return { ...selection, modelId: suffix ? `${id}-${suffix}` : id };
130+
return { ...selection, modelId: suffix ? cursorWireModelIdWithEffort(id, suffix) : id };
131131
}
132132

133133
function contentPartToText(part: OcxContentPart | OcxAssistantContentPart): string | undefined {

‎tests/cursor-discovery.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ describe("Cursor discovery metadata", () => {
6363
// Issue #117: Cursor GetUsableModels may return ids with a `cursor-` wire prefix.
6464
expect(isCursorModelAvailableForAccount("grok-4.5", ["cursor-grok-4.5-high"])).toBe(true);
6565
expect(isCursorModelAvailableForAccount("grok-4.5-fast", ["cursor-grok-4.5-fast-medium"])).toBe(true);
66+
// Current Cursor wire shape puts `-fast` after the effort tier (`grok-4.5-high-fast`).
67+
expect(isCursorModelAvailableForAccount("grok-4.5-fast", ["cursor-grok-4.5-high-fast"])).toBe(true);
68+
expect(isCursorModelAvailableForAccount("grok-4.5-fast", ["cursor-grok-4.5-medium-fast"])).toBe(true);
69+
expect(isCursorModelAvailableForAccount("grok-4.5-fast", ["cursor-grok-4.5-high"])).toBe(false);
70+
expect(isCursorModelAvailableForAccount("grok-4.5", ["cursor-grok-4.5-high-fast"])).toBe(false);
6671
expect(isCursorModelAvailableForAccount("gpt-5.4", ["cursor-gpt-5.4-high"])).toBe(true);
6772
// Prefixed sibling rejection: cursor- prefix must not bypass sibling-model checks.
6873
expect(isCursorModelAvailableForAccount("gpt-5.5", ["cursor-gpt-5.5-extra-high"])).toBe(false);

‎tests/cursor-effort-suffix.test.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ describe("Cursor per-model reasoning-effort suffix", () => {
6060
expect(modelIdFor("cursor/glm-5.2", "max")).toBe("glm-5.2-max");
6161
});
6262

63-
test("grok-4.5-fast preserves its explicit code-backed tiers", () => {
64-
expect(modelIdFor("cursor/grok-4.5-fast", "medium")).toBe("grok-4.5-fast-medium");
65-
expect(modelIdFor("cursor/grok-4.5-fast", "high")).toBe("grok-4.5-fast-high");
66-
expect(modelIdFor("cursor/grok-4.5-fast", "xhigh")).toBe("grok-4.5-fast-xhigh");
63+
test("grok-4.5-fast uses trailing -fast after the effort tier on the wire", () => {
64+
// Live GetUsableModels returns grok-4.5-{low,medium,high}-fast, not grok-4.5-fast-{effort}.
65+
expect(modelIdFor("cursor/grok-4.5-fast", "medium")).toBe("grok-4.5-medium-fast");
66+
expect(modelIdFor("cursor/grok-4.5-fast", "high")).toBe("grok-4.5-high-fast");
67+
expect(modelIdFor("cursor/grok-4.5-fast", "xhigh")).toBe("grok-4.5-xhigh-fast");
68+
expect(modelIdFor("cursor/grok-4.5", "high")).toBe("grok-4.5-high");
6769
});
6870

6971
test("model ladders are deduped and sorted in canonical Codex order", () => {

0 commit comments

Comments
 (0)