Skip to content

Commit 90be220

Browse files
t3dotggclaude
andcommitted
fix: better default models and worktree bases
- Claude: only Opus/Fable default to 1M context; Sonnet stays 200k, matching Claude Code's own defaults - Codex: propagate the app-server's isDefault flag into provider snapshots, preferring gpt-5.6-sol then gpt-5.6-terra when present; web and mobile now pick the flagged default instead of the first list entry, and the static DEFAULT_MODEL fallback is gpt-5.6-sol - ServerProviderModel grows an optional isDefault field Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent 944e28c commit 90be220

8 files changed

Lines changed: 96 additions & 8 deletions

File tree

‎apps/mobile/src/features/threads/new-task-flow-provider.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
371371
const selectedModel =
372372
selectedProjectDraft.modelSelection ??
373373
selectedProject?.defaultModelSelection ??
374+
modelOptions.find((option) => option.isDefault)?.selection ??
374375
modelOptions[0]?.selection ??
375376
null;
376377
const selectedModelKey = selectedModel

‎apps/mobile/src/lib/modelOptions.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export type ModelOption = {
1515
readonly providerKey: string;
1616
readonly providerLabel: string;
1717
readonly providerDriver: string;
18+
readonly isDefault: boolean;
1819
readonly capabilities: ModelCapabilities | null;
1920
readonly selection: ModelSelection;
2021
};
@@ -78,6 +79,7 @@ export function buildModelOptions(
7879
providerKey: provider.instanceId,
7980
providerLabel,
8081
providerDriver: provider.driver,
82+
isDefault: model.isDefault === true,
8183
capabilities: model.capabilities,
8284
selection: normalizeSelectionOptions(
8385
{
@@ -107,6 +109,7 @@ export function buildModelOptions(
107109
providerKey: fallbackModelSelection.instanceId,
108110
providerLabel,
109111
providerDriver: fallbackModelSelection.instanceId,
112+
isDefault: false,
110113
capabilities: null,
111114
selection: fallbackModelSelection,
112115
});

‎apps/server/src/provider/Layers/ClaudeProvider.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,10 @@ const BUILT_IN_MODELS: ReadonlyArray<ServerProviderModel> = [
214214
buildSelectOptionDescriptor({
215215
id: "contextWindow",
216216
label: "Context Window",
217+
// Sonnet is 200k-default in Claude Code (1M is opt-in there too).
217218
options: [
218-
{ value: "200k", label: "200k" },
219-
{ value: "1m", label: "1M", isDefault: true },
219+
{ value: "200k", label: "200k", isDefault: true },
220+
{ value: "1m", label: "1M" },
220221
],
221222
}),
222223
],
@@ -243,9 +244,10 @@ const BUILT_IN_MODELS: ReadonlyArray<ServerProviderModel> = [
243244
buildSelectOptionDescriptor({
244245
id: "contextWindow",
245246
label: "Context Window",
247+
// Sonnet is 200k-default in Claude Code (1M is opt-in there too).
246248
options: [
247-
{ value: "200k", label: "200k" },
248-
{ value: "1m", label: "1M", isDefault: true },
249+
{ value: "200k", label: "200k", isDefault: true },
250+
{ value: "1m", label: "1M" },
249251
],
250252
}),
251253
],

‎apps/server/src/provider/Layers/CodexProvider.test.ts‎

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { assert, it } from "@effect/vitest";
22

3-
import { mapCodexModelCapabilities } from "./CodexProvider.ts";
3+
import { applyPreferredCodexDefaultModel, mapCodexModelCapabilities } from "./CodexProvider.ts";
44

55
it("maps current Codex model capability fields", () => {
66
const capabilities = mapCodexModelCapabilities({
@@ -102,3 +102,45 @@ it("uses standard routing when the catalog has no default service tier", () => {
102102
},
103103
]);
104104
});
105+
106+
it("marks the most preferred available model as default", () => {
107+
const models = applyPreferredCodexDefaultModel([
108+
{ slug: "gpt-5.6-terra", name: "GPT-5.6-Terra", isCustom: false, capabilities: null },
109+
{ slug: "gpt-5.4", name: "GPT-5.4", isCustom: false, isDefault: true, capabilities: null },
110+
]);
111+
112+
assert.deepStrictEqual(
113+
models.map((model) => ({ slug: model.slug, isDefault: model.isDefault })),
114+
[
115+
{ slug: "gpt-5.6-terra", isDefault: true },
116+
{ slug: "gpt-5.4", isDefault: undefined },
117+
],
118+
);
119+
});
120+
121+
it("prefers sol over terra when both are available", () => {
122+
const models = applyPreferredCodexDefaultModel([
123+
{ slug: "gpt-5.6-terra", name: "GPT-5.6-Terra", isCustom: false, capabilities: null },
124+
{ slug: "gpt-5.6-sol", name: "GPT-5.6-Sol", isCustom: false, capabilities: null },
125+
]);
126+
127+
assert.deepStrictEqual(models.find((model) => model.isDefault)?.slug, "gpt-5.6-sol");
128+
});
129+
130+
it("keeps Codex's own default when no preferred model is available", () => {
131+
const models = applyPreferredCodexDefaultModel([
132+
{ slug: "gpt-5.5", name: "GPT-5.5", isCustom: false, capabilities: null },
133+
{ slug: "gpt-5.4", name: "GPT-5.4", isCustom: false, isDefault: true, capabilities: null },
134+
]);
135+
136+
assert.deepStrictEqual(models.find((model) => model.isDefault)?.slug, "gpt-5.4");
137+
});
138+
139+
it("ignores custom models that shadow a preferred slug", () => {
140+
const models = applyPreferredCodexDefaultModel([
141+
{ slug: "gpt-5.6-sol", name: "gpt-5.6-sol", isCustom: true, capabilities: null },
142+
{ slug: "gpt-5.4", name: "GPT-5.4", isCustom: false, isDefault: true, capabilities: null },
143+
]);
144+
145+
assert.deepStrictEqual(models.find((model) => model.isDefault)?.slug, "gpt-5.4");
146+
});

‎apps/server/src/provider/Layers/CodexProvider.ts‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import type {
2222
ServerProviderModel,
2323
ServerProviderSkill,
2424
} from "@t3tools/contracts";
25-
import { ServerSettingsError } from "@t3tools/contracts";
25+
import { PREFERRED_DEFAULT_CODEX_MODELS, ServerSettingsError } from "@t3tools/contracts";
2626

2727
import { createModelCapabilities } from "@t3tools/shared/model";
2828
import { resolveSpawnCommand } from "@t3tools/shared/shell";
@@ -189,10 +189,36 @@ function parseCodexModelListResponse(
189189
slug: model.model,
190190
name: toDisplayName(model),
191191
isCustom: false,
192+
...(model.isDefault ? { isDefault: true } : {}),
192193
capabilities: mapCodexModelCapabilities(model),
193194
}));
194195
}
195196

197+
/**
198+
* Prefer our own default-model ranking when one of the preferred slugs is in
199+
* the live catalog; otherwise keep whatever Codex itself flagged as default.
200+
*/
201+
export function applyPreferredCodexDefaultModel(
202+
models: ReadonlyArray<ServerProviderModel>,
203+
): ReadonlyArray<ServerProviderModel> {
204+
const preferredSlug = PREFERRED_DEFAULT_CODEX_MODELS.find((slug) =>
205+
models.some((model) => model.slug === slug && !model.isCustom),
206+
);
207+
if (!preferredSlug) {
208+
return models;
209+
}
210+
return models.map((model) => {
211+
if (model.slug === preferredSlug) {
212+
return model.isDefault ? model : { ...model, isDefault: true };
213+
}
214+
if (!model.isDefault) {
215+
return model;
216+
}
217+
const { isDefault: _isDefault, ...rest } = model;
218+
return rest;
219+
});
220+
}
221+
196222
function appendCustomCodexModels(
197223
models: ReadonlyArray<ServerProviderModel>,
198224
customModels: ReadonlyArray<string>,
@@ -376,7 +402,9 @@ const probeCodexAppServerProvider = Effect.fn("probeCodexAppServerProvider")(fun
376402
return {
377403
account: accountResponse,
378404
version,
379-
models: appendCustomCodexModels(models, input.customModels ?? []),
405+
models: applyPreferredCodexDefaultModel(
406+
appendCustomCodexModels(models, input.customModels ?? []),
407+
),
380408
skills: parseCodexSkillsListResponse(skillsResponse, input.cwd),
381409
} satisfies CodexAppServerProviderSnapshot;
382410
});

‎apps/web/src/providerModels.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export function getDefaultServerModel(
9292
): string {
9393
const models = getProviderModels(providers, provider);
9494
return (
95+
models.find((model) => model.isDefault && !model.isCustom)?.slug ??
9596
models.find((model) => !model.isCustom)?.slug ??
9697
models[0]?.slug ??
9798
DEFAULT_MODEL_BY_PROVIDER[provider] ??

‎packages/contracts/src/model.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,17 @@ const CURSOR_DRIVER_KIND = ProviderDriverKind.make("cursor");
133133
const GROK_DRIVER_KIND = ProviderDriverKind.make("grok");
134134
const OPENCODE_DRIVER_KIND = ProviderDriverKind.make("opencode");
135135

136-
export const DEFAULT_MODEL = "gpt-5.4";
136+
export const DEFAULT_MODEL = "gpt-5.6-sol";
137+
138+
/**
139+
* Codex default-model preference, most preferred first. The provider snapshot
140+
* marks the first of these present in the live `model/list` response as
141+
* default; when none are available, Codex's own `isDefault` flag wins.
142+
*/
143+
export const PREFERRED_DEFAULT_CODEX_MODELS: ReadonlyArray<string> = [
144+
"gpt-5.6-sol",
145+
"gpt-5.6-terra",
146+
];
137147
export const DEFAULT_GIT_TEXT_GENERATION_MODEL = "gpt-5.4-mini";
138148

139149
export const DEFAULT_MODEL_BY_PROVIDER: Partial<Record<ProviderDriverKind, string>> = {

‎packages/contracts/src/server.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export const ServerProviderModel = Schema.Struct({
6464
shortName: Schema.optional(TrimmedNonEmptyString),
6565
subProvider: Schema.optional(TrimmedNonEmptyString),
6666
isCustom: Schema.Boolean,
67+
isDefault: Schema.optional(Schema.Boolean),
6768
capabilities: Schema.NullOr(ModelCapabilities),
6869
});
6970
export type ServerProviderModel = typeof ServerProviderModel.Type;

0 commit comments

Comments
 (0)