Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ The following fields correspond to `ModelConfig` (field names used in import/exp
| Model Family | `family` | A grouping identifier for grouping/matching models (e.g., `gpt-4`, `claude-3`). |
| Max Input Tokens | `maxInputTokens` | Maximum input/context tokens (some providers interpret this as total context for “input + output”). |
| Max Output Tokens | `maxOutputTokens` | Maximum generated tokens (required by some providers, e.g., Anthropic’s `max_tokens`). |
| Reported Max Output Tokens | `reportedMaxOutputTokens` | Maximum output tokens reported to VS Code for context window metadata. Use when the provider should expose an output reserve to VS Code but should not receive an output token limit in API requests. |
| Tokenizer | `tokenizer` | Tokenizer used for VS Code token counting (`provideTokenCount`). Default: `default`. |
| Token Count Multiplier | `tokenCountMultiplier` | Multiplier applied to the token count before returning it to VS Code. Default: `1.0`. |
| Capabilities | `capabilities` | Capability declaration (for UI and routing logic; may also affect request construction). |
Expand Down
1 change: 1 addition & 0 deletions README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ VS Code 的 Copilot Chat 本身就支持登录 GitHub Copilot 账号,所以一
| 模型家族 | `family` | 便于分组/匹配的一类模型标识(如 `gpt-4`、`claude-3`)。 |
| 最大输入 Tokens | `maxInputTokens` | 最大输入/上下文 tokens(部分供应商语义为“输入+输出”总上下文)。 |
| 最大输出 Tokens | `maxOutputTokens` | 最大生成 tokens(部分供应商要求必填,如 Anthropic 的 `max_tokens`)。 |
| 汇报最大输出 Tokens | `reportedMaxOutputTokens` | 汇报给 VS Code 上下文窗口元数据的最大输出 tokens。适用于需要向 VS Code 暴露输出预留,但不应在 API 请求中发送输出 token 限制的供应商。 |
| 分词器 | `tokenizer` | 用于 VS Code Token 计数(`provideTokenCount`)的分词器。默认:`default`。 |
| Token 计数倍率 | `tokenCountMultiplier` | 在返回给 VS Code 前,对 Token 计数结果乘以该倍率。默认:`1.0`。 |
| 模型能力 | `capabilities` | 能力声明(用于 UI 与路由逻辑判断,部分场景也会影响请求构造)。 |
Expand Down
3 changes: 3 additions & 0 deletions l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@
"Enter max output tokens (leave blank to send default: {0})": "Enter max output tokens (leave blank to send default: {0})",
"Enter max output tokens (leave blank to let the provider decide)": "Enter max output tokens (leave blank to let the provider decide)",
"default: {0}": "default: {0}",
"Reported Max Output Tokens": "Reported Max Output Tokens",
"Enter max output tokens reported to VS Code (leave blank to use max output tokens)": "Enter max output tokens reported to VS Code (leave blank to use max output tokens)",
"uses max output tokens": "uses max output tokens",
"Tool Calling": "Tool Calling",
"Tool Calling Support": "Tool Calling Support",
"Select tool calling support": "Select tool calling support",
Expand Down
3 changes: 3 additions & 0 deletions l10n/bundle.l10n.zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@
"Enter max output tokens (leave blank to send default: {0})": "请输入最大输出令牌(留空则发送默认值:{0})",
"Enter max output tokens (leave blank to let the provider decide)": "请输入最大输出令牌(留空则由供应商决定)",
"default: {0}": "默认:{0}",
"Reported Max Output Tokens": "汇报最大输出令牌",
"Enter max output tokens reported to VS Code (leave blank to use max output tokens)": "请输入汇报给 VS Code 的最大输出令牌(留空则使用最大输出令牌)",
"uses max output tokens": "使用最大输出令牌",
"Tool Calling": "工具调用",
"Tool Calling Support": "工具调用支持",
"Select tool calling support": "请选择工具调用支持",
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,10 @@
"description": "%configuration.endpoints.models.maxOutputTokens.description%",
"default": 8192
},
"reportedMaxOutputTokens": {
"type": "number",
"description": "%configuration.endpoints.models.reportedMaxOutputTokens.description%"
},
"tokenizer": {
"type": "string",
"description": "%configuration.endpoints.models.tokenizer.description%",
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"configuration.endpoints.models.family.description": "Model family (e.g., gpt-4, claude-3). Defaults to model ID.",
"configuration.endpoints.models.maxInputTokens.description": "Maximum input/context tokens.",
"configuration.endpoints.models.maxOutputTokens.description": "Maximum output tokens.",
"configuration.endpoints.models.reportedMaxOutputTokens.description": "Maximum output tokens reported to VS Code for context window metadata. Does not affect API request parameters.",
"configuration.endpoints.models.tokenizer.description": "Tokenizer used for token counting in VS Code.",
"configuration.endpoints.models.tokenizer.enumDescriptions.0": "Alias of char4. The approximate algorithm used by VS Code officially (about 4 characters per token).",
"configuration.endpoints.models.tokenizer.enumDescriptions.1": "A conservative tokenizer based on UTF-8 bytes ensures that the model’s context limit is not exceeded, but it may trigger context compression more quickly due to significant deviations from actual token consumption.",
Expand Down
1 change: 1 addition & 0 deletions package.nls.zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"configuration.endpoints.models.family.description": "模型系列(例如:gpt-4、claude-3)。默认使用模型 ID。",
"configuration.endpoints.models.maxInputTokens.description": "最大输入/上下文令牌数。",
"configuration.endpoints.models.maxOutputTokens.description": "最大输出令牌数。",
"configuration.endpoints.models.reportedMaxOutputTokens.description": "汇报给 VS Code 上下文窗口元数据的最大输出令牌数,不影响 API 请求参数。",
"configuration.endpoints.models.tokenizer.description": "用于 VS Code 令牌计数的分词器。",
"configuration.endpoints.models.tokenizer.enumDescriptions.0": "char4 的别名。使用 VS Code 官方近似算法(约 4 字符/令牌)。",
"configuration.endpoints.models.tokenizer.enumDescriptions.1": "基于 UTF-8 字节的保守分词器,可以确保不会超出模型上下文限制,但由于可能与实际消耗的偏差较大导致更快地触发上下文压缩。",
Expand Down
42 changes: 36 additions & 6 deletions src/client/openai/codex-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,42 @@ export class OpenAICodexProvider extends OpenAIResponsesProvider {
_credential: AuthTokenInfo,
): Promise<ModelConfig[]> {
return [
{ id: 'gpt-5.5', maxInputTokens: 400000, maxOutputTokens: undefined },
{ id: 'gpt-5.4', maxOutputTokens: undefined },
{ id: 'gpt-5.2', maxOutputTokens: undefined },
{ id: 'gpt-5.4-mini', maxOutputTokens: undefined },
{ id: 'gpt-5.3-codex', maxOutputTokens: undefined },
{ id: 'gpt-5.3-codex-spark', maxOutputTokens: undefined },
{
id: 'gpt-5.5',
maxInputTokens: 272000,
maxOutputTokens: undefined,
reportedMaxOutputTokens: 128000,
},
{
id: 'gpt-5.4',
maxInputTokens: 922000,
maxOutputTokens: undefined,
reportedMaxOutputTokens: 128000,
},
{
id: 'gpt-5.2',
maxInputTokens: 272000,
maxOutputTokens: undefined,
reportedMaxOutputTokens: 128000,
},
{
id: 'gpt-5.4-mini',
maxInputTokens: 272000,
maxOutputTokens: undefined,
reportedMaxOutputTokens: 128000,
},
{
id: 'gpt-5.3-codex',
maxInputTokens: 272000,
maxOutputTokens: undefined,
reportedMaxOutputTokens: 128000,
},
{
id: 'gpt-5.3-codex-spark',
maxInputTokens: 100000,
maxOutputTokens: undefined,
reportedMaxOutputTokens: 32000,
},
];
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/config-ops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const MODEL_CONFIG_KEYS = [
'family',
'maxInputTokens',
'maxOutputTokens',
'reportedMaxOutputTokens',
'tokenizer',
'tokenCountMultiplier',
'capabilities',
Expand All @@ -39,6 +40,7 @@ export const MODEL_CONFIG_KEYS = [
export const BUILT_IN_SYNC_MODEL_CONFIG_KEYS = [
'maxInputTokens',
'maxOutputTokens',
'reportedMaxOutputTokens',
'tokenizer',
'tokenCountMultiplier',
'capabilities',
Expand Down
5 changes: 4 additions & 1 deletion src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ export class UnifyChatService implements vscode.LanguageModelChatProvider {
family: resolvedModelFamily,
version: '',
maxInputTokens: model.maxInputTokens ?? DEFAULT_MAX_INPUT_TOKENS,
maxOutputTokens: model.maxOutputTokens ?? DEFAULT_MAX_OUTPUT_TOKENS,
maxOutputTokens:
model.reportedMaxOutputTokens ??
model.maxOutputTokens ??
DEFAULT_MAX_OUTPUT_TOKENS,
capabilities,
category: {
label: provider.name,
Expand Down
7 changes: 7 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ export interface ModelConfig {
* others treat it as optional and apply a server-side default if omitted.
*/
maxOutputTokens?: number;
/**
* Maximum output tokens reported to VS Code for context window metadata.
*
* Use this when the provider should expose an output reserve to VS Code but
* should not receive an output token limit in API requests.
*/
reportedMaxOutputTokens?: number;
/**
* Tokenizer used for VS Code token counting (`provideTokenCount`).
*
Expand Down
17 changes: 17 additions & 0 deletions src/ui/model-fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,23 @@ export const modelFormSchema: FormSchema<ModelConfig> = {
return t('provider decides');
},
},
// Reported Max Output Tokens
{
key: 'reportedMaxOutputTokens',
type: 'number',
label: t('Reported Max Output Tokens'),
icon: 'eye',
section: 'details',
prompt: t(
'Enter max output tokens reported to VS Code (leave blank to use max output tokens)',
),
placeholder: t('Leave blank for default'),
positiveInteger: true,
getDescription: (draft) =>
draft.reportedMaxOutputTokens !== undefined
? draft.reportedMaxOutputTokens.toLocaleString()
: t('uses max output tokens'),
},
// Tool Calling (custom due to special limit option)
{
key: 'capabilities',
Expand Down