Skip to main content

dsh-turn-delete

30Stars0Forks0Issues1Watchers

Delete one complete turn from a DeepSeek Harness session without deleting the session

Evidence5/5methodologySourceInstallMaintenanceDSH versionSecurity scan
Machine-auditedInstall commandRepo verifieddsh-plugin topicLicenseREADMEAI wiki
Language
TypeScript
License
MIT
Branch
main
deepseekdeepseek-harnessdshdsh-plugin

Install

cmdweb profile
$ dsh plugin --profile web add dsh-turn-delete

Run 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.6peerDependencies 声明范围 <0.2.0-0,已验证 rc.6 / rc.7
Node.js>=22.19engines.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)

Read the usage guide →

Install steps, key points, FAQ and compatibility for this plugin — auto-derived from indexed fields.

Listing badge

Listed on deepseek-plugin.org
[![Listed on deepseek-plugin.org](https://img.shields.io/badge/listed_on-deepseek--plugin.org-007EC6)](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.

← Back to plugin directory