Skip to content

Commit fa11e5b

Browse files
authored
feat(diagnostics): add opt-in cache trace diagnostics (#35)
Add privacy-preserving cache trace diagnostics behind deepseek-copilot.debug. Include request fingerprints, summary prefix comparison, tool schema hashes, reasoning cache warnings, vision resolution markers, and cache usage logs. Refactor provider request, stream, model, and token helpers without changing vision, conversion, or reasoning replay behavior.
1 parent e06c550 commit fa11e5b

13 files changed

Lines changed: 1565 additions & 289 deletions

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ Both support optional thinking mode, tool calling, and 1M token context.
8585
| `deepseek-copilot.baseUrl` | `https://api.deepseek.com` | API endpoint — change for self-hosted / proxied deployments |
8686
| `deepseek-copilot.maxTokens` | `0` | Max output tokens (`0` = no limit). Useful for cost control |
8787
| `deepseek-copilot.modelIdOverrides` | prefilled official ID map | API model IDs to send for DeepSeek V4 Flash / Pro. Change only for compatible third-party APIs with different model names |
88+
| `deepseek-copilot.debug` | `false` | Enable privacy-preserving diagnostic debug logs for troubleshooting. Does not log prompt text |
8889
| `deepseek-copilot.visionModel` | *(auto)* | Which Copilot model to proxy images through |
8990
| `deepseek-copilot.visionPrompt` | *(built-in)* | Prompt used to describe image attachments |
9091

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@
120120
"minimum": 0,
121121
"description": "%deepseek-copilot.config.maxTokens.description%"
122122
},
123+
"deepseek-copilot.debug": {
124+
"type": "boolean",
125+
"default": false,
126+
"description": "%deepseek-copilot.config.debug.description%"
127+
},
123128
"deepseek-copilot.modelIdOverrides": {
124129
"type": "object",
125130
"default": {

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"deepseek-copilot.config.title": "DeepSeek Copilot",
1818
"deepseek-copilot.config.baseUrl.description": "DeepSeek API base URL. Defaults to official DeepSeek API endpoint.",
1919
"deepseek-copilot.config.maxTokens.description": "Maximum number of output tokens per request. Set to 0 to use the API default (no limit). Useful for controlling costs.",
20+
"deepseek-copilot.config.debug.description": "Enable diagnostic debug logging for troubleshooting. Logs privacy-preserving metadata such as request hashes, prefix overlap, tool schema changes, and missing reasoning_content. Does not log prompt text.",
2021
"deepseek-copilot.config.modelIdOverrides.description": "Override the API model ID sent for each DeepSeek model. Defaults are prefilled with official DeepSeek IDs; change them only when using a compatible third-party API that uses different model names.",
2122
"deepseek-copilot.config.modelIdOverrides.deepseek-v4-flash.description": "API model ID for DeepSeek V4 Flash",
2223
"deepseek-copilot.config.modelIdOverrides.deepseek-v4-pro.description": "API model ID for DeepSeek V4 Pro",

package.nls.zh-cn.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"deepseek-copilot.config.title": "DeepSeek 助手",
1818
"deepseek-copilot.config.baseUrl.description": "DeepSeek API 基础 URL,默认为官方 DeepSeek API 端点。",
1919
"deepseek-copilot.config.maxTokens.description": "每次请求的最大输出 Token 数,设为 0 则不限制,可用于控制成本。",
20+
"deepseek-copilot.config.debug.description": "启用用于排查问题的诊断调试日志。日志只包含请求哈希、前缀重合度、工具定义变化、缺失 reasoning_content 等隐私保护后的元数据,不记录提示词原文。",
2021
"deepseek-copilot.config.modelIdOverrides.description": "覆盖各 DeepSeek 模型实际使用的 API 模型 ID,默认使用官方 DeepSeek ID,仅在对接不同模型名称的第三方 API 时需要修改。",
2122
"deepseek-copilot.config.modelIdOverrides.deepseek-v4-flash.description": "DeepSeek V4 Flash 的 API 模型 ID。",
2223
"deepseek-copilot.config.modelIdOverrides.deepseek-v4-pro.description": "DeepSeek V4 Pro 的 API 模型 ID。",

src/config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,11 @@ export function getMaxTokens(): number | undefined {
3333
const value = config.get<number>('maxTokens', 0);
3434
return value > 0 ? value : undefined;
3535
}
36+
37+
/**
38+
* Whether to log privacy-preserving diagnostic debug information.
39+
*/
40+
export function getDebugLoggingEnabled(): boolean {
41+
const config = vscode.workspace.getConfiguration(CONFIG_SECTION);
42+
return config.get<boolean>('debug', false);
43+
}

src/extension.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import vscode from 'vscode';
2+
import { getDebugLoggingEnabled } from './config';
23
import { WALKTHROUGH_ID, WELCOME_SHOWN_KEY } from './consts';
34
import { t } from './i18n';
45
import { logger } from './logger';
@@ -7,7 +8,10 @@ import { DeepSeekChatProvider } from './provider';
78
let activeProvider: DeepSeekChatProvider | undefined;
89

910
export function activate(context: vscode.ExtensionContext) {
10-
logger.info('Activating extension');
11+
logger.info(
12+
`Activating extension version=${context.extension.packageJSON.version}` +
13+
` debug=${getDebugLoggingEnabled()}`,
14+
);
1115

1216
context.subscriptions.push(
1317
vscode.commands.registerCommand('deepseek-copilot.showLogs', () => logger.show()),
@@ -57,7 +61,7 @@ export function activate(context: vscode.ExtensionContext) {
5761
logger.warn(t('extension.welcomeFailed'), error);
5862
});
5963

60-
logger.info('Extension activated');
64+
logger.info(`Extension activated version=${context.extension.packageJSON.version}`);
6165
} catch (error) {
6266
activeProvider = undefined;
6367
logger.error('Failed to activate DeepSeek extension', error);

0 commit comments

Comments
 (0)