Leeminjing/dsh-messages-sanitizer
DeepSeek 防护插件:自动修复消息数组中的无效 tool_calls/tool 消息配对,防止 400 INVALID_REQUEST 会话崩溃。
Project Overview项目介绍
This is a native plugin built exclusively for DeepSeek Harness, designed to resolve persistent session freezes caused by invalid message arrays after unexpected tool call crashes. When an unexpected tool scheduling crash leaves orphan unpaired tool_calls in the session history, every subsequent API request will return a 400 INVALID_REQUEST error, locking the entire session and preventing any further conversation. The plugin automatically sanitizes and corrects the messages array to bring it into compliance with OpenAI's tool call protocol requirements, allowing the conversation to resume normally right after the crash.
The plugin uses a four-layer defense system to handle invalid messages across different unexpected crash scenarios: auto-resume, pre-request prevention, error healing, and fallback sanitization. It complements the official source code fix released by the DeepSeek Harness team, working as an additional safety net that does not require modifying DSH source code to operate correctly. It automatically fixes messages at runtime, can rescue older already corrupted sessions, and lets users continue their work without waiting for a new official DSH release to fix the issue.
Installation is done via a single DSH CLI command, and the plugin activates automatically after restarting DSH, with a simple configuration toggle to enable or disable it. It is a zero-build pure ESM module that loads directly via the cordis loader, uses core dependencies already included in the DSH runtime, and requires no extra dependency installation from users. After modifying the plugin code, you only need to restart DSH to apply changes, and it ships with 40 test cases to ensure functional stability across different common use cases.
这是一个专为 DeepSeek Harness 开发的原生插件,专门解决工具调度崩溃后消息数组不合法导致的会话卡死问题。当工具调度发生异常崩溃后,会话历史会留下未配对的孤儿 tool_calls,之后每一轮请求都会触发 API 返回 400 INVALID_REQUEST 错误,导致整个会话卡死无法继续。本插件会自动矫正消息数组,让它符合 OpenAI 协议规范,恢复对话正常运行。
插件通过四层防御机制保障会话正常:自动续跑、前置预防、错误治愈、兜底矫正,针对不同场景的非法消息进行处理。它和 DeepSeek Harness 官方的源码修复互补,不需要修改 DSH 源码,就能在运行时自动修复消息,旧的已崩溃会话也能被救回,用户不需要等待 DSH 发版就能继续使用。
安装可以通过 DSH 命令行一键完成,安装后重启 DSH 即可生效,支持通过配置开关启用或停用插件。插件是零构建的纯 ESM 模块,直接由 cordis 加载器加载,依赖 DSH 运行时自带的核心包,不需要额外安装依赖,修改代码后仅需重启 DSH 就能生效,还自带 40 个测试用例保证功能稳定。
请帮我安装这个 DSH 插件。安装前先完成【兼容性检查 + 安全性检查】,检查通过再动手。
插件:dsh-messages-sanitizer(Leeminjing/dsh-messages-sanitizer)
仓库:https://github.com/Leeminjing/dsh-messages-sanitizer
本站详情页:https://www.yhbd.top/plugins/leeminjing-dsh-messages-sanitizer/
本站登记:类型 plugin · 归类 原生 DSH 插件 · 许可证 MIT · ⭐ 4 · 最近提交 2026-09-04 · 主语言 JavaScript
按下面顺序执行,每步先把结论告诉我,再进入下一步:
【1 兼容性检查】
① 我这边:DSH 版本、Node 版本、操作系统、当前 profile(web / desktop)。
② 读它的 README、package.json、插件 manifest,列出它要求的 DSH 版本 / Node 版本 / 操作系统 / 外部依赖 / 需要另外先装的运行时。
③ 逐条比对,结论只写「满足 / 不满足 / 未知」三种;不满足的给出可行替代方案。
④ 检查是否和我已装的插件冲突:命令名重复、skill / tool 重名、端口占用、重复注册的 MCP server。
【2 安全性检查】
① 仓库可信度:和上面「本站登记」是否一致;star / fork 数、创建时间、最近提交,是否归档或长期停更。
② 安装脚本:逐行看 package.json 的 preinstall / install / postinstall,以及 install.sh、setup.ps1 之类脚本。出现 curl|bash、下载后直接执行、混淆代码、访问与插件功能无关的域名,立刻停下来告诉我,不要继续装。
③ 依赖:列出新增依赖,标出无人维护、或与知名包拼写近似的可疑包(typosquatting)。
④ 权限与副作用:它会读写哪些目录、访问哪些域名、需要哪些 DSH 权限(filesystem / network / shell / clipboard 等),以及怎么卸载和回滚。
⑤ 如果它要求 sudo / 管理员权限,或权限明显超出功能所需,先停下来问我。
【3 安装】
上面两步没有「不满足」和「高危项」时才执行;用官方推荐方式安装,不要自行提权。
【4 汇报】
用表格输出:检查项 / 结论 / 依据 / 是否需要我决策。拿不准的一律写「未知」并说明要我怎么确认——不要猜,也不要替我决定。
Send this message to DSH in your current session: it verifies compatibility and security first (answering met / not met / unknown item by item) and only installs once everything checks out — it will stop and ask you if it finds a high-risk item. The box scrolls; the copy is the full prompt. CLI install commands may not be accurate across systems, so DSH is the safer route.把上面这条消息直接发给当前会话里的 DSH:它会先核对兼容性与安全性(逐条给「满足 / 不满足 / 未知」),确认没问题再安装,有高危项会停下来问你。框内可滚动,复制到的是完整提示词;安装命令不一定准确,发给 DSH 更稳。
- Only 4 stars - very few users, little community feedback星标只有 4,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项
Compatibility兼容性
- DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
- External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
- Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册
Security安全性
- Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
- Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
- curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
- Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
- Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
- Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式
Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。
Or use CLI install (for developers)或使用命令行安装(适合开发者)
CLI Install命令行安装
dsh plugin --profile web add github:Leeminjing/dsh-messages-sanitizer
把 Leeminjing/dsh-messages-sanitizer 加入你的 DSH 配置(web profile)即可启用。
READMEREADME
dsh-messages-sanitizer
⚠️ 已退役 —— dsh ≥ 0.2.0 已在运行时根治本插件要补的问题
本插件的存在前提是:工具调度崩溃会在会话里留下孤儿 tool_calls,导致之后每一轮都被
400 INVALID_REQUEST 拒绝。这个前提在 dsh 0.2.0 已不成立:
@deepseek-ai/dsh-agent-loop在 step 抛错时用ToolCallRecovery为所有未应答的调用 合成并追加tool/result事件(带TOOL_NOT_STARTED/TOOL_OUTCOME_UNKNOWN错误码);- 会话恢复时
interruptedTurnClosers()会把修复写进持久日志; deriveMessages()自身就会丢弃空 content 的 assistant 消息。
而且插件的主路径在 0.2.0 上无法实现:agent/pre-step 返回的每条消息都被循环以
session.append("user/message", …) 落盘,而会话校验强制该事件的消息 role 必须是
user——注入 tool 角色的合成结果会直接抛错。其余分层所依赖的 Session#events、
surfaceOp.{start,end}、tool-result 内容块在 0.2.0 也均已移除或改名。
结论:不要安装本插件。直接用 dsh ≥ 0.2.0。 本仓库已归档,仅作历史记录保留;
npm 包已标记 deprecated。0.1.1 只对仍停留在 dsh 0.1.x 的用户有意义。
🔧 你在 DeepSeek Harness 里创建 / 加载插件,对话崩了吗?本插件专治这个。
开发或加载本地插件时,一次工具调度崩溃(
Cannot read properties of undefined (reading 'prepare'))就会在会话里留下孤儿tool_calls,之后每一轮都被400 INVALID_REQUEST拒绝、重试无效、会话卡死。本插件自动把 messages 数组修回 合法,让对话继续,不再卡死。
💥 Before ✅ After (安装本插件后)
插件崩溃 插件崩溃
↓ ↓
留下孤儿 tool_calls messages 自动修复
↓ ↓
400 INVALID_REQUEST 死循环 对话继续
↓
对话卡死
DeepSeek Harness 消息数组自动矫正插件:防止一切因 messages 数组不合法导致的聊天崩溃。
背景:你遇到的那个崩溃
OpenAI 兼容协议要求工具调用成对出现,且 tool 消息必须紧邻其 assistant tool_calls 消息(中间不能插入任何 user / assistant 消息):
assistant { content: ..., tool_calls: [{ id: "call_A", ... }] }
tool { tool_call_id: "call_A", ... } ← 必须紧跟覆盖每个 id
当一次工具调度在「记录 assistant tool_calls / tool/call 之后、产出 tool 结果之前」
崩溃时(例如 ctx.tools[symbol].prepare 抛 Cannot read properties of undefined),
会话日志会留下一个没有 tool 消息响应的孤儿 tool_calls。下一轮请求把历史拼成:
[..., assistant{tool_calls:[write]}, user{...}] ← 非法
API 直接返回 400 INVALID_REQUEST,且重试时历史原封不动,反复被拒,会话卡死。
如果崩溃后还有多次失败重试,日志里还会留下多条重复的 user 消息横在孤儿
assistant 与注入点之间,让"补插 tool 消息"也无法满足紧邻约束。
背景(与 DSH 官方讨论对照)
同类故障在 DeepSeek Harness 官方仓库也已被跟踪: Discussion #4843「残缺或孤立的 tool_calls 记录导致 DeepSeek 接口返回 400」 描述了「会话历史中存在无配对 result、或 id/name/arguments 残缺的 tool_calls 时,chat-completions 接口返回 400」, 并从 harness 源码层(agent-loop 剥离、llm-deepseek 合成 fallback id、compaction 的 tool-pairing 按 callId 而非计数) 给出根因修复 patch。
Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →
liangmianya/dsh-synapse
alaliqing/claude-paper
acryldev/acryl
omdsh-dev/dsh-annotation
Anionex/dsh-turn-rewind
Tyan66666/billion-context-dsh
qkycir-123/dsh-run2skill