Skip to content

Commit 4b15996

Browse files
fix(server): Claude always runs its full context window
Drop the 200k/1M Context Window option. Each Claude profile declares the window Claude Code actually runs, and Opus 4.6 is sent with [1m] to get it. Closes #16904 Closes #8405 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent ba0ea3d commit 4b15996

8 files changed

Lines changed: 32 additions & 233 deletions

File tree

‎apps/server/src/claudeModelOptions.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ const selection = (
1414
});
1515

1616
describe("compileClaudeModelSelection", () => {
17-
it("compiles context, effort, and settings together", () => {
17+
it("compiles effort and settings together and ignores a saved context window", () => {
1818
expect(
1919
compileClaudeModelSelection(
2020
selection("claude-fable-5", [
21-
{ id: "contextWindow", value: "1m" },
21+
{ id: "contextWindow", value: "200k" },
2222
{ id: "effort", value: "ultracode" },
2323
]),
2424
),
2525
).toMatchObject({
26-
apiModelId: "claude-fable-5[1m]",
26+
apiModelId: "claude-fable-5",
2727
effort: "xhigh",
2828
settings: { ultracode: true },
2929
});

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ import {
9797
} from "../../provider/Drivers/ClaudeHome.ts";
9898
import {
9999
BUNDLED_CLAUDE_MODEL_CATALOG,
100-
resolveClaudeCatalogContextWindow,
101100
resolveClaudeCatalogContextWindowTokens,
102101
} from "../../provider/ClaudeModelCatalog.ts";
103102
import {
@@ -138,12 +137,9 @@ export const CLAUDE_PROVIDER = ProviderDriverKind.make("claudeAgent");
138137
export const CLAUDE_AGENT_SDK_QUERY_PROTOCOL = "claude-agent-sdk.query" as const;
139138

140139
function claudeContextWindow(modelSelection: ModelSelection): number | null {
141-
if (modelSelection.model === "claude-opus-4-6" || modelSelection.model === "claude-opus-4-7") {
142-
return 1_000_000;
143-
}
144-
return resolveClaudeCatalogContextWindow(BUNDLED_CLAUDE_MODEL_CATALOG, modelSelection) === "1m"
145-
? 1_000_000
146-
: 200_000;
140+
return (
141+
resolveClaudeCatalogContextWindowTokens(BUNDLED_CLAUDE_MODEL_CATALOG, modelSelection) ?? null
142+
);
147143
}
148144

149145
export function claudeProviderTurnTokenUsage(

‎apps/server/src/provider/ClaudeModelCatalog.test.ts‎

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,12 @@ const manifest = (): ModelManifestData => ({
3737
type: "select",
3838
options: [{ id: "extreme", label: "Extreme", isDefault: true }],
3939
},
40-
{
41-
id: "contextWindow",
42-
label: "Context Window",
43-
type: "select",
44-
options: [
45-
{ id: "large", label: "Large", isDefault: true },
46-
{ id: "small", label: "Small" },
47-
],
48-
},
4940
],
5041
},
5142
adapter: {
5243
claudeCode: {
5344
effortMap: { extreme: "high" },
54-
modelSuffixes: { contextWindow: { large: "[large]" } },
45+
modelSuffix: "[large]",
5546
},
5647
},
5748
},
@@ -71,7 +62,7 @@ const manifest = (): ModelManifestData => ({
7162
});
7263

7364
describe("Claude model catalog", () => {
74-
it("resolves capacity from selected options and fixed catalog windows without guessing custom models", () => {
65+
it("resolves fixed catalog windows without guessing custom models", () => {
7566
const source = manifest();
7667
const profile = source.providers!.claudeAgent!.profiles.synthetic!;
7768
const catalog = resolveClaudeModelCatalog({
@@ -86,7 +77,7 @@ describe("Claude model catalog", () => {
8677
},
8778
synthetic: {
8879
...profile,
89-
adapter: { claudeCode: { contextWindowTokens: { large: 1_000_000, small: 32_000 } } },
80+
adapter: { claudeCode: { fixedContextWindowTokens: 1_000_000 } },
9081
},
9182
},
9283
models: [
@@ -106,9 +97,9 @@ describe("Claude model catalog", () => {
10697
assert.equal(
10798
resolveClaudeCatalogContextWindowTokens(catalog, {
10899
...selection,
109-
options: [{ id: "contextWindow", value: "small" }],
100+
options: [{ id: "contextWindow", value: "200k" }],
110101
}),
111-
32_000,
102+
1_000_000,
112103
);
113104
assert.equal(
114105
resolveClaudeCatalogContextWindowTokens(catalog, { ...selection, model: "fixed" }),

‎apps/server/src/provider/ClaudeModelCatalog.testFixtures.ts‎

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,10 @@ const effort = {
2020
promptInjectedValues: ["ultrathink"],
2121
};
2222

23-
const contextWindow = {
24-
id: "contextWindow",
25-
label: "Context Window",
26-
type: "select" as const,
27-
options: [
28-
{ id: "standard", label: "Standard" },
29-
{ id: "expanded", label: "Expanded", isDefault: true },
30-
],
31-
};
32-
3323
const runtime = {
3424
effortMap: { ultrathink: null },
35-
modelSuffixes: { contextWindow: { expanded: "[expanded]" } },
36-
contextWindowTokens: { standard: 200_000, expanded: 1_000_000 },
25+
modelSuffix: "[expanded]",
26+
fixedContextWindowTokens: 1_000_000,
3727
};
3828

3929
export const SYNTHETIC_CLAUDE_MODEL_CATALOG: ClaudeModelCatalog = {
@@ -45,11 +35,7 @@ export const SYNTHETIC_CLAUDE_MODEL_CATALOG: ClaudeModelCatalog = {
4535
aliases: [SYNTHETIC_CLAUDE_COLLIDING_ALIAS],
4636
isCustom: false,
4737
capabilities: {
48-
optionDescriptors: [
49-
effort,
50-
{ id: "fastMode", label: "Fast Mode", type: "boolean" },
51-
contextWindow,
52-
],
38+
optionDescriptors: [effort, { id: "fastMode", label: "Fast Mode", type: "boolean" }],
5339
},
5440
},
5541
runtime,
@@ -61,7 +47,7 @@ export const SYNTHETIC_CLAUDE_MODEL_CATALOG: ClaudeModelCatalog = {
6147
name: "Claude Synthetic Standard",
6248
isCustom: false,
6349
capabilities: {
64-
optionDescriptors: [effort, contextWindow],
50+
optionDescriptors: [effort],
6551
},
6652
},
6753
runtime,

‎apps/server/src/provider/ClaudeModelCatalog.ts‎

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
} from "@t3tools/contracts";
88
import * as Option from "effect/Option";
99
import {
10-
getModelSelectionStringOptionValue,
1110
getProviderOptionCurrentValue,
1211
getProviderOptionDescriptors,
1312
readCustomModelEntries,
@@ -215,47 +214,19 @@ export function isClaudeCatalogUltracodeEffort(effort: string | null | undefined
215214
return effort === "ultracode";
216215
}
217216

218-
export function resolveClaudeCatalogContextWindow(
219-
catalog: ClaudeModelCatalog,
220-
modelSelection: ModelSelection | undefined,
221-
): string | undefined {
222-
const caps = getClaudeCatalogModelCapabilities(catalog, modelSelection?.model);
223-
const raw = getModelSelectionStringOptionValue(modelSelection, "contextWindow");
224-
const descriptors = getProviderOptionDescriptors({
225-
caps,
226-
...(raw ? { selections: [{ id: "contextWindow", value: raw }] } : {}),
227-
});
228-
const descriptor = descriptors.find((candidate) => candidate.id === "contextWindow");
229-
const value = getProviderOptionCurrentValue(descriptor);
230-
return typeof value === "string" ? value : undefined;
231-
}
232-
233217
export function resolveClaudeCatalogApiModelId(
234218
catalog: ClaudeModelCatalog,
235219
modelSelection: ModelSelection,
236220
): string {
237221
const entry = resolveClaudeCatalogModel(catalog, modelSelection.model);
238222
const slug = entry?.model.slug ?? modelSelection.model;
239-
const descriptors = getProviderOptionDescriptors({
240-
caps: entry?.model.capabilities ?? EMPTY_CAPABILITIES,
241-
selections: modelSelection.options,
242-
});
243-
for (const [optionId, suffixes] of Object.entries(entry?.runtime.modelSuffixes ?? {})) {
244-
const value = getProviderOptionCurrentValue(
245-
descriptors.find((descriptor) => descriptor.id === optionId),
246-
);
247-
if (typeof value === "string" && suffixes[value]) return `${slug}${suffixes[value]}`;
248-
}
249-
return slug;
223+
return `${slug}${entry?.runtime.modelSuffix ?? ""}`;
250224
}
251225

252226
export function resolveClaudeCatalogContextWindowTokens(
253227
catalog: ClaudeModelCatalog,
254228
modelSelection: ModelSelection | undefined,
255229
): number | undefined {
256-
const entry = resolveClaudeCatalogModel(catalog, modelSelection?.model);
257-
if (!entry) return undefined;
258-
if (entry.runtime.fixedContextWindowTokens) return entry.runtime.fixedContextWindowTokens;
259-
const contextWindow = resolveClaudeCatalogContextWindow(catalog, modelSelection);
260-
return contextWindow ? entry.runtime.contextWindowTokens?.[contextWindow] : undefined;
230+
return resolveClaudeCatalogModel(catalog, modelSelection?.model)?.runtime
231+
.fixedContextWindowTokens;
261232
}

‎apps/server/src/provider/ClaudeModelManifest.ts‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,8 @@ export const ClaudeCodeProfileSchema = Schema.Struct({
77
effortMap: Schema.optional(
88
Schema.Record(TrimmedNonEmptyString, Schema.NullOr(TrimmedNonEmptyString)),
99
),
10-
modelSuffixes: Schema.optional(
11-
Schema.Record(
12-
TrimmedNonEmptyString,
13-
Schema.Record(TrimmedNonEmptyString, TrimmedNonEmptyString),
14-
),
15-
),
16-
contextWindowTokens: Schema.optional(Schema.Record(TrimmedNonEmptyString, Schema.Number)),
10+
/** Appended to the slug when Claude Code needs it to run `fixedContextWindowTokens`. */
11+
modelSuffix: Schema.optional(TrimmedNonEmptyString),
1712
fixedContextWindowTokens: Schema.optional(Schema.Number),
1813
});
1914

0 commit comments

Comments
 (0)