Delete one complete turn from a DeepSeek Harness session without deleting the session
- Language
- TypeScript
- License
- MIT
- Branch
- main
Install
$ dsh plugin --profile web add dsh-turn-deleteRun the command above in your terminal to install this plugin via the dsh CLI. You can switch Profile in the top-right corner. New to dsh? Read the beginner tutorial
Install via your agent
Install the DeepSeek Harness plugin hanshenmesen/dsh-turn-delete for me: review the repository at https://github.com/hanshenmesen/dsh-turn-delete first, then run the install command and verify the plugin loads successfully.
Paste this instruction to the DSH Web GUI assistant — it will install and verify for you.
一句话定位
这个插件让你在不删除整个会话的前提下,单独移除其中一次已经结束的完整对话轮次(包含提问、回复与工具记录),删除结果会以持久事件写入,刷新或重启后仍然生效。
核心能力
- 在每次已完成顶层轮次的最后一条助手回复旁显示一个删除按钮,点击后会弹出确认对话框
- 任务正在运行或处于 subagent 对话时,删除按钮自动隐藏或禁用,避免误操作
- 删除会改写该轮次在模型上下文中的可见性,但保留 Session id、标题、工作区、后续轮次与原始事件日志
- 通过持久化的「tombstone(墓碑)」事件记录删除结果,刷新页面或重启 profile 后依然生效
- 对同一次删除请求做幂等处理,重复点击不会写入多条墓碑事件
- 当目标轮次尚未结束、或已经被压缩进上下文摘要时,主动拒绝删除,避免只删掉模型可见上下文的一部分
技术实现
- 语言: TypeScript(含 React 18 浏览器端组件)
- 关键依赖: @deepseek-ai/cordis、@deepseek-ai/dsh-agent、@deepseek-ai/dsh-session、@deepseek-ai/dsh-llm
- 架构模式: 双半挂载——Host 端在 Node 进程内注册
POST /dsh-turn-delete路由并通过agent.runMaintenance取得维护租约后写入 tombstone 事件;Browser 端通过slots.inject注入conversation.chat.assistant-actions(删除按钮)与conversation.chat.turnTail(删除后行级隐藏标记),并向conversationEvents注册自定义节点定义把 tombstone 投影到 Turn - 入口文件: src/index.ts(Host)、src/client/index.tsx(Browser)
适用场景
当一个长 Session 中间某一轮对话走了错误的提问方向、产生了大量无用的工具调用或敏感内容,用户既不想丢掉整个 Session 重新开始,也不想让模型在后续轮次继续被这些内容影响时,用这个插件把那一次完整轮次从模型上下文里抹掉,同时保留 Session 的历史与结构。
前置依赖与兼容性
| 依赖 | 最低版本 | 说明 |
|---|---|---|
| DeepSeek Harness | >=0.1.0-rc.6 | peerDependencies 声明范围 <0.2.0-0,已验证 rc.6 / rc.7 |
| Node.js | >=22.19 | engines.node 强制要求 |
| 平台 | 跨平台 | 适配 Web profile 及基于 Web 的桌面套壳;纯 Node 进程仍需可访问浏览器端 |
| 原生模块 | 无 | 未引入任何 napi / native 模块 |
安装方式
dsh plugin --profile web add github:hanshenmesen/dsh-turn-delete
配置项
本插件无需额外配置。
常见问题
Q: 安装后需要重启 dsh web 吗?
A: 需要。README 第 33 行明确说明安装后必须重启 dsh web 才能加载新插件。
Q: Subagent 产生的轮次能删除吗?
A: 不能。源码 src/client/TurnDeleteAction.tsx 第 61 行在 subagent 非空时直接返回 null,删除按钮不会渲染。
Q: 任务运行过程中能删除轮次吗?
A: 不能。源码第 49、97、100 行把 running 状态映射为按钮 disabled 与灰色半透,点击不会触发请求。
Q: 重复触发同一次删除会怎样?
A: 幂等返回。src/turn-delete.ts 第 108-109 行检测到同 turn 已存在 tombstone 事件后直接返回原 seq,不会重复写入。
Q: 删除后原始审计数据还在吗?
A: 在。README 第 76 行说明删除只改写后续模型上下文,原始 append-only 事件日志保留用于审计与回放。
Q: 已经压缩进摘要的轮次能单独删除吗?
A: 不能。src/turn-delete.ts 第 121、132、137、143、148 行会在表面节点与历史部分重叠时抛 TURN_COMPACTED,避免只删掉模型可见上下文的一部分。
Q: 升级 Harness 之后需要做什么?
A: 建议新建一个含三个短轮次的临时 Session 并删除中间轮次做一次验证(README 第 62 行)。
Q: 这个插件需要任何配置吗?
A: 不需要。代码中没有 Schema 字段,安装后无需任何额外配置。
上手难度
入门 — 安装一条命令、无需任何配置即可使用;但需要理解 DSH 的 Session / Turn / Agent 概念才能理解删除边界条件。
已知问题与限制
- 当目标轮次已被压缩进上下文摘要(与其他历史合并进 compaction 替换节点)时,删除请求会被拒绝,提示「这一轮已经被压缩进上下文摘要,无法单独删除」
- 当 Session 的目标 Agent 当前不在线或不再活跃时,请求返回
TARGET_NOT_FOUND,需要重新打开 Session - 删除请求体上限为 16 KB(src/http.ts:7),超出后返回
INVALID_REQUEST错误 - 当 Agent 维护租约被其他任务占用时,请求返回 423
AGENT_BUSY;前端会把按钮置灰并提示「任务正在运行,请结束后再删除」 - 浏览器端的行级隐藏效果依赖 Chat 列表 DOM 结构(
[data-chat-flow-kind="turn-tail"]等属性),若 Harness 在升级后调整内部 DOM 结构,DeletedTurnMarker 可能需要同步适配(src/client/DeletedTurnMarker.tsx:11-23)
English | 中文
Delete one complete closed turn from a DeepSeek Harness conversation without deleting or replacing the Session. The action appears beside the final assistant response for each completed top-level turn.
Demo
Delete the middle turn after confirmation while keeping the same Session and its later turn. This was recorded through the real DeepSeek model flow on DeepSeek Harness 0.1.0-rc.7.

