dsh-conductor:在同一会话里刷新上下文,并把长聊控在成本之内

前言

在 DeepSeek Harness(DSH)里跑协调类会话,每一轮请求都会带上当前仍留在上下文里的整段历史。聊了一周之后,单步请求的 token 往往以十万计,其中大量是过期的工具输出。靠压缩可以把体积压下去,但容易变成「摘要套摘要」;直接开新会话则能减负,却会丢掉会话 id、标题、侧栏位置和脚本里绑定的 chat id,积累下来的协作状态也不连贯。

dsh-conductor 是维护者 lucagiftzek 发布的客户端插件(npm 包名 @lucagiftzek/dsh-conductor,当前版本 0.2.0)。它把「原地刷新上下文、按提示回滚会话与文件、自动压缩与失败恢复、多会话编排」收进侧栏里的一个 Conductor 标签页,并配套一批以斜杠命令和工具为主的操作面。

这是什么

dsh-conductor 面向 DSH web 配置(profile web) 用户:在 不新开 chat、不改变 chat id 的前提下,用模型生成的 handoff 把上下文清空并重写;完整转录仍可见并可归档为 Markdown。同一插件还提供 pin、drop、消息版本、Ghost 跨会话投递、/checkpoint 与 /rewind、按阈值自动压缩或定时 /new、失败轮次恢复,以及自 dsh-orchestrator 等插件并入的编排能力。

插件分类为客户端;侧栏展示依赖 dsh-better-sidebar。

核心功能

以下能力均来自项目 README 中的功能表与说明。

上下文与压缩

命令 作用
/new [focus] 在同一会话内刷新上下文:一次模型调用基于全量上下文写出 handoff,handoff 成为新历史;handoff 另存为文件
/clear 清空模型上下文,保留 chat;占位式压缩,不调用模型
/force-compact [--pointer] [focus] 在超出模型窗口时仍尝试压缩(来自 dsh-force-compact 思路);可分块 map-reduce 或无模型机械 checkpoint
/context 列出占用上下文的内容,按体积排序,并读 live surface 与 token 计量

README 中说明:测试环境下 /new 之后的第一步请求规模接近「全新会话的第一步 + handoff(约 2K tokens 内)」,固定成本主要是系统提示、工作区说明与工具定义。

精选、固定与版本

  • /drop ...、/undrop:把工具输出、消息或整步从上下文中移除(可恢复);转录与存档文件保留原文。
  • /pin、/unpin、星标:消息在每次 /new、/clear 与压缩后仍以原文回到上下文(侧库存储)。
  • Versions:编辑用户或模型消息后,界面显示当前文本并带 v2 等标记,历史版本保留且可 diff。

Ghost 与跨会话协作

  • Ghost:/post、dsh-post、chats post 向另一会话投递静默消息——在目标会话中显示为带 Ghost 标签的消息,下一轮由该会话模型读取,不会唤醒目标会话。
  • /relay <chat>:本会话每次最终回答以 ghost 形式进入协调会话,无需额外脚本上报。

回滚与自动化

  • /checkpoint、/rewind:回到任意较早的用户提示点;可恢复对话、agent 改过的文件,或两者;文件预像在 Conductor 自有存储中(不修改你的 git);被回滚部分归档。
  • /auto level:按你设定的模型窗口占用百分比,在告警后自动压缩或 handoff 刷新上下文。
  • /auto new:在空闲时按每日时刻或每 N 轮自动 /new。
  • /recovery:在限速、提供商错误、回答截断、进程重启等情况下自动续跑;配额或凭证错误时立即停止(承接 dsh-continue 一类能力)。

检索、模板与编排

  • /recall:在本会话历史 epoch(归档、drop 项、handoff)中做关键词检索,无模型、无索引。
  • Handoff template:自定义 handoff 分段,可全局或单会话,替换默认八段结构。
  • Orchestration:agents(spawn、prompt、fork、cancel)、tasks(command、scrape、http、agent)、runners、provider cards(自 dsh-orchestrator 并入,详见仓库 docs/ORCHESTRATION.md)。

Conductor 侧栏标签

依赖 dsh-better-sidebar 注入后,侧栏 Conductor 标签含上下文计量与五个子标签:Context、Pins、Inbox、History、Agents。

安装与启用

环境要求(来自 README 与 package.json):

  • DSH ≥ 0.2.1-rc.5
  • web profile
  • dsh-better-sidebar(DSH 0.2.1 上可固定 dsh-better-sidebar@0.28.2;该包最新版需要 DSH 0.2.2)
  • Node ≥ 22.5(插件 engines 字段)

官方安装示例:

