The best way to control Claude Code, Codex and more from any computer or phone
[codex] preserve custom model slugs (#4168)
Maxwell Young committed
Jul 20, 2026 at 23:32 UTC
fa69f05b69d05003a6994194c12edd1d8aee080c
11 files changed
+88
-58
apps/server/src/provider/Layers/ClaudeProvider.ts
-5
@@ -2,7 +2,6 @@ import {
2
type ClaudeSettings,
3
type ModelCapabilities,
4
type ModelSelection,
5
- ProviderDriverKind,
5
type ServerProviderModel,
6
type ServerProviderSlashCommand,
7
} from "@t3tools/contracts";
@@ -44,7 +43,6 @@ const DEFAULT_CLAUDE_MODEL_CAPABILITIES: ModelCapabilities = createModelCapabili
43
optionDescriptors: [],
44
});
45
47
-const PROVIDER = ProviderDriverKind.make("claudeAgent");
46
const CLAUDE_PRESENTATION = {
47
displayName: "Claude",
48
showInteractionModeToggle: true,
@@ -691,7 +689,6 @@ export const checkClaudeProviderStatus = Effect.fn("checkClaudeProviderStatus")(
689
const checkedAt = DateTime.formatIso(yield* DateTime.now);
690
const allModels = providerModelsFromSettings(
691
BUILT_IN_MODELS,
694
- PROVIDER,
692
claudeSettings.customModels,
693
DEFAULT_CLAUDE_MODEL_CAPABILITIES,
694
);
@@ -782,7 +779,6 @@ export const checkClaudeProviderStatus = Effect.fn("checkClaudeProviderStatus")(
779
780
const models = providerModelsFromSettings(
781
getBuiltInClaudeModelsForVersion(parsedVersion),
785
- PROVIDER,
782
claudeSettings.customModels,
783
DEFAULT_CLAUDE_MODEL_CAPABILITIES,
784
);
@@ -851,7 +847,6 @@ export const makePendingClaudeProvider = (
847
const checkedAt = yield* nowIso;
848
const models = providerModelsFromSettings(
849
BUILT_IN_MODELS,
854
- PROVIDER,
850
claudeSettings.customModels,
851
DEFAULT_CLAUDE_MODEL_CAPABILITIES,
852
);
apps/server/src/provider/Layers/CursorProvider.ts
+1
-4
@@ -8,7 +8,6 @@ import type {
8
ServerProviderModel,
9
ServerProviderState,
10
} from "@t3tools/contracts";
11
-import { ProviderDriverKind } from "@t3tools/contracts";
11
import type * as EffectAcpSchema from "effect-acp/schema";
12
import { causeErrorTag } from "@t3tools/shared/observability";
13
import * as Crypto from "effect/Crypto";
@@ -51,7 +50,6 @@ import { CursorListAvailableModelsResponse } from "../acp/CursorAcpExtension.ts"
50
const decodeCursorListAvailableModelsResponse = Schema.decodeUnknownEffect(
51
CursorListAvailableModelsResponse,
52
);
54
-const PROVIDER = ProviderDriverKind.make("cursor");
53
const CURSOR_PRESENTATION = {
54
displayName: "Cursor",
55
badgeLabel: "Early Access",
@@ -576,7 +574,7 @@ export const discoverCursorModelsViaAcp = (
574
export function getCursorFallbackModels(
575
cursorSettings: Pick<CursorSettings, "customModels">,
576
): ReadonlyArray<ServerProviderModel> {
579
- return providerModelsFromSettings([], PROVIDER, cursorSettings.customModels, EMPTY_CAPABILITIES);
577
+ return providerModelsFromSettings([], cursorSettings.customModels, EMPTY_CAPABILITIES);
578
}
579
580
/** Timeout for `agent about` — it's slower than a simple `--version` probe. */
@@ -638,7 +636,6 @@ export function buildCursorProviderSnapshot(input: {
636
checkedAt: input.checkedAt,
637
models: providerModelsFromSettings(
638
input.discoveredModels ?? [],
641
- PROVIDER,
639
input.cursorSettings.customModels,
640
EMPTY_CAPABILITIES,
641
),
apps/server/src/provider/Layers/GrokProvider.ts
+1
-8
@@ -1,7 +1,6 @@
1
import {
2
type GrokSettings,
3
type ModelCapabilities,
4
- ProviderDriverKind,
4
type ServerProvider,
5
type ServerProviderModel,
6
} from "@t3tools/contracts";
@@ -38,7 +37,6 @@ const GROK_PRESENTATION = {
37
showInteractionModeToggle: false,
38
requiresNewThreadForModelChange: true,
39
} as const;
41
-const PROVIDER = ProviderDriverKind.make("grok");
40
const EMPTY_CAPABILITIES: ModelCapabilities = createModelCapabilities({
41
optionDescriptors: [],
42
});
@@ -98,12 +96,7 @@ function grokModelsFromSettings(
96
customModels: ReadonlyArray<string> | undefined,
97
builtInModels: ReadonlyArray<ServerProviderModel> = GROK_BUILT_IN_MODELS,
98
): ReadonlyArray<ServerProviderModel> {
101
- return providerModelsFromSettings(
102
- builtInModels,
103
- PROVIDER,
104
- customModels ?? [],
105
- EMPTY_CAPABILITIES,
106
- );
99
+ return providerModelsFromSettings(builtInModels, customModels ?? [], EMPTY_CAPABILITIES);
100
}
101
102
function buildGrokDiscoveredModelsFromSessionModelState(
apps/server/src/provider/Layers/OpenCodeProvider.ts
+3
-22
@@ -1,5 +1,4 @@
1
import {
2
- ProviderDriverKind,
2
type ModelCapabilities,
3
type OpenCodeSettings,
4
type ServerProviderModel,
@@ -25,7 +24,6 @@ import {
24
} from "../opencodeRuntime.ts";
25
import type { Agent, ProviderListResponse } from "@opencode-ai/sdk/v2";
26
28
-const PROVIDER = ProviderDriverKind.make("opencode");
27
const OPENCODE_PRESENTATION = {
28
displayName: "OpenCode",
29
showInteractionModeToggle: false,
@@ -259,7 +257,6 @@ export const makePendingOpenCodeProvider = (
257
const checkedAt = yield* Effect.map(DateTime.now, DateTime.formatIso);
258
const models = providerModelsFromSettings(
259
[],
262
- PROVIDER,
260
openCodeSettings.customModels,
261
DEFAULT_OPENCODE_MODEL_CAPABILITIES,
262
);
@@ -319,12 +316,7 @@ export const checkOpenCodeProviderStatus = Effect.fn("checkOpenCodeProviderStatu
316
presentation: OPENCODE_PRESENTATION,
317
enabled: openCodeSettings.enabled,
318
checkedAt,
322
- models: providerModelsFromSettings(
323
- [],
324
- PROVIDER,
325
- customModels,
326
- DEFAULT_OPENCODE_MODEL_CAPABILITIES,
327
- ),
319
+ models: providerModelsFromSettings([], customModels, DEFAULT_OPENCODE_MODEL_CAPABILITIES),
320
probe: {
321
installed: failure.installed,
322
version,
@@ -340,12 +332,7 @@ export const checkOpenCodeProviderStatus = Effect.fn("checkOpenCodeProviderStatu
332
presentation: OPENCODE_PRESENTATION,
333
enabled: false,
334
checkedAt,
343
- models: providerModelsFromSettings(
344
- [],
345
- PROVIDER,
346
- customModels,
347
- DEFAULT_OPENCODE_MODEL_CAPABILITIES,
348
- ),
335
+ models: providerModelsFromSettings([], customModels, DEFAULT_OPENCODE_MODEL_CAPABILITIES),
336
probe: {
337
installed: false,
338
version: null,
@@ -391,12 +378,7 @@ export const checkOpenCodeProviderStatus = Effect.fn("checkOpenCodeProviderStatu
378
presentation: OPENCODE_PRESENTATION,
379
enabled: openCodeSettings.enabled,
380
checkedAt,
394
- models: providerModelsFromSettings(
395
- [],
396
- PROVIDER,
397
- customModels,
398
- DEFAULT_OPENCODE_MODEL_CAPABILITIES,
399
- ),
381
+ models: providerModelsFromSettings([], customModels, DEFAULT_OPENCODE_MODEL_CAPABILITIES),
382
probe: {
383
installed: true,
384
version,
@@ -444,7 +426,6 @@ export const checkOpenCodeProviderStatus = Effect.fn("checkOpenCodeProviderStatu
426
427
const models = providerModelsFromSettings(
428
flattenOpenCodeModels(inventoryExit.value),
447
- PROVIDER,
429
customModels,
430
DEFAULT_OPENCODE_MODEL_CAPABILITIES,
431
);
apps/server/src/provider/providerSnapshot.test.ts
+20
-2
@@ -1,5 +1,5 @@
1
import { describe, expect, it } from "@effect/vitest";
2
-import { ProviderDriverKind, type ModelCapabilities } from "@t3tools/contracts";
2
+import type { ModelCapabilities } from "@t3tools/contracts";
3
import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
4
import { createModelCapabilities } from "@t3tools/shared/model";
5
import * as Effect from "effect/Effect";
@@ -38,7 +38,6 @@ describe("providerModelsFromSettings", () => {
38
it("applies the provided capabilities to custom models", () => {
39
const models = providerModelsFromSettings(
40
[],
41
- ProviderDriverKind.make("opencode"),
41
["openai/gpt-5"],
42
OPENCODE_CUSTOM_MODEL_CAPABILITIES,
43
);
@@ -52,6 +51,25 @@ describe("providerModelsFromSettings", () => {
51
},
52
]);
53
});
54
+
55
+ it("preserves a custom slug that collides with a provider alias", () => {
56
+ const capabilities = createModelCapabilities({ optionDescriptors: [] });
57
+ const models = providerModelsFromSettings(
58
+ [
59
+ {
60
+ slug: "claude-opus-4-8",
61
+ name: "Claude Opus 4.8",
62
+ isCustom: false,
63
+ capabilities,
64
+ },
65
+ ],
66
+ [" opus "],
67
+ capabilities,
68
+ );
69
+
70
+ expect(models.map((model) => model.slug)).toEqual(["claude-opus-4-8", "opus"]);
71
+ expect(models[1]?.isCustom).toBe(true);
72
+ });
73
});
74
75
describe("ProviderCommandNotFoundError", () => {
apps/server/src/provider/providerSnapshot.ts
+2
-3
@@ -13,7 +13,7 @@ import * as PlatformError from "effect/PlatformError";
13
import * as Schema from "effect/Schema";
14
import * as Stream from "effect/Stream";
15
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
16
-import { normalizeModelSlug } from "@t3tools/shared/model";
16
+import { normalizeCustomModelSlug } from "@t3tools/shared/model";
17
import { isWindowsCommandNotFound } from "../processRunner.ts";
18
import { createProviderVersionAdvisory } from "./providerMaintenance.ts";
19
import { collectUint8StreamText } from "../stream/collectUint8StreamText.ts";
@@ -140,7 +140,6 @@ export function parseGenericCliVersion(output: string): string | null {
140
141
export function providerModelsFromSettings(
142
builtInModels: ReadonlyArray<ServerProviderModel>,
143
- provider: ProviderDriverKind,
143
customModels: ReadonlyArray<string>,
144
customModelCapabilities: ModelCapabilities,
145
): ReadonlyArray<ServerProviderModel> {
@@ -149,7 +148,7 @@ export function providerModelsFromSettings(
148
const customEntries: ServerProviderModel[] = [];
149
150
for (const candidate of customModels) {
152
- const normalized = normalizeModelSlug(candidate, provider);
151
+ const normalized = normalizeCustomModelSlug(candidate);
152
if (!normalized || seen.has(normalized)) {
153
continue;
154
}
apps/web/src/components/settings/ProviderModelsSection.tsx
+2
-2
@@ -16,7 +16,7 @@ import {
16
type ProviderInstanceId,
17
type ServerProviderModel,
18
} from "@t3tools/contracts";
19
-import { normalizeModelSlug } from "@t3tools/shared/model";
19
+import { normalizeCustomModelSlug } from "@t3tools/shared/model";
20
21
import { cn } from "../../lib/utils";
22
import { sortModelsForProviderInstance } from "../../modelOrdering";
@@ -111,7 +111,7 @@ export function ProviderModelsSection({
111
}, [favoriteModelSet, modelOrder, models]);
112
113
const handleAdd = () => {
114
- const normalized = driverKind ? normalizeModelSlug(input, driverKind) : input.trim() || null;
114
+ const normalized = normalizeCustomModelSlug(input);
115
if (!normalized) {
116
setError("Enter a model slug.");
117
return;
apps/web/src/modelSelection.test.ts
+33
@@ -101,6 +101,39 @@ describe("instance-scoped model selection", () => {
101
).toBe("openai/gpt-5.5");
102
});
103
104
+ it("preserves a custom slug that collides with a provider alias", () => {
105
+ const providers = [
106
+ provider({
107
+ provider: ProviderDriverKind.make("claudeAgent"),
108
+ instanceId: "claude_openrouter",
109
+ models: ["claude-opus-4-8"],
110
+ }),
111
+ ];
112
+ const settings: UnifiedSettings = {
113
+ ...settingsWithProviderInstances(),
114
+ providerInstances: {
115
+ ...settingsWithProviderInstances().providerInstances,
116
+ [ProviderInstanceId.make("claude_openrouter")]: {
117
+ driver: ProviderDriverKind.make("claudeAgent"),
118
+ config: { customModels: ["opus"] },
119
+ },
120
+ },
121
+ };
122
+ const openrouter = deriveProviderInstanceEntries(providers)[0]!;
123
+
124
+ expect(
125
+ getAppModelOptionsForInstance(settings, openrouter).map((option) => option.slug),
126
+ ).toEqual(["claude-opus-4-8", "opus"]);
127
+ expect(
128
+ resolveAppModelSelectionForInstance(
129
+ ProviderInstanceId.make("claude_openrouter"),
130
+ settings,
131
+ providers,
132
+ "opus",
133
+ ),
134
+ ).toBe("opus");
135
+ });
136
+
137
it("includes Grok custom models from the selected provider instance", () => {
138
const providers = [provider({ provider: ProviderDriverKind.make("grok"), instanceId: "grok" })];
139
const settings: UnifiedSettings = {
apps/web/src/modelSelection.ts
+4
-6
@@ -9,7 +9,7 @@ import {
9
} from "@t3tools/contracts";
10
import {
11
createModelSelection,
12
- normalizeModelSlug,
12
+ normalizeCustomModelSlug,
13
resolveSelectableModel,
14
} from "@t3tools/shared/model";
15
import { getComposerProviderState } from "./components/chat/composerProviderState";
@@ -117,13 +117,12 @@ function applyInstanceModelPreferences(
117
export function normalizeCustomModelSlugs(
118
models: Iterable<string | null | undefined>,
119
builtInModelSlugs: ReadonlySet<string>,
120
- provider: ProviderDriverKind = ProviderDriverKind.make("codex"),
120
): string[] {
121
const normalizedModels: string[] = [];
122
const seen = new Set<string>();
123
124
for (const candidate of models) {
126
- const normalized = normalizeModelSlug(candidate, provider);
125
+ const normalized = normalizeCustomModelSlug(candidate);
126
if (
127
!normalized ||
128
normalized.length > MAX_CUSTOM_MODEL_LENGTH ||
@@ -163,7 +162,7 @@ export function getAppModelOptions(
162
// see the user's authored custom models.
163
const defaultInstanceId = defaultInstanceIdForDriver(provider);
164
const customModels = readInstanceCustomModels(settings, defaultInstanceId, provider);
166
- for (const slug of normalizeCustomModelSlugs(customModels, builtInModelSlugs, provider)) {
165
+ for (const slug of normalizeCustomModelSlugs(customModels, builtInModelSlugs)) {
166
if (seen.has(slug)) {
167
continue;
168
}
@@ -206,8 +205,7 @@ export function getAppModelOptionsForInstance(
205
);
206
207
const customModels = readInstanceCustomModels(settings, entry.instanceId, entry.driverKind);
209
- const normalizer = entry.driverKind;
210
- for (const slug of normalizeCustomModelSlugs(customModels, builtInModelSlugs, normalizer)) {
208
+ for (const slug of normalizeCustomModelSlugs(customModels, builtInModelSlugs)) {
209
if (seen.has(slug)) {
210
continue;
211
}
packages/shared/src/model.test.ts
+12
-1
@@ -1,5 +1,5 @@
1
import { describe, expect, it } from "vite-plus/test";
2
-import { ProviderInstanceId, type ModelCapabilities } from "@t3tools/contracts";
2
+import { ProviderDriverKind, ProviderInstanceId, type ModelCapabilities } from "@t3tools/contracts";
3
4
import {
5
buildProviderOptionSelectionsFromDescriptors,
@@ -10,6 +10,8 @@ import {
10
getProviderOptionDescriptors,
11
getProviderOptionBooleanSelectionValue,
12
getProviderOptionStringSelectionValue,
13
+ normalizeCustomModelSlug,
14
+ normalizeModelSlug,
15
} from "./model.ts";
16
17
const codexCaps: ModelCapabilities = createModelCapabilities({
@@ -144,3 +146,12 @@ describe("descriptor helpers", () => {
146
expect(getModelSelectionBooleanOptionValue(selection, "fastMode")).toBe(true);
147
});
148
});
149
+
150
+describe("model slug normalization", () => {
151
+ it("preserves exact custom slugs instead of expanding provider aliases", () => {
152
+ const claude = ProviderDriverKind.make("claudeAgent");
153
+
154
+ expect(normalizeModelSlug("opus", claude)).toBe("claude-opus-4-8");
155
+ expect(normalizeCustomModelSlug(" opus ")).toBe("opus");
156
+ });
157
+});
packages/shared/src/model.ts
+10
-5
@@ -236,11 +236,7 @@ export function normalizeModelSlug(
236
model: string | null | undefined,
237
provider: ProviderDriverKind = DEFAULT_PROVIDER_DRIVER_KIND,
238
): string | null {
239
- if (typeof model !== "string") {
240
- return null;
241
- }
242
-
243
- const trimmed = model.trim();
239
+ const trimmed = normalizeCustomModelSlug(model);
240
if (!trimmed) {
241
return null;
242
}
@@ -252,6 +248,15 @@ export function normalizeModelSlug(
248
return typeof aliased === "string" ? aliased : trimmed;
249
}
250
251
+/** Custom model identifiers are provider-owned, so only trim them; never expand aliases. */
252
+export function normalizeCustomModelSlug(model: string | null | undefined): string | null {
253
+ if (typeof model !== "string") {
254
+ return null;
255
+ }
256
+
257
+ return model.trim() || null;
258
+}
259
+
260
export function resolveSelectableModel(
261
provider: ProviderDriverKind,
262
value: string | null | undefined,