Skip to content
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ All four entries support thinking mode, tool calling, and 1M token context. See
| `deepseek-copilot.debugMode` | `minimal` | Diagnostic mode: `minimal` for token usage only, `metadata` for privacy-preserving logs, or `verbose` for full request dumps and pipeline snapshots under extension global storage. Full dumps may include sensitive prompt text, tool schemas, file snippets, and image descriptions. Use `DeepSeek: Open Request Dumps Folder` to open the dump location |
| `deepseek-copilot.visionModel` | *(auto)* | Vision Proxy used by V4 Flash and Pro. Auto mode selects Flash Vision Exp when available; configure another VS Code model or API endpoint with `DeepSeek: Configure Vision Proxy` |
| `deepseek-copilot.visionPrompt` | *(built-in)* | Prompt used by V4 Flash/Pro's Vision Proxy to describe image attachments. It does not affect native V4.1 Flash or Flash Vision Exp requests |
| `deepseek-copilot.experimental.stabilizeToolList` | `false` | Experimental. Tries to pre-activate VS Code/Copilot virtual tools so the DeepSeek API `tools` parameter is more complete and stable across turns. May improve context-cache hit rate when enabled tools change between turns. Can increase input tokens because more function definitions may be included; cache-hit input tokens are cheaper but still count toward usage. Usually leave it off with 64 or fewer enabled tools unless the tool list still changes across turns; do not enable it with more than 128 enabled tools |
| `deepseek-copilot.experimental.stabilizeToolList` | `false` | Experimental. Tries to pre-activate VS Code/Copilot virtual tools so the DeepSeek API `tools` parameter is more complete and stable across turns. May improve context-cache hit rate when enabled tools change between turns. Can increase input tokens because more function definitions may be included; cache-hit input tokens are cheaper but still count toward usage. Usually leave it off with 64 or fewer enabled tools unless the tool list still changes across turns |

Thinking Effort is configured from Copilot Chat's model picker for each DeepSeek model.