cd ~/.dsh && dsh plugin --profile web add dsh-better-sidebar && dsh plugin --profile web add @lucagiftzek/dsh-conductor
# on DSH 0.2.1 pin the sidebar: dsh plugin --profile web add dsh-better-sidebar@0.28.2 (its latest needs DSH 0.2.2)
# or from GitHub: dsh plugin --profile web add github:lucagiftzek/dsh-conductor
# restart dsh web

README 顶部另给出一组等价命令(可先装 sidebar 宿主,再装 conductor):

dsh plugin --profile web add dsh-better-sidebar   # the tab host, skip if installed (on DSH 0.2.1: dsh-better-sidebar@0.28.2)
dsh plugin --profile web add @lucagiftzek/dsh-conductor
# or from GitHub: dsh plugin --profile web add github:lucagiftzek/dsh-conductor
# restart dsh web, then open the Conductor tab from the sidebar's + menu

说明:npm 新包发布后,经 dsh plugin add 拉取可能有约一天延迟(pnpm minimum release age);走 GitHub 源可立即使用。

首次运行:新装后 Conductor 标签会有一分钟引导(自主行为、ghost 与 script secret、agents/tasks)。可选默认跳过;可从标签 ... 菜单或 Settings 重跑。自动化安装可通过在 dsh-conductor 配置行写入 setupCompleted: "<ISO time>" 跳过引导。

自旧插件迁移:若已使用 dsh-orchestrator、dsh-force-compact 或 dsh-continue,README 建议先按上法安装 dsh-conductor,再执行迁移脚本(先 dry run)并重启:

M=~/.dsh/profiles/web/node_modules/@lucagiftzek/dsh-conductor/scripts/migrate-profile.mjs
node $M                                          # shows what changes
node $M --apply                                  # backs up, then edits package.json and cordis.patch.yml
cd ~/.dsh/profiles/web && pnpm install           # then restart dsh web

典型用法

  1. 长会话控 token:在协调 chat 中需要「清零历史负担但保留 id 与 pin」时,发送 /new 或带聚焦参数的 /new [focus];进行前可在 Conductor 的 Context 子标签查看 /context 等价信息。
  2. 剔除去噪工具输出:对过大的一次性工具结果使用 /drop,需要时用 /undrop 放回;关键结论用 /pin 固定,避免下次 /new 丢失。
  3. 协作而不唤醒 worker:worker 会话用 /post 或 dsh-post 向主会话投递 Ghost;主会话用 /relay <chat> 集中收取各会话最终答案。
  4. 试错后回滚:在错误提示点之后若文件与会话走向不对,使用 /rewind 预览并恢复到该提示点之前的状态(含 agent 编辑文件的预像)。
  5. 无人值守长跑:设置 /auto level 阈值与 /auto new 计划;配合 /recovery 处理限速与中断(注意配额与凭证类错误会立即停止)。

本地开发链接安装(README 节选):在 ~/.dsh/profiles/web/package.json 的 dependencies 中加入 "@lucagiftzek/dsh-conductor": "link:/path/to/dsh-conductor",并把包名写入 dsh.profile.bundles,在 profile 目录执行 pnpm install 后重启。

适用场景与注意

更适合:需要 单 chat 长期身份不变 的编排会话、多 agent 协作、以及对上下文体积和失败恢复有明确运维需求的 DSH web 用户。

使用前应了解:

  • 插件以 当前 DSH 进程权限 运行,会参与上下文改写、文件预像存储与编排任务;安装前请阅读 GitHub 仓库 源码与许可证(仓库含 LICENSE)。
  • 侧栏 UI 强依赖 dsh-better-sidebar;DSH 版本与 sidebar 版本需按 README 对齐,避免 0.2.1 与 0.2.2 混用导致不兼容。
  • Ghost 与脚本 API 涉及 secret,首次引导中会做说明;生产环境不要跳过对默认行为的理解。
  • 社区插件目录 SkillHub 上的 dsh-conductor 页 与 GitHub 为独立信息源,与 DeepSeek / 幻方无官方从属关系;版本与星标以各站点实时数据为准(目录抓取时 GitHub 星标为 0)。

结尾

dsh-conductor 把「长聊成本控制」从反复开新会话或纯压缩,收敛到 同一 chat 内的 handoff、可回滚的 checkpoint、侧栏可视化的上下文与历史。若你已在 DSH web 上跑多会话 agent,可先装 dsh-better-sidebar 与 @lucagiftzek/dsh-conductor,从 Conductor 标签与 /new、/context 起步。

  • 目录页:https://www.skillhub.cn/plugins/lucagiftzek/dsh-conductor
  • GitHub:https://github.com/lucagiftzek/dsh-conductor
  • npm:https://www.npmjs.com/package/@lucagiftzek/dsh-conductor
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