@dpskh/tool-rewind
Exploration-fold plugin for the DeepSeek Harness: folds everything since the most recent checkpoint/mark (appended by the @dpskh/tool-checkpoint plugin) into an auto-generated report, replacing the exploration's noisy middle in the model-visible surface while the durable log keeps the full exploration for audit
安装
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:dpskh/dsh-rewind说明文档
阅读完整 README ↗@dpskh/tool-rewind —— DeepSeek Harness 的探索折叠插件
English | 中文
一个包、一个入口插件。挂载 @dpskh/tool-rewind 提供 ctx.rewind(把最近一次 checkpoint/mark 之后的一切折叠成自动生成报告的服务)和基于它的模型侧 rewind 工具。折叠用报告遮蔽探索的表面区间 —— 与 DeepSeek Harness 压缩接缝相同的 surfaceOp: { op: 'replace' } 机制 —— 使后续请求不再携带探索的中间步骤(读文件、搜索、试验),而持久日志完整保留探索过程供审计。报告由 ctx.llm 自动生成;标记来自兄弟插件 @dpskh/tool-checkpoint。不修改任何上游包。
配置
- id: tool-rewind
name: '@dpskh/tool-rewind'
config:
toolName: rewind # model-facing tool name (default rewind)
maxTokens: 1024 # summarization output budget
maxSummarizationRetries: 2 # empty-completion retries before failing
summarizationProvider: deepseek # optional override of the routed provider
summarizationModel: deepseek-chat
reportLanguage: en # en | zh (report instruction language)
报告调用的 provider/model 解析顺序:配置覆盖,其次会话最近路由的 request/header 配置,最后 agent 的 options。三者全缺则响亮报错。
当路由暴露 off reasoning effort 时,报告调用会关闭 thinking —— 压缩探索是机械性任务,而推理模型的思考 token 会在 maxTokens 预算内与报告文本竞争(思考可能在任何文本开始前耗尽预算,留下空补全)。空补全最多重试 maxSummarizationRetries 次;预算耗尽后以携带 finish 原因与 token 用量的消息拒绝,该消息被保留在 fold-end 错误记录中。
配合使用
折叠需要标记:两个插件一起挂载,rewind 才能折叠 checkpoint 锚定的探索。单独挂 rewind 没有可折叠的内容,会以 no-checkpoint 错误失败;单独挂 checkpoint 只会记录惰性标记。
- id: tool-checkpoint
name: '@dpskh/tool-checkpoint' # https://github.com/dpskh/dsh-checkpoint
- id: tool-rewind
name: '@dpskh/tool-rewind'
config:
reportLanguage: en # en | zh report instruction language
契约
ctx.rewind.rewind(agent, signal)—— 找到最近的checkpoint/mark;选取其后的平衡表面区间(绝不切开 tool-call/result 配对,绝不折叠 rewind 调用本身);通过ctx.llm总结该区间;随后在一个同步块内提交checkpoint/rewind溯源记录和携带报告的替换user/message(source 标记{ kind: 'plugin', plugin: 'rewind' },isRewindReportSource可识别)。失败时以错误记录闭合折叠括号,并以分类RewindError(NO_CHECKPOINT、EMPTY_REGION、UNBALANCED、FOLD_IN_PROGRESS、CHANGED、SHRINK)拒绝。若标记在调用中途追加(checkpoint 工具在自身的 tool-call 与结果之间运行),该结果会成为标记后的孤立节点;选区会跳过它到下一个平衡切点,使 checkpoint 调用自身的配对保持可见,折叠从随后的探索开始。