Install
From npm (recommended):
dsh plugin --profile web add dsh-turn-delete
From GitHub:
dsh plugin --profile web add github:hanshenmesen/dsh-turn-delete
From a prebuilt GitHub Release:
dsh plugin --profile web add https://github.com/hanshenmesen/dsh-turn-delete/releases/latest/download/dsh-turn-delete.tgz
Restart dsh web after installation. To remove it:
dsh plugin --profile web remove dsh-turn-delete
Behavior
- A trash action appears only on completed ordinary Session turns. Subagent transcripts do not expose it.
- Deletion requires confirmation and is disabled while the Session is running.
- The prompt, assistant messages, and tool records for the selected turn are removed from the Session's current model surface.
- The Session id, title, workspace association, later turns, and original append-only event log remain intact.
- A durable zero-content replacement event records the deletion. Reloading the page or restarting the profile preserves it.
- Repeating the same request is idempotent.
The plugin refuses deletion when the target turn is still open or has already been merged into a compaction replacement with other history. This prevents deleting only part of model-visible context.
Design
The Host half registers POST /dsh-turn-delete, claims the target Agent's maintenance lease, validates the complete closed-turn surface span, appends a zero-content replacement, and waits for sessions.flush() before acknowledging success.
The browser half contributes to the public conversation.chat.assistant-actions and conversation.chat.turnTail slots. A Conversation definition projects the durable tombstone onto the target Turn. DeepSeek Harness does not yet expose a public whole-Turn visibility hook, so the tail contribution applies a narrow presentation compatibility layer to the Chat rows between adjacent Turn tails. Model context deletion does not depend on that compatibility layer.
Compatibility
- DeepSeek Harness
0.1.0-rc.6and0.1.0-rc.7 - Node.js 22.19 or newer
- Web profile and Web-based desktop shells
DeepSeek Harness is in developer preview. After upgrading Harness, verify the plugin once with a disposable Session containing three short turns and delete the middle one.
Development
npm install
npm run check
dsh plugin --profile web add -w link:/absolute/path/to/dsh-turn-delete
npm run check type-checks and builds both plugin halves, runs the unit/UI tests, and verifies the npm package contents.
Security
Like every DSH plugin, this package runs with the Harness process's permissions. Review the source before installing third-party plugins. The deletion changes future model context but deliberately retains the original append-only events for audit and replay.
License
MIT
Read the usage guide →
Install steps, key points, FAQ and compatibility for this plugin — auto-derived from indexed fields.
Listing badge
[](https://deepseek-plugin.org/plugins/hanshenmesen/dsh-turn-delete)Paste this markdown into your GitHub README to link back to this listing. The badge only states the listing — not a security endorsement.