Expand Down
2 changes: 1 addition & 1 deletion README.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ API Key 存储在 VS Code 的 `SecretStorage` 中(macOS 钥匙串 / Windows
| `deepseek-copilot.debugMode` | `minimal` | 诊断模式:`minimal` 仅上报 token 用量,`metadata` 输出隐私安全日志,`verbose` 将完整请求 dump 和 pipeline snapshot 写入扩展 global storage。完整 dump 可能包含敏感提示词文本、工具定义、文件片段和图片描述。使用 `DeepSeek: 打开请求 Dump 目录` 打开 dump 位置 |
| `deepseek-copilot.visionModel` | *(自动)* | V4 Flash 和 Pro 使用的视觉代理。自动模式会在可用时选择 Flash Vision Exp;也可通过 `DeepSeek: 配置视觉代理` 改用其他 VS Code 模型或 API 端点 |
| `deepseek-copilot.visionPrompt` | *(内置)* | V4 Flash/Pro 的视觉代理用于描述图片附件的提示词,不影响 V4.1 Flash 或 Flash Vision Exp 的原生图片请求 |
| `deepseek-copilot.experimental.stabilizeToolList` | `false` | 实验性设置。尝试预先激活 VS Code/Copilot 的虚拟工具,让传给 DeepSeek API 的 `tools` 参数在多轮对话中更完整、更稳定。当已启用工具跨轮次变化时,可能提高上下文缓存命中率。代价是 input tokens 可能增加;缓存命中的 input tokens 单价更低,但仍会计入用量。64 个或更少已启用工具时通常无需开启,除非工具列表仍在跨轮次变化;超过 128 个已启用工具时不建议开启 |
| `deepseek-copilot.experimental.stabilizeToolList` | `false` | 实验性设置。尝试预先激活 VS Code/Copilot 的虚拟工具,让传给 DeepSeek API 的 `tools` 参数在多轮对话中更完整、更稳定。当已启用工具跨轮次变化时,可能提高上下文缓存命中率。代价是 input tokens 可能增加;缓存命中的 input tokens 单价更低,但仍会计入用量。64 个或更少已启用工具时通常无需开启,除非工具列表仍在跨轮次变化 |

思考强度可通过 Copilot Chat 的模型选择器对每个 DeepSeek 模型单独设置。

Expand Down
4 changes: 1 addition & 3 deletions docs/notices/tool-drift.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ DeepSeek V4 for Copilot Chat detected that the Tools list in the current chat ma

## Why This Happens

The DeepSeek Chat Completions API supports at most **128 tools** in one request. VS Code's Language Model API also lets a model declare the maximum number of tools it can receive per request.

When the experimental `deepseek-copilot.experimental.stabilizeToolList` setting is enabled, the extension tries to pre-activate VS Code/Copilot `activate_*` virtual tools before sending the request, so the DeepSeek API `tools` parameter is more complete and stable across turns.

If too many tools are available in the current environment, Copilot may trim, group, or defer tool expansion. The resulting Tools array may differ between turns.
Expand All @@ -14,7 +12,7 @@ If too many tools are available in the current environment, Copilot may trim, gr

DeepSeek uses a context KVCache for the input prefix. The Tools array is part of the request input; if it changes, the cache may not hit.

With this experimental setting enabled, each request may include more function definitions (names, descriptions, and JSON schemas), so **input tokens** can increase. Cache-hit input tokens are billed at a lower price but still count toward usage. It is usually unnecessary with fewer than **64 enabled tools**. Do not enable it with more than **128 enabled tools**, because DeepSeek supports at most **128 functions** in one `tools` request.
With this experimental setting enabled, each request may include more function definitions (names, descriptions, and JSON schemas), so **input tokens** can increase. Cache-hit input tokens are billed at a lower price but still count toward usage. It is usually unnecessary with fewer than **64 enabled tools**.

## What You Can Do

Expand Down
4 changes: 1 addition & 3 deletions docs/notices/tool-drift.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ DeepSeek V4 for Copilot Chat 检测到当前会话中的 Tools(工具)列表

## 为什么会发生

DeepSeek Chat Completions API 单次请求最多支持 **128 个 tools**。VS Code 的 Language Model API 也允许模型声明单次请求可接收的最大工具数。

当启用实验性设置 `deepseek-copilot.experimental.stabilizeToolList` 时,扩展会尝试预先激活 VS Code/Copilot 的 `activate_*` 虚拟工具,让传给 DeepSeek API 的 `tools` 参数在多轮对话中更完整、更稳定。

如果当前环境中可用工具太多,Copilot 可能会对工具列表进行裁剪、分组或延迟展开。不同轮次得到的 Tools 数组可能不完全一致。
Expand All @@ -14,7 +12,7 @@ DeepSeek Chat Completions API 单次请求最多支持 **128 个 tools**。VS Co

DeepSeek 对输入前缀使用上下文 KV 缓存(KVCache)。Tools 数组是请求输入的一部分;如果 Tools 数组变化,缓存可能无法命中。

开启这个实验性设置后,请求中可能包含更多函数工具定义(名称、说明和 JSON Schema),因此 **input tokens** 可能增加。缓存命中的 input tokens 单价更低,但仍会计入用量。少于 **64 个已启用工具** 时通常无需开启;超过 **128 个已启用工具** 时不建议开启,因为 DeepSeek 单次 `tools` 请求最多支持 **128 个 functions**。
开启这个实验性设置后,请求中可能包含更多函数工具定义(名称、说明和 JSON Schema),因此 **input tokens** 可能增加。缓存命中的 input tokens 单价更低,但仍会计入用量。少于 **64 个已启用工具** 时通常无需开启。

## 你可以怎么做

Expand Down
2 changes: 1 addition & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"deepseek-copilot.config.baseUrl.description": "DeepSeek API base URL. Defaults to the official DeepSeek API endpoint. [Reset to Default](command:deepseek-copilot.resetBaseUrl)\n\n[Set / Update API Key](command:deepseek-copilot.setApiKey) · [Clear API Key](command:deepseek-copilot.clearApiKey)",
"deepseek-copilot.config.requestHeaders.description": "Custom headers for chat completions. [Learn more](https://github.com/Vizards/deepseek-v4-for-copilot/blob/main/docs/settings/request-headers.en.md).",
"deepseek-copilot.config.maxTokens.description": "Maximum number of output tokens per request. Set to 0 to use the API default. Useful for controlling costs.",
"deepseek-copilot.config.experimental.stabilizeToolList.description": "**Experimental**: improve DeepSeek context-cache hit rate by pre-activating available tools.\n- When the enabled tools list changes across turns, this may improve DeepSeek context-cache hit rate.\n- Requests will include more function definitions, so input tokens may increase. Cache-hit input tokens are billed at a lower price, but still count toward usage.\n- This may add internal preflight tool calls to the current Copilot chat history. If you switch to another model in the same conversation, that model provider may reject or mishandle the replayed history. Start a new chat if model switching behaves unexpectedly.\n\nUse [Configure Tools](command:workbench.action.chat.configureTools) to **view and manage** your tool list:\n\n- 64 or fewer enabled tools: usually no need to enable this unless the tool list still changes across turns.\n- More than 128 enabled tools: not recommended. DeepSeek supports at most 128 functions in one `tools` request. Consider disabling tools you rarely use.",
"deepseek-copilot.config.experimental.stabilizeToolList.description": "**Experimental**: improve DeepSeek context-cache hit rate by pre-activating available tools.\n- When the enabled tools list changes across turns, this may improve DeepSeek context-cache hit rate.\n- Requests will include more function definitions, so input tokens may increase. Cache-hit input tokens are billed at a lower price, but still count toward usage.\n- This may add internal preflight tool calls to the current Copilot chat history. If you switch to another model in the same conversation, that model provider may reject or mishandle the replayed history. Start a new chat if model switching behaves unexpectedly.\n\nUse [Configure Tools](command:workbench.action.chat.configureTools) to **view and manage** your tool list:\n\n- 64 or fewer enabled tools: usually no need to enable this unless the tool list still changes across turns.\n- More than 64 enabled tools: consider this setting only if the tools list changes between turns and DeepSeek context-cache hits are poor. Larger tool lists may increase input tokens.",
"deepseek-copilot.config.debugMode.description": "Controls what diagnostic information DeepSeek Copilot writes. Token usage is always reported to Copilot regardless of this setting.\n\n- **Minimal** — Token usage only. No diagnostic logs or request dumps.\n- **Metadata** — Privacy-safe diagnostic metadata (request hashes, prefix overlap, tool schema changes). Does not contain prompt text — safe to share in public issue reports. View with [`DeepSeek: Show Logs`](command:deepseek-copilot.showLogs).\n- **Verbose** — Complete request payloads written to disk for local debugging. **Warning: contains sensitive prompt content.** View with [`DeepSeek: Open Request Dumps Folder`](command:deepseek-copilot.openRequestDumpsFolder).",
"deepseek-copilot.config.debugMode.minimal.label": "Minimal",
"deepseek-copilot.config.debugMode.minimal.description": "Token usage only. No diagnostic logs or dumps.",
Expand Down
2 changes: 1 addition & 1 deletion package.nls.zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"deepseek-copilot.config.baseUrl.description": "DeepSeek API 基础 URL,默认为官方 DeepSeek API 端点。[恢复默认](command:deepseek-copilot.resetBaseUrl)\n\n[设置/更新 API Key](command:deepseek-copilot.setApiKey) · [清除 API Key](command:deepseek-copilot.clearApiKey)",
"deepseek-copilot.config.requestHeaders.description": "聊天补全请求的自定义请求头。[了解更多](https://github.com/Vizards/deepseek-v4-for-copilot/blob/main/docs/settings/request-headers.zh.md)。",
"deepseek-copilot.config.maxTokens.description": "每次请求的最大输出 Token 数,设为 0 时使用 API 默认值,可用于控制成本。",
"deepseek-copilot.config.experimental.stabilizeToolList.description": "**实验性功能**:通过预先激活可用的工具来提升 DeepSeek 上下文缓存命中率。\n- 当已启用工具列表跨轮次变化时,这可能提高 DeepSeek 上下文缓存命中率;\n- 请求中将包含更多函数工具定义,input tokens 可能增加,虽然缓存命中的 input tokens 单价更低,但仍会计入用量;\n- 此设置可能会在当前 Copilot 对话历史中加入内部预检工具调用。在同一对话中切换到其他模型时,部分模型提供方可能无法正确重放这段历史;如果切换模型后请求异常,请新建对话后重试。\n\n 通过 [配置工具](command:workbench.action.chat.configureTools) **查看和管理**工具列表:\n\n- 64 个或更少已启用工具时通常无需开启,除非工具列表仍在跨轮次变化;\n- 超过 128 个已启用工具时不建议开启:DeepSeek 单次 `tools` 请求最多支持 128 个 functions。考虑禁用部分不常用工具。",
"deepseek-copilot.config.experimental.stabilizeToolList.description": "**实验性功能**:通过预先激活可用的工具来提升 DeepSeek 上下文缓存命中率。\n- 当已启用工具列表跨轮次变化时,这可能提高 DeepSeek 上下文缓存命中率;\n- 请求中将包含更多函数工具定义,input tokens 可能增加,虽然缓存命中的 input tokens 单价更低,但仍会计入用量;\n- 此设置可能会在当前 Copilot 对话历史中加入内部预检工具调用。在同一对话中切换到其他模型时,部分模型提供方可能无法正确重放这段历史;如果切换模型后请求异常,请新建对话后重试。\n\n 通过 [配置工具](command:workbench.action.chat.configureTools) **查看和管理**工具列表:\n\n- 64 个或更少已启用工具时通常无需开启,除非工具列表仍在跨轮次变化;\n- 超过 64 个已启用工具时,仅在工具列表跨轮次变化、DeepSeek 上下文缓存命中率不理想时考虑开启。工具列表越大,input tokens 也可能增加。",
"deepseek-copilot.config.debugMode.description": "控制 DeepSeek Copilot 写入的诊断信息量。无论此设置如何,token 用量始终上报给 Copilot。\n\n- **基本** — 仅上报 token 用量,不输出诊断日志或请求 dump。\n- **元数据** — 隐私安全的诊断元数据(请求哈希、前缀重合度、工具定义变更)。不含提示词原文,可安全附在公开 issue 中反馈问题。使用 [`DeepSeek: 显示日志`](command:deepseek-copilot.showLogs) 查看。\n- **详细** — 将完整请求体写入磁盘,供本地调试。**警告:包含敏感的提示词内容。** 使用 [`DeepSeek: 打开请求 Dump 目录`](command:deepseek-copilot.openRequestDumpsFolder) 浏览。",
"deepseek-copilot.config.debugMode.minimal.label": "基本",
"deepseek-copilot.config.debugMode.minimal.description": "仅上报 token 用量,不输出诊断日志或 dump。",
Expand Down
3 changes: 1 addition & 2 deletions resources/walkthrough/advanced-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ First, open VS Code's Tools configuration and check how many tools are enabled f
[Configure Tools](command:workbench.action.chat.configureTools)

- 64 or fewer enabled tools: there is usually no need to turn this on unless the tool list still changes across turns.
- More than 128 enabled tools: not recommended. DeepSeek supports at most 128 functions in one `tools` request, so DeepSeek Copilot cannot guarantee a stable `tools` list above that limit. Disable rarely used tools first, then consider enabling this setting.
- Between 64 and 128 enabled tools: consider this setting only if the tools list changes between turns and DeepSeek context-cache hits are poor.
- More than 64 enabled tools: consider this setting only if the tools list changes between turns and DeepSeek context-cache hits are poor. Larger tool lists include more function definitions and may increase input tokens.

This setting may improve cache hits by making the DeepSeek API `tools` parameter more complete and stable across turns. It may also increase input tokens because more function definitions can be included in each request.

Expand Down
3 changes: 1 addition & 2 deletions resources/walkthrough/advanced-settings.nls.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
[配置 Tools](command:workbench.action.chat.configureTools)

- 64 个或更少已启用工具:通常无需开启,除非工具列表仍在跨轮次变化。
- 超过 128 个已启用工具:不建议开启。因为 DeepSeek 单次 `tools` 请求最多支持 128 个 functions,超过这个数量后,DeepSeek Copilot 无法保证传给 DeepSeek 的 `tools` 列表稳定。请先 disable 掉一些不常用的工具,再考虑开启。
- 介于 64 到 128 个已启用工具:仅在工具列表跨轮次变化、DeepSeek 上下文缓存命中率不理想时,再考虑开启。
- 超过 64 个已启用工具:仅在工具列表跨轮次变化、DeepSeek 上下文缓存命中率不理想时,再考虑开启。工具列表越大,包含的函数定义越多,input tokens 也可能增加。

这个设置可能通过让 DeepSeek API 的 `tools` 参数在多轮对话中更完整、更稳定来提高缓存命中率。代价是每次请求可能包含更多函数工具定义,因此 input tokens 可能增加。

Expand Down
9 changes: 4 additions & 5 deletions src/consts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { DEEPSEEK_TOOLS_LIMIT } from './provider/tools/consts';
import type { ModelDefinition } from './types';

/**
Expand Down Expand Up @@ -57,7 +56,7 @@ export const MODELS: ModelDefinition[] = [
maxInputTokens: 655360,
maxOutputTokens: 393216,
capabilities: {
toolCalling: DEEPSEEK_TOOLS_LIMIT,
toolCalling: true,
imageInput: true,
nativeImageInput: true,
thinking: {
Expand Down Expand Up @@ -88,7 +87,7 @@ export const MODELS: ModelDefinition[] = [
maxInputTokens: 655360,
maxOutputTokens: 393216,
capabilities: {
toolCalling: DEEPSEEK_TOOLS_LIMIT,
toolCalling: true,
imageInput: true,
nativeImageInput: false,
thinking: {
Expand Down Expand Up @@ -119,7 +118,7 @@ export const MODELS: ModelDefinition[] = [
maxInputTokens: 655360,
maxOutputTokens: 393216,
capabilities: {
toolCalling: DEEPSEEK_TOOLS_LIMIT,
toolCalling: true,
imageInput: true,
nativeImageInput: false,
thinking: {
Expand Down Expand Up @@ -150,7 +149,7 @@ export const MODELS: ModelDefinition[] = [
maxInputTokens: 655360,
maxOutputTokens: 393216,
capabilities: {
toolCalling: DEEPSEEK_TOOLS_LIMIT,
toolCalling: true,
imageInput: true,
nativeImageInput: true,
thinking: {
Expand Down
4 changes: 0 additions & 4 deletions src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@ const zh: Translations = {
'vision.proxy.error.unknown': '未知错误',

// Request
'request.toolsLimitExceeded':
'DeepSeek 单次 tools 请求最多支持 {0} 个 functions,当前请求包含 {1} 个。请先用 VS Code 的 Configure Tools 关闭不常用的工具;如果正在使用实验性稳定工具列表设置,请关闭它。',
'request.preflightRoundLimitExceeded':
'实验性稳定工具列表设置已尝试 {0} 轮,仍无法得到稳定的已启用工具列表。请关闭该实验性设置,或先用 VS Code 的 Configure Tools 关闭不常用的工具。',
'notice.visionProxyMissing': '⚠️ 视觉代理不可用,DeepSeek 无法看到图片。[配置视觉代理]({0})',
Expand Down Expand Up @@ -434,8 +432,6 @@ const en: Translations = {
'vision.proxy.error.unknown': 'unknown',

// Request
'request.toolsLimitExceeded':
'DeepSeek supports at most {0} functions in a single `tools` request, but this request contains {1}. Use VS Code Configure Tools to disable tools you rarely use. If the experimental tool-list stabilization setting is enabled, turn it off.',
'request.preflightRoundLimitExceeded':
'Experimental tool-list stabilization tried {0} rounds but still could not get a stable enabled-tools list. Turn this experimental setting off, or use VS Code Configure Tools to disable tools you rarely use first.',
'notice.visionProxyMissing':
Expand Down
4 changes: 0 additions & 4 deletions src/provider/tools/consts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// DeepSeek Chat Completions API: "A max of 128 functions are supported."
// https://api-docs.deepseek.com/api/create-chat-completion#:~:text=A%20max%20of%20128%20functions%20are%20supported.
export const DEEPSEEK_TOOLS_LIMIT = 128;

export const ACTIVATE_TOOL_PREFIX = 'activate_';
export const PREFLIGHT_ACTIVATE_CALL_ID_PREFIX = 'deepseek_preflight_activate_';
export const MAX_PREFLIGHT_ROUNDS_PER_USER_REQUEST = 3;
Expand Down
Loading
Loading