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
羽毛球分组比赛记分
小程序二维码

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

小夜