Skip to content

Commit 1d393bb

Browse files
committed
fix: auto-enable extendedContext when legacy [1m] models found in config
Configs with model: "opus[1m]" (old format, no extendedContext key) were silently downgraded to 200K context because migration stripped [1m] without setting extendedContext=true. Now detects legacy [1m] in any model value and auto-enables extended context to preserve user intent.
1 parent 50c4dcd commit 1d393bb

7 files changed

Lines changed: 10 additions & 6 deletions

File tree

console/src/services/worker/http/routes/SettingsRoutes.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ export class SettingsRoutes extends BaseRouteHandler {
7171
}
7272

7373
private mergeWithDefaults(raw: Record<string, unknown>): ModelSettings {
74+
let hasLegacy1m =
75+
typeof raw.model === "string" && raw.model.includes("[1m]");
76+
7477
let mainModel =
7578
typeof raw.model === "string"
7679
? SettingsRoutes.stripLegacy1m(raw.model)
@@ -92,6 +95,7 @@ export class SettingsRoutes extends BaseRouteHandler {
9295
rawCommands as Record<string, unknown>,
9396
)) {
9497
if (typeof v === "string") {
98+
if (v.includes("[1m]")) hasLegacy1m = true;
9599
const stripped = SettingsRoutes.stripLegacy1m(v);
96100
if (MODEL_CHOICES.includes(stripped)) {
97101
mergedCommands[k] = stripped;
@@ -119,7 +123,7 @@ export class SettingsRoutes extends BaseRouteHandler {
119123
}
120124
}
121125

122-
const extendedContext = raw.extendedContext === true;
126+
const extendedContext = raw.extendedContext === true || hasLegacy1m;
123127

124128
return {
125129
model: mainModel,

console/tests/settings-routes.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ describe('SettingsRoutes', () => {
152152
expect(m.body.commands['spec-plan']).toBe(DEFAULT_SETTINGS.commands['spec-plan']);
153153
});
154154

155-
it('should strip legacy 1m model without enabling extendedContext', async () => {
155+
it('should auto-enable extendedContext when legacy 1m model found', async () => {
156156
fs.writeFileSync(configPath, JSON.stringify({ model: 'opus[1m]' }));
157157

158158
const m = makeMockRes();
@@ -161,10 +161,10 @@ describe('SettingsRoutes', () => {
161161
await (routes as any).handleGet(req as Request, m.res as Response);
162162

163163
expect(m.body.model).toBe('opus');
164-
expect(m.body.extendedContext).toBe(false);
164+
expect(m.body.extendedContext).toBe(true);
165165
});
166166

167-
it('should strip legacy 1m commands without enabling extendedContext', async () => {
167+
it('should auto-enable extendedContext when legacy 1m commands found', async () => {
168168
fs.writeFileSync(configPath, JSON.stringify({ model: 'opus', commands: { spec: 'sonnet[1m]' } }));
169169

170170
const m = makeMockRes();
@@ -173,7 +173,7 @@ describe('SettingsRoutes', () => {
173173
await (routes as any).handleGet(req as Request, m.res as Response);
174174

175175
expect(m.body.commands.spec).toBe('sonnet');
176-
expect(m.body.extendedContext).toBe(false);
176+
expect(m.body.extendedContext).toBe(true);
177177
});
178178
});
179179

launcher/model_config.py

182 Bytes
Binary file not shown.

launcher/settings_injector.py

182 Bytes
Binary file not shown.
-30 Bytes
Binary file not shown.
-3 Bytes
Binary file not shown.

pilot/scripts/worker-service.cjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)