Skip to content

Commit 723cfe9

Browse files
committed
fix(provider): keep selectable context window total within DeepSeek's 1M
VS Code/Copilot derives the displayed context window from maxInputTokens + maxOutputTokens. The selector reported 1,000,000 + 128,000 ≈ 1.128M for the 1M option, partially reverting the accounting fixed in #71. Restore the model default to 655,360 + 393,216 (= 1,048,576, DeepSeek's official combined input+output limit) and map each selectable window to an input/output split that sums to the advertised total (200K → 125,000 + 75,000), preserving the same 5:3 reservation ratio.
1 parent 523a4df commit 723cfe9

2 files changed

Lines changed: 33 additions & 6 deletions

File tree

src/consts.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ export const MODELS: ModelDefinition[] = [
5454
family: 'deepseek',
5555
version: 'v4',
5656
detail: 'Fast, general-purpose model',
57-
maxInputTokens: 1000000,
58-
maxOutputTokens: 128000,
57+
maxInputTokens: 655360,
58+
maxOutputTokens: 393216,
5959
capabilities: {
6060
toolCalling: DEEPSEEK_TOOLS_LIMIT,
6161
imageInput: true,
@@ -74,8 +74,8 @@ export const MODELS: ModelDefinition[] = [
7474
family: 'deepseek',
7575
version: 'v4',
7676
detail: 'Most capable reasoning model',
77-
maxInputTokens: 1000000,
78-
maxOutputTokens: 128000,
77+
maxInputTokens: 655360,
78+
maxOutputTokens: 393216,
7979
capabilities: {
8080
toolCalling: DEEPSEEK_TOOLS_LIMIT,
8181
imageInput: true,

src/provider/models.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ export function toChatInfo(
4949
detail: hasApiKey ? modelDetail : t('auth.apiKeyRequiredDetail'),
5050
tooltip: hasApiKey ? modelTooltip : t('auth.apiKeyRequiredDetail'),
5151
statusIcon: hasApiKey ? undefined : new vscode.ThemeIcon('warning'),
52-
maxInputTokens: contextSize ?? m.maxInputTokens,
53-
maxOutputTokens: m.maxOutputTokens,
52+
...resolveContextWindow(m, contextSize),
5453
isBYOK: true,
5554
isUserSelectable: true,
5655
capabilities: {
@@ -77,6 +76,34 @@ export function getConfiguredThinkingEffort(options: ModelConfigurationOptions):
7776
return configuredEffort === 'max' ? 'max' : 'high';
7877
}
7978

79+
/**
80+
* Token split for the selectable 200K context window.
81+
*
82+
* VS Code/Copilot derives the displayed context window from
83+
* `maxInputTokens + maxOutputTokens`, so each selectable window must split its
84+
* *total* budget into input + output. The default 1M window keeps the
85+
* accounting fixed in #71 (655,360 + 393,216 = 1,048,576 = DeepSeek's official
86+
* combined input+output limit). The 200K option mirrors that same 5:3
87+
* input:output reservation, scaled to a 200,000-token total, so the reported
88+
* window stays honest (~200K) instead of input + a separate output reservation.
89+
*/
90+
const CONTEXT_WINDOW_200K = { maxInputTokens: 125000, maxOutputTokens: 75000 } as const;
91+
92+
/**
93+
* Resolve the (input, output) token split for the selected context window.
94+
* Unknown / unset values fall back to the model's own metadata, which encodes
95+
* DeepSeek's official 1M (input + output) window.
96+
*/
97+
function resolveContextWindow(
98+
m: ModelDefinition,
99+
contextSize?: number,
100+
): { maxInputTokens: number; maxOutputTokens: number } {
101+
if (contextSize === 200000) {
102+
return { ...CONTEXT_WINDOW_200K };
103+
}
104+
return { maxInputTokens: m.maxInputTokens, maxOutputTokens: m.maxOutputTokens };
105+
}
106+
80107
/**
81108
* Read the context size selected by the user via the model-picker dropdown.
82109
* Falls back to the VS Code setting when the dropdown hasn't been used yet.

0 commit comments

Comments
 (0)