dsh-agent-compact:DeepSeek Harness 的自主片段压缩 DSH plugin

mimichunterz/dsh-agent-compact

记忆与上下文已验证
收录时间 2026-08-20
页面最后更新 2026-08-20

DSH plugin 让 Agent 自主压缩对话片段,用自写检查点替代官方全量压缩,减少信息丢失。

让 DeepSeek Harness 的 agent 自主选择对话中已完成、不再需要的片段进行压缩,并用自写的检查点替换,最大限度减少信息损失。

install
dsh plugin --profile web add github:mimichunterz/dsh-agent-compact
分类
记忆与上下文
平台
DSH-Plugin
作者
mimichunterz
分发方式
插件

dsh-agent-compact 核心特性

自主选择压缩片段自写检查点摘要原始片段归档保存减少信息丢失

dsh-agent-compact 仓库信息

mimichunterz
发布者
mimichunterz
仓库
mimichunterz/dsh-agent-compact
4
Star
1
Fork
0
Watch
0
开放 Issue
语言TypeScript
许可证Other
官网
仓库最近更新2026-08-17 13:33:07
仓库创建时间2026-08-14 14:38:16
主题
context-compressiondeepseek-harnessdsh-plugin
默认分支main

dsh-agent-compact 仓库简介

dsh-agent-compact 是 DeepSeek Harness(DSH)的上下文压缩插件(DSH plugin),由 MimicHunterZ 维护,采用 TypeScript 编写,最近更新于 2026-08。它解决的是官方压缩机制只能从对话开头进行全量压缩、导致开头任务计划和方向信息随压缩丢失的问题。该插件允许 agent 自主调用 context_compact 工具,选择对话中已完成、不再需要的中间片段进行压缩,并用 agent 自己编写的检查点(checkpoint)替换,从而将信息损失降到最低。核心能力包括:通过 startAnchor / endAnchor 精确选择压缩范围(支持 CJK 标点宽度容错)、强制要求 summary 参数(agent 自写的 Markdown 检查点)、原始片段先归档到 spill 存储(~/.dsh/spill/session-<hash>/<hex>-<seq>.txt,顺序命名,重启安全),且不额外发起 LLM 摘要请求,压缩过程在 agent 正常回合内完成,仅按普通回合计费。

dsh-agent-compact 这个 DSH plugin 支持哪些核心特性?

  • 自主选择压缩范围:agent 通过 startAnchor / endAnchor 指定要压缩的对话片段,支持唯一前缀匹配,对 CJK 标点宽度不敏感,能精准定位到中间任意一段。
  • agent 自写检查点summary 参数为必填,压缩后替换为 agent 自己生成的 Markdown 检查点,而非官方引擎的自动摘要,保留关键细节。
  • 原始数据归档:压缩前先将完整原始片段写入 spill 存储,路径在 shadow 消息中回显,模型可随时读回原始文本,重启后依然可访问。
  • 无额外摘要请求:复用宿主引擎的标准事务(边界校验、工具对平衡、表面替换),不额外调用 LLM 摘要器,节省成本。

dsh-agent-compact 怎么安装?

安装命令如下,安装后需重启 profile 使 context_compact 工具生效:

bash
dsh plugin --profile web add github:mimichunterz/dsh-agent-compact

若从本地源码安装,可执行 dsh plugin --profile web add ./agent-compactdsh plugin 命令会在 profile 目录中转发给 pnpm,并将 bundle 追加到 dsh.profile.bundles。插件自带的 cordis.patch.yml 将 spill 归档根目录固定为 ~/.dsh/spill,部署时可通过 profile 的 cordis.patch.yml 覆盖。

dsh-agent-compact 怎么卸载?

卸载命令如下,同样需要重启 profile:

bash
dsh plugin --profile web remove @mimichunterz/agent-compact

该命令会转发给 pnpm remove,卸载包并从 dsh.profile.bundles 中移除 bundle。若插件是通过 profile 的 cordis.patch.yml 额外挂载的(开发模式),需手动删除对应行,否则下次启动会重新挂载。

dsh-agent-compact 有哪些配置项?

字段默认值说明
autoArchivetrue压缩前是否将完整原始片段保存到 spill 归档

配置可通过 profile 的 cordis.patch.yml 插入的行或 bundle patch 传递。

dsh-agent-compact 的工作原理是什么?

patchEngine()(见 src/optimizer.ts)包装了引擎的 summarize() 方法:当存在 _externalSummary(即 agent 自写的检查点)时,直接使用该摘要,跳过官方引擎的自动摘要流程。工具调用发生在 agent 的正常回合内,按普通回合计费,仅避免了官方引擎对同一片段额外发起的摘要请求。

查看更多 DSH 插件,访问 dsh-plugin.org

DSH-Plugin 常见问题