dsh-auto-compact

by wangxiang0605qvq

记忆github收录于 08-23

dsh-auto-compact — DeepSeek Harness 自动压缩插件 Auto Compaction Plugin

安装

dsh plugin --profile web add github:wangxiang0605qvq/dsh-auto-compact

GitHub 源码安装:首次需按提示配置 allowBuilds 构建授权后重试

安装与环境配置指引、插件开发教程见 DSH 中文社区文档 ↗

安装即在你的机器上以你的权限运行第三方代码——它可读写文件、使用凭据、访问网络,DSH 的工具审批不会为插件代码加沙箱。「检测到 manifest」仅代表发现 dsh.bundle / dsh.plugin 清单,不构成兼容性或安全审查;安装前请审阅源码,不熟悉的插件先在不含密钥的环境试用。

README

目录

让模型可以主动调度 DeepSeek Harness 会话上下文的自动压缩。注册模型工具 compact_now:模型在回合中请求压缩当前会话历史,插件在**回合结束后(agent 空闲时)**自动执行压缩,并写入会话日志。

Allows the model to schedule automatic compaction of its session context. Registers the compact_now tool: when called, the plugin runs compaction after the current turn ends (once the agent is idle) and records the result in the session log.

为什么需要它 | Why

  • DSH 内置了按压力触发的自动压缩(compaction-basic)和人类手动的 /compact 命令。
  • 但模型自己无法触发压缩:compaction.compactNow 要求 agent 空闲,而工具在回合内执行时 agent 必然处于运行中(会抛 busy)。
  • 本插件的 compact_now 用 agent.whenIdle() 把压缩推迟到回合结束后的空闲时刻执行,绕开 busy 限制。

安装 | Install

将本仓库复制到 DSH profile 的 node_modules 下:

Copy-Item -Recurse . "$env:USERPROFILE\.dsh\profiles\node_modules\@deepseek-ai\dsh-auto-compact"

在 profile 补丁(如 ~/.dsh/profiles/web/cordis.patch.yml)中插入:

- insert:
    - id: auto-compact
      name: "@deepseek-ai/dsh-auto-compact"
      inject: ["tools", "agents", "timer"]
      config: {}

重启 DSH 生效。

使用 | Usage

模型直接调用 compact_now 工具即可:

  • 返回 { ok: true, status: "scheduled" }:压缩已排队,回合结束后自动执行;
  • 返回 { ok: false, reason }:压缩服务不可用(如 minimal 预设未挂 compaction-basic);
  • 压缩结果(compaction/start 标记、摘要等)记录在会话日志中,模型可从后续上下文中看到。

依赖 | Dependencies

  • @deepseek-ai/dsh-compaction:压缩服务契约(agent 预设需挂载 compaction-basic 实现)。
  • @deepseek-ai/dsh-tools、@deepseek-ai/cordis:工具注册与运行时。

License

MIT

原始 README: https://github.com/wangxiang0605qvq/dsh-auto-compact/blob/main/README.md ↗