dsh-session-user-id
DiscoveredA per-session, persistent, and random DeepSeek API user_id
dsh-session-user-id
给每条 DSH 会话分配一个持久、唯一、随机的 DeepSeek API user_id。
背景
DeepSeek API 的请求体支持 user_id 字段([a-zA-Z0-9\-_]+,最长 512),用于内容安全隔离、KVCache 隔离、调度隔离。
官方明确要求:不要在 user_id 中包含用户隐私信息 —— 所以本插件只用随机 UUID v4。
DSH 本身只有一个全局匿名 user id(getOrCreateAnonymousUserId()),没有会话概念。但 deepseekLlmApiExtensions 扩展点的 request 带 sessionId,而 provider 返回的 value 会 merge 成 request body 的顶层字段 —— 正好用来注入 user_id。
不改 DSH 源码。
行为
- 第一次见到某个
sessionId→ 生成 UUID v4、写入映射文件、之后永久不变 - 没有
sessionId的请求(例如某些内部调用)→ 不注入,保持默认 - compaction / session-title 等子请求沿用同一
sessionId⇒ 同一个user_id
映射文件
$DSH_HOME/session-user-ids.json
{ "version": 1, "sessions": { "<sessionId>": "<uuid>" } }
写入用「先写临时文件再 rename」的原子方式,避免半截文件。
权衡
user_id 隔离 = 每条会话独立的 KVCache。
会话之间不再共享缓存,共同前缀(system prompt、人设)要重新计算 → 命中率可能下降、成本上升。这是隔离的代价,换来的是会话之间不互相污染。
安装
① 通过插件市场(推荐)
在 awesome-dsh-plugin 的目录里找到本插件,
或在 dsh 的 插件 → 发现 里搜索 dsh-session-user-id,点安装。
② 手动安装
任选一种,不要两种同时用:
A. 复制 + 手写 insert(适合本地开发)
-
把本目录复制到
$DSH_HOME/profiles/web/node_modules/dsh-session-user-id/ -
在
$DSH_HOME/profiles/web/cordis.patch.yml加:- insert: - id: session-user-id name: 'dsh-session-user-id' -
重启 dsh,或让 Loader 重载配置
B. dsh plugin add(需要包已发布到 npm)
dsh plugin --profile web add dsh-session-user-id
⚠ 用 B 之后,包名会进
dsh.profile.bundles,bundles 层会读本包自带的cordis.patch.yml;此时不要再做 A 的第 2 步 —— 同一个 id 会被插两次, DSH 启动会直接失败。
依赖
deepseekLlmApiExtensions(DSH ≥ 0.2.1 自带)
Comments
Loading…
Similar plugins
by duanyunlun
Per-provider request headers in the DeepSeek Harness Models settings page, with per-conversation ${sessionId} expansion.
★ 0
MIT
JavaScript
Sep 11, 2026
dsh plugin --profile web add dsh-provider-headersby DM-Odyssey
dsh Session Manager(会话管理插件)
★ 0
MIT
JavaScript
Aug 19, 2026
dsh plugin --profile web add @dm-odyssey/dsh-session-managerby TheM14
DeepSeek Harness 已归档会话管理与新预设续接插件。Archived-session management and preset continuation plugin for DeepSeek Harness.
★ 0
↓ 238/wk
MIT
JavaScript
Aug 21, 2026
dsh plugin --profile web add dsh-session-cleanerby LRainner
为 DeepSeek Harness 提供不隶属于任何工作区的独立会话,复用原生输入区,并带独立侧边栏面板。MIT。
★ 0
MIT
TypeScript
Oct 23, 2026
dsh plugin --profile web add dsh-plugin-standalone-sessionby awol2005ex3
DeepSeek Harness(`dsh`)插件:为单机的 harness 增加**用户管理**与**会话按用户隔离**。
★ 0
Apache-2.0
TypeScript
Sep 28, 2026
dsh plugin --profile web add dsh-user-managerby PwnKY
DeepSeek Harness 的 Codex 式会话深度链接插件:dsh:// 深链,跨对话读取上下文
★ 7
↓ 253/wk
MIT
JavaScript
Oct 13, 2026
dsh plugin --profile web add dsh-session-link