@devries-cameron20 / t3code-1 / commits / 57e92b0b98
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(cursor): Max Mode tiers keep working after Cursor changes a model (#39453)

Co-authored-by: Cursor <cursoragent@cursor.com>

Yash Singh committed Nov 19, 2026 at 18:46 UTC 57e92b0b98725a2e4ea60790f550b1915b0ac8c2
5 files changed +91 -13
packages/provider-cursor/src/server/adapter.ts
+6 -1
@@ -4,6 +4,7 @@ import type {
4 InteractionUpdate,
5 McpServerConfig,
6 RunResult,
7 + SDKModel,
8 SDKUserMessage,
9 SettingSource,
10 ToolCall,
@@ -309,6 +310,7 @@ export function makeCursorAgentOptions(input: {
310 readonly apiKey?: string;
311 readonly modelSelection: ModelSelection;
312 readonly models?: ReadonlyArray<ServerProviderModel>;
313 + readonly sdkModels?: ReadonlyArray<SDKModel>;
314 readonly runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy;
315 readonly threadId: ThreadId;
316 readonly mcpSession: McpProviderSession.McpProviderSessionConfig | undefined;
@@ -317,7 +319,7 @@ export function makeCursorAgentOptions(input: {
319 const policy = cursorRuntimeAgentPolicy(input.runtimePolicy, input.platform);
320 const mcpServers = cursorMcpServers(input.mcpSession);
321 return {
320 - model: cursorSdkModelSelection(input.modelSelection, input.models),
322 + model: cursorSdkModelSelection(input.modelSelection, input.models, input.sdkModels),
323 name: `T3 Code ${input.threadId}`,
324 mode: input.runtimePolicy.interactionMode === "plan" ? "plan" : "agent",
325 ...(input.apiKey === undefined ? {} : { apiKey: input.apiKey }),
@@ -1017,6 +1019,7 @@ export interface CursorAdapterV2Options {
1019 readonly instanceId: ProviderInstanceId;
1020 readonly environment: NodeJS.ProcessEnv;
1021 readonly getModels?: () => ReadonlyArray<ServerProviderModel>;
1022 + readonly getSdkModels?: () => ReadonlyArray<SDKModel>;
1023 }
1024
1025 export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
@@ -2548,6 +2551,7 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
2551 ...(apiKey === undefined ? {} : { apiKey }),
2552 modelSelection: openInput.modelSelection,
2553 models: adapterOptions.getModels?.() ?? [],
2554 + sdkModels: adapterOptions.getSdkModels?.() ?? [],
2555 runtimePolicy: openInput.runtimePolicy,
2556 platform,
2557 threadId: openInput.threadId,
@@ -2775,6 +2779,7 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
2779 model: cursorSdkModelSelection(
2780 turnInput.modelSelection,
2781 adapterOptions.getModels?.() ?? [],
2782 + adapterOptions.getSdkModels?.() ?? [],
2783 ),
2784 mode: turnInput.runtimePolicy.interactionMode === "plan" ? "plan" : "agent",
2785 ...(Object.keys(turnMcpServers).length === 0
packages/provider-cursor/src/server/driver.ts
+17
@@ -4,6 +4,7 @@ import {
4 type ServerProviderModel,
5 } from "@t3tools/contracts";
6 import { CursorSettings } from "../settings.ts";
7 +import type { SDKModel } from "@cursor/sdk";
8 import * as Effect from "effect/Effect";
9 import * as SecureRandom from "effect/crypto/SecureRandom";
10 import * as FileSystem from "effect/FileSystem";
@@ -164,10 +165,12 @@ export const CursorDriver: ProviderDriver<
165 });
166
167 let catalogModels: ReadonlyArray<ServerProviderModel> = [];
168 + let catalogSdkModels: ReadonlyArray<SDKModel> = [];
169 const orchestrationAdapter = yield* makeCursorAdapterV2({
170 instanceId,
171 environment: processEnv,
172 getModels: () => catalogModels,
173 + getSdkModels: () => catalogSdkModels,
174 }).pipe(
175 Effect.provideService(CursorAgentSdk.CursorAgentSdkRunner, {
176 ...sdkRunner,
@@ -211,6 +214,7 @@ export const CursorDriver: ProviderDriver<
214 auth.requireApiKey,
215 auth.withAccess,
216 () => catalogModels,
217 + () => catalogSdkModels,
218 );
219
220 const checkProvider = auth.readApiKey.pipe(
@@ -250,6 +254,19 @@ export const CursorDriver: ProviderDriver<
254 }
255 }),
256 ),
257 + Effect.provideServiceEffect(
258 + CursorSdkCatalog.CursorSdkCatalog,
259 + Effect.map(CursorSdkCatalog.CursorSdkCatalog, (catalog) =>
260 + CursorSdkCatalog.CursorSdkCatalog.of({
261 + // Untraced: CursorSdkCatalog.read already spans this call.
262 + read: Effect.fnUntraced(function* (apiKey) {
263 + const snapshot = yield* catalog.read(apiKey);
264 + if (snapshot.models.length > 0) catalogSdkModels = snapshot.models;
265 + return snapshot;
266 + }),
267 + }),
268 + ),
269 + ),
270 Effect.provide(CursorSdkCatalog.layer),
271 Effect.provideService(HttpClient.HttpClient, httpClient),
272 );
packages/provider-cursor/src/server/sdkModel.test.ts
+33
@@ -65,6 +65,39 @@ describe("cursorSdkModelSelection", () => {
65 });
66 });
67
68 + it.each([
69 + { context: undefined, maxMode: true },
70 + { context: "1m", maxMode: true },
71 + { context: "300k", maxMode: undefined },
72 + ])("sets Max Mode from the catalog for context $context", ({ context, maxMode }) => {
73 + const sdkModels = [
74 + {
75 + id: "gemini-4-neon",
76 + displayName: "Gemini 4 Neon",
77 + parameters: [{ id: "context", values: [{ value: "300k" }, { value: "1m" }] }],
78 + variants: [
79 + { displayName: "300K", params: [{ id: "context", value: "300k" }] },
80 + {
81 + displayName: "1M",
82 + isDefault: true,
83 + isMaxMode: true,
84 + params: [{ id: "context", value: "1m" }],
85 + },
86 + ],
87 + },
88 + ];
89 + const selection = cursorSdkModelSelection(
90 + {
91 + instanceId,
92 + model: "gemini-4-neon",
93 + ...(context === undefined ? {} : { options: [{ id: "contextWindow", value: context }] }),
94 + },
95 + buildCursorDiscoveredModelsFromSdk(sdkModels),
96 + sdkModels,
97 + );
98 + expect(selection.maxMode).toBe(maxMode);
99 + });
100 +
101 it("sends no parameters for a model missing from the catalog", () => {
102 expect(cursorSdkModelSelection({ instanceId, model: "auto" }, models)).toEqual({
103 id: "default",
packages/provider-cursor/src/server/sdkModel.ts
+32 -10
@@ -1,4 +1,8 @@
1 -import type { ModelSelection as CursorSdkModelSelection, ModelParameterValue } from "@cursor/sdk";
1 +import type {
2 + ModelSelection as CursorSdkModelSelection,
3 + ModelParameterValue,
4 + SDKModel,
5 +} from "@cursor/sdk";
6 import type { ModelSelection, ServerProviderModel } from "@t3tools/contracts";
7 import { getProviderOptionCurrentValue } from "@t3tools/shared/model";
8
@@ -55,9 +59,27 @@ export function cursorContextWindowTokens(
59 return Number.isSafeInteger(tokens) && tokens > 0 ? tokens : undefined;
60 }
61
62 +// The SDK infers Max Mode from a model list it never refreshes, so pass it from T3's fresher catalog.
63 +function cursorSdkMaxMode(
64 + sdkModel: SDKModel | undefined,
65 + params: ReadonlyArray<ModelParameterValue>,
66 +): boolean {
67 + if (params.length === 0) return false;
68 + const variants = (sdkModel?.variants ?? []).filter((variant) =>
69 + params.every((param) =>
70 + variant.params.some(
71 + (candidate) =>
72 + candidate.id.trim() === param.id.trim() && candidate.value.trim() === param.value.trim(),
73 + ),
74 + ),
75 + );
76 + return variants.length > 0 && variants.every((variant) => variant.isMaxMode === true);
77 +}
78 +
79 export function cursorSdkModelSelection(
80 modelSelection: ModelSelection,
81 models: ReadonlyArray<ServerProviderModel> = [],
82 + sdkModels: ReadonlyArray<SDKModel> = [],
83 ): CursorSdkModelSelection {
84 const explicit = modelSelection.options ?? [];
85 const descriptors =
@@ -69,16 +91,16 @@ export function cursorSdkModelSelection(
91 const value = descriptor.id === "fastMode" ? false : getProviderOptionCurrentValue(descriptor);
92 return value === undefined ? [] : [{ id: descriptor.id, value }];
93 });
72 - const options = [...explicit, ...defaults];
94 + const params = [...explicit, ...defaults].map((option): ModelParameterValue => ({
95 + id: cursorSdkParameterId(option.id),
96 + value: String(option.value),
97 + }));
98 + const sdkModel = sdkModels.find(
99 + (model) => model.id === modelSelection.model || model.aliases?.includes(modelSelection.model),
100 + );
101 return {
102 id: modelSelection.model === "auto" ? "default" : modelSelection.model,
75 - ...(options.length === 0
76 - ? {}
77 - : {
78 - params: options.map((option): ModelParameterValue => ({
79 - id: cursorSdkParameterId(option.id),
80 - value: String(option.value),
81 - })),
82 - }),
103 + ...(params.length === 0 ? {} : { params }),
104 + ...(cursorSdkMaxMode(sdkModel, params) ? { maxMode: true } : {}),
105 };
106 }
packages/provider-cursor/src/server/textGeneration.ts
+3 -2
@@ -1,6 +1,6 @@
1 import * as FileSystem from "effect/FileSystem";
2
3 -import type { AgentOptions, RunResult } from "@cursor/sdk";
3 +import type { AgentOptions, RunResult, SDKModel } from "@cursor/sdk";
4 import * as Effect from "effect/Effect";
5 import * as Schema from "effect/Schema";
6
@@ -55,6 +55,7 @@ export const makeCursorTextGeneration = Effect.fn("makeCursorTextGeneration")(fu
55 resolveApiKey?: Effect.Effect<string, ProviderSetupError>,
56 withAccess?: CursorAuth["withAccess"],
57 getModels?: () => ReadonlyArray<ServerProviderModel>,
58 + getSdkModels?: () => ReadonlyArray<SDKModel>,
59 ) {
60 const fs = yield* FileSystem.FileSystem;
61 const sdk = yield* CursorSdk.CursorSdk;
@@ -121,7 +122,7 @@ export const makeCursorTextGeneration = Effect.fn("makeCursorTextGeneration")(fu
122 const agentOptions = {
123 apiKey,
124 mode: "plan",
124 - model: cursorSdkModelSelection(modelSelection, getModels?.() ?? []),
125 + model: cursorSdkModelSelection(modelSelection, getModels?.() ?? [], getSdkModels?.() ?? []),
126 local: {
127 cwd,
128 store,