Skip to content

Commit b803ecc

Browse files
committed
refactor: centralize default model to Opus 4.5
- Change default model from Sonnet to Opus 4.5 - Remove isDefault boolean from model definitions (no static guarantee) - Add DEFAULT_MODEL_KEY const that directly references a KnownModelKey - Update all hardcoded model strings to use the centralized DEFAULT_MODEL - Fix WORKSPACE_DEFAULTS to import from knownModels.ts The default model is now defined in one place: src/common/constants/knownModels.ts -> DEFAULT_MODEL_KEY = "OPUS" _Generated with `mux`_
1 parent d47b013 commit b803ecc

File tree

6 files changed

+21
-18
lines changed

6 files changed

+21
-18
lines changed

src/browser/stories/mockFactory.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import type {
1616
MuxImagePart,
1717
MuxToolPart,
1818
} from "@/common/types/message";
19+
import { DEFAULT_MODEL } from "@/common/constants/knownModels";
1920

2021
/** Part type for message construction */
2122
type MuxPart = MuxTextPart | MuxReasoningPart | MuxImagePart | MuxToolPart;
@@ -196,7 +197,7 @@ export function createAssistantMessage(
196197
metadata: {
197198
historySequence: opts.historySequence,
198199
timestamp: opts.timestamp ?? STABLE_TIMESTAMP,
199-
model: opts.model ?? "anthropic:claude-sonnet-4-5",
200+
model: opts.model ?? DEFAULT_MODEL,
200201
usage: { inputTokens: 100, outputTokens: 50, totalTokens: 150 },
201202
duration: 1000,
202203
},

src/browser/stories/storyHelpers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
getInputKey,
1515
getModelKey,
1616
} from "@/common/constants/storage";
17+
import { DEFAULT_MODEL } from "@/common/constants/knownModels";
1718
import {
1819
createWorkspace,
1920
groupWorkspacesByProject,
@@ -178,7 +179,7 @@ export function setupStreamingChatStory(opts: StreamingChatSetupOptions): APICli
178179
createStreamingChatHandler({
179180
messages: opts.messages,
180181
streamingMessageId: opts.streamingMessageId,
181-
model: opts.model ?? "anthropic:claude-sonnet-4-5",
182+
model: opts.model ?? DEFAULT_MODEL,
182183
historySequence: opts.historySequence,
183184
streamText: opts.streamText,
184185
pendingTool: opts.pendingTool,

src/common/constants/knownModels.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ interface KnownModelDefinition {
1515
aliases?: string[];
1616
/** Preload tokenizer encodings at startup */
1717
warm?: boolean;
18-
/** Use as global default model */
19-
isDefault?: boolean;
2018
/** Optional tokenizer override for ai-tokenizer */
2119
tokenizerOverride?: string;
2220
}
@@ -29,12 +27,17 @@ interface KnownModel extends KnownModelDefinition {
2927
// Model definitions. Note we avoid listing legacy models here. These represent the focal models
3028
// of the community.
3129
const MODEL_DEFINITIONS = {
30+
OPUS: {
31+
provider: "anthropic",
32+
providerModelId: "claude-opus-4-5",
33+
aliases: ["opus"],
34+
warm: true,
35+
},
3236
SONNET: {
3337
provider: "anthropic",
3438
providerModelId: "claude-sonnet-4-5",
3539
aliases: ["sonnet"],
3640
warm: true,
37-
isDefault: true,
3841
tokenizerOverride: "anthropic/claude-sonnet-4.5",
3942
},
4043
HAIKU: {
@@ -43,11 +46,6 @@ const MODEL_DEFINITIONS = {
4346
aliases: ["haiku"],
4447
tokenizerOverride: "anthropic/claude-3.5-haiku",
4548
},
46-
OPUS: {
47-
provider: "anthropic",
48-
providerModelId: "claude-opus-4-5",
49-
aliases: ["opus"],
50-
},
5149
GPT: {
5250
provider: "openai",
5351
providerModelId: "gpt-5.1",
@@ -119,10 +117,10 @@ export function getKnownModel(key: KnownModelKey): KnownModel {
119117
// Derived collections
120118
// ------------------------------------------------------------------------------------
121119

122-
const DEFAULT_MODEL_ENTRY =
123-
Object.values(KNOWN_MODELS).find((model) => model.isDefault) ?? KNOWN_MODELS.SONNET;
120+
/** The default model key - change this single line to update the global default */
121+
export const DEFAULT_MODEL_KEY: KnownModelKey = "OPUS";
124122

125-
export const DEFAULT_MODEL = DEFAULT_MODEL_ENTRY.id;
123+
export const DEFAULT_MODEL = KNOWN_MODELS[DEFAULT_MODEL_KEY].id;
126124

127125
export const DEFAULT_WARM_MODELS = Object.values(KNOWN_MODELS)
128126
.filter((model) => model.warm)

src/constants/workspaceDefaults.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, test, expect } from "bun:test";
22
import { WORKSPACE_DEFAULTS } from "./workspaceDefaults";
3+
import { DEFAULT_MODEL } from "@/common/constants/knownModels";
34

45
type Mutable<T> = { -readonly [P in keyof T]: T[P] };
56

@@ -15,7 +16,7 @@ describe("WORKSPACE_DEFAULTS", () => {
1516
test("should have correct default values", () => {
1617
expect(WORKSPACE_DEFAULTS.mode).toBe("exec");
1718
expect(WORKSPACE_DEFAULTS.thinkingLevel).toBe("off");
18-
expect(WORKSPACE_DEFAULTS.model).toBe("anthropic:claude-sonnet-4-5");
19+
expect(WORKSPACE_DEFAULTS.model).toBe(DEFAULT_MODEL);
1920
expect(WORKSPACE_DEFAULTS.autoRetry).toBe(true);
2021
expect(WORKSPACE_DEFAULTS.input).toBe("");
2122
});

src/constants/workspaceDefaults.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import type { UIMode } from "@/common/types/mode";
2424
import type { ThinkingLevel } from "@/common/types/thinking";
25+
import { DEFAULT_MODEL } from "@/common/constants/knownModels";
2526

2627
/**
2728
* Hard-coded default values for workspace settings.
@@ -36,9 +37,9 @@ export const WORKSPACE_DEFAULTS = {
3637

3738
/**
3839
* Default AI model for new workspaces.
39-
* This is the TRUE default - not dependent on user's LRU cache.
40+
* Uses the centralized default from knownModels.ts.
4041
*/
41-
model: "anthropic:claude-sonnet-4-5" as string,
42+
model: DEFAULT_MODEL as string,
4243

4344
/** Default auto-retry preference for new workspaces */
4445
autoRetry: true as boolean,

src/node/services/workspaceService.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import type {
3131
import type { MuxMessage } from "@/common/types/message";
3232
import type { RuntimeConfig } from "@/common/types/runtime";
3333
import { hasSrcBaseDir, getSrcBaseDir } from "@/common/types/runtime";
34+
import { defaultModel } from "@/common/utils/ai/models";
3435
import type { StreamEndEvent, StreamAbortEvent } from "@/common/types/stream";
3536
import type { TerminalService } from "@/node/services/terminalService";
3637

@@ -660,7 +661,7 @@ export class WorkspaceService extends EventEmitter {
660661
if (messageText.trim()) {
661662
const branchNameResult = await generateWorkspaceName(
662663
messageText,
663-
"anthropic:claude-sonnet-4-5",
664+
defaultModel,
664665
this.aiService
665666
);
666667

@@ -880,7 +881,7 @@ export class WorkspaceService extends EventEmitter {
880881
projectPath?: string;
881882
trunkBranch?: string;
882883
})
883-
| undefined = { model: "claude-sonnet-4-5-latest" }
884+
| undefined = { model: defaultModel }
884885
): Promise<
885886
| Result<void, SendMessageError>
886887
| { success: true; workspaceId: string; metadata: FrontendWorkspaceMetadata }

0 commit comments

Comments
 (0)