dsh-auto-compact
其他 活跃维护

dsh-auto-compact

wangxiang0605qvq/dsh-auto-compact

自动压缩插件,内置compact_now工具,每轮对话结束后自动压缩上下文,无需手动触发即可避免上下文溢出,轻量接入无额外配置,维持长上下文对话的有效性。

0
Stars 标星
0
Forks 分支
0
Watchers 关注
0
Open Issues
JavaScript
主要语言
MIT
开源协议
4 KB
仓库大小
1 个月前
最后推送
一键安装扩展 / 插件指令
dsh plugin --profile web add github:wangxiang0605qvq/dsh-auto-compact
git clone https://github.com/wangxiang0605qvq/dsh-auto-compact.git
git clone git@github.com:wangxiang0605qvq/dsh-auto-compact.git
README.md main

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

让模型可以主动调度 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_nowagent.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