DeepSeek Harness Plugin Hub

发布与管理完整 Harness Profiles,发现适合你的插件。

探索

插件目录环境预设文档中心动态

社区

发布插件联系我们报告问题

相关链接

Plugin Hub GitHubDeepSeek Harness 官方项目系统状态隐私说明
© 2026 DeepSeek Harness Plugin HubPowered byPaxTech

独立、非官方社区项目,与 DeepSeek 官方无隶属、授权或背书关系。

DeepSeek Harness Plugin Hub
ProfilesPlugins分类动态文档登录管理 Profiles
ProfilesPlugins分类动态文档登录
← Plugins

@xiaobanli/dsh-compact-after-task

Compact After Task

在当前任务完成后,根据用户设置的上下文阈值自动压缩 DSH 对话。包含易失性 Config 字段,以及 Settings -> Plugins 中的专用卡片。

插件会安装到这里;不确定时保持 web。

npx -y @deepseek-ai/dsh plugin --profile web add @xiaobanli/dsh-compact-after-task@0.2.0
README兼容性版本
图片

兼容性与来源证明

Compact After Task 以 @xiaobanli/dsh-compact-after-task 发布,当前版本为 0.2.0。Plugin Hub 会校验它的 manifest,并保存精确安装来源,便于复现安装结果。

DSH 兼容范围
*
运行环境
web
发布来源
npm
Registry 更新时间
2026/11/4

版本

0.2.0stable
2026/9/24
0.1.2stable
2026/9/9
0.1.1stable
2026/8/20
查看其余 1 个版本收起版本
0.1.0stable
2026/8/19

相关插件

正在加载相关插件…

最新版
0.2.0
DSH
*
HMR
重启进程
Tree shaking
未声明可安全裁剪
解包体积
36.2 kB
文件数
9
Surface
web
许可证
MIT
发布源
npm
GitHub
★ 0
周下载
35
最近提交
2026/8/21
查看源码 ↗项目主页 ↗
README Badge

点击下方 Badge 复制 Markdown,粘贴到 README 即可。

这是你的 Plugin?认领权益 · 优先安全扫描

验证 package.json 声明的 GitHub 仓库,即可管理这个公开页面。认领后,Hub 会优先安排当前版本的安全扫描,并在通过后公开展示结果。

认领这个 Plugin →
报告问题

相关插件

继续浏览 memory-context 分类下经过校验的插件。

Experimental Session Search@deepseek-ai/dsh-experimental-session-search为 Agents 提供搜索和读取当前工作区早期会话的工具。Hindsight Coding Agents@vectorize-io/hindsight-coding-agents面向编程代理的仅反思式 Hindsight 长期记忆(可插拔支持多种运行框架:opencode、……),自动在后台导入(无需设置 CLI)。Contextdsh-context用于上下文洞察和管理的 DeepSeek Harness 插件,提供上下文仪表板和上下文命令,帮助了解上下文的构成及其演变过程。Mnemondsh-mnemon面向 DeepSeek Harness 的可组合、基于视图的上下文。开箱即用的可插拔来源与策略、分层记忆和自我演进技能。

README

dsh-compact-after-task

A DSH (Cordis) plugin that auto-compacts a conversation after the current task finishes, whenever context pressure crosses a threshold you set (default 50% of the routed model's context window). Install it and stop manually clicking "compress" — and stop letting the context (and the bill) grow unchecked.

The switch and the threshold live on a dedicated card under Settings → Plugins → "Auto-compact" (toggle + slider); changes apply immediately, no restart needed.

The problem it solves

In a long conversation the model re-receives the entire history on every turn. As the conversation grows, this bites harder and harder:

  • No compaction → exploding cost. The bigger the context, the more tokens each turn re-sends. Even with a provider KV cache (cheaper than fresh input, still not free), the history is re-transmitted and re-billed every single turn. Rolling from tens of thousands to hundreds of thousands of tokens quietly multiplies per-turn cost — the longer you talk, the more each reply costs, without you noticing.
  • Manual compaction is tedious and easy to forget. /compact or the UI compress button works, but you have to remember to use it — and people only remember once things are already slow and expensive, after several huge turns have been paid for.
  • The built-in auto-compaction is a late, mid-task safety net. dsh-compaction-basic only fires at 80% of the context window, and only at a step boundary while a task is running — by then you've already paid for several enormous requests, and the compaction interrupts work in progress.
  • Slower responses. Longer prefixes mean more processing per request and a noticeably sluggish feel.

This plugin automates the "remember to compress" chore: after each task finishes (the agent returns to idle) it checks the pressure and compacts at your chosen threshold — dealing with cost before it hurts, not after.

How it relates to the built-in compaction (complementary, not a replacement)

Built-in dsh-compaction-basicThis plugin
WhenAt each step boundary (agent/pre-step), mid-taskAfter the task fully finishes (agent returns to idle)
ThresholdthresholdRatio 0.8 (fixed)thresholdRatio user-set, default 0.5
RoleLast-resort mid-task safety netRoutine "slim down between tasks"

The compaction itself is identical to /compact: it calls ctx.compaction.compactNow(), produces one <compacted-summary> checkpoint, and the conversation UI shows the usual "compacted N history items" card.

Requirements

  • DSH Desktop / DSH profile with the base bundle (dsh-base), which provides dsh-compaction-basic, dsh-token-meter, dsh-agent and dsh-llm.
  • Core auto-compaction works on any version. The configuration form needs DSH ≥ 0.1.7-alpha.2, because that release removed the third-party settings-card mechanism (Host-side settings.installSection, the settings.plugin.item slot and the settingsScope client service). This plugin instead declares its Config fields with .volatile(): the Plugins page auto-generates a form for the entry from that schema, keyed by the profile entry id (compact-after-task). A .volatile() field is a stable reference ({ get() }) at runtime — the loader commits a new immutable snapshot into the same reference when the user saves, so the plugin reads the current value on every use and needs neither a restart nor a change subscription. On runtimes without volatile support the same fields arrive as plain values, which the plugin also accepts.
  • This plugin reaches the compaction service via agentPresets.serviceFor(), not inject: ["compaction"]. Since agent presets arrived, the compaction service is no longer provided on the host plane — each session's preset (standard/cordis/…) mounts it inside an isolate realm, so a host-plane plugin that injects compaction pends forever (waiting for service: compaction). This plugin instead calls the official read API ctx.agentPresets.serviceFor(agent, "compaction") when the agent goes idle (that API exists precisely for callers whose request is about a session but arrives from outside it); on runtimes without agent presets it falls back to ctx.get("compaction").

Install

Two ways — pick one (do not mix them: the loader rejects a duplicate entry id).

A. Standard: plugin market / dsh plugin add (recommended)

The package ships a dsh.bundle.patch pointing at its own cordis.patch.yml, so it is a first-class bundle: installing it via the market or the CLI adds it to the profile's dsh.profile.bundles, and on the next boot the loader applies the package's own patch layer automatically — no manual editing needed.

# from npm (after publishing) — or from GitHub directly:
dsh plugin --profile desktop add @xiaobanli/dsh-compact-after-task
dsh plugin --profile desktop add github:xiaoliang2/dsh-compact-after-task

Or, in the desktop app, open Settings → Plugin Market and one-click install. Restart DSH Desktop, done.

B. Manual, profile-local (no market, no publishing)

  1. Copy this package into the profile and make it resolvable from the profile's node_modules (same way dshmarket is installed):

    # from the DSH home, e.g. C:\Users\you\.dsh\profiles\desktop
    Copy-Item -Recurse <path-to>\dsh-compact-after-task .\plugins\dsh-compact-after-task
    New-Item -ItemType Junction -Path .\node_modules\@xiaobanli\dsh-compact-after-task -Target .\plugins\dsh-compact-after-task
    
  2. Add the plugin row to the profile's cordis.patch.yml (your user patch layer, applied after every bundle layer):

    - insert:
        - id: compact-after-task
          name: '@xiaobanli/dsh-compact-after-task'
          config:
            enabled: true
            thresholdRatio: 0.5
    
  3. Declare the dependency in the profile's package.json so a later pnpm install does not prune it:

    "dependencies": {
      "@xiaobanli/dsh-compact-after-task": "file:plugins/dsh-compact-after-task"
    }
    
  4. Restart DSH Desktop for the profile change to take effect.

If you already installed it manually (method B), uninstall/remove it before installing via the market, otherwise the same entry id compact-after-task is inserted twice and the loader refuses to boot.

Configuration

KeyTypeDefaultMeaning
enabledbooleantrueMaster switch.
thresholdRationumber (0.05–1)0.5Compress when pressure reaches this fraction of the routed model's context window (0.5 = 50%).
onlyRootsbooleanfalseOnly compress top-level conversation agents (skip background subagents).

Adjusting the threshold

After install, open Settings → Plugins: beside the plugin list there is now an Auto-compact tab holding one card:

  • Toggle — auto-compact after each task finishes;
  • Slider — the threshold (5%–100%, 5% steps) with the live percentage beside it;
  • Toggle — top-level conversations only (skip background subagents);
  • Reset to default — shown only while the threshold is overridden, restoring the cordis.patch.yml base-layer value.

The card binds its entry's settings namespace (compact-after-task) through the official client service ctx.configForms: saving writes into your profile's patch for that entry, and the loader commits the new value into the running plugin — no restart needed. (The same values are also editable from the plugin manager's auto-generated form for that row; the two are equivalent.)

Picking a threshold

Set it from "the max per-turn re-send you can tolerate ÷ the model's context window":

  • DeepSeek's default 1M window: 0.3–0.6 is the sweet spot; 0.5 is a conservative default.
  • Want each turn to re-send ≤ 400K tokens → 0.4; ≤ 250K → 0.25.
  • Don't go ≥ 0.8: the built-in compaction already fires at 0.8 at a step boundary, so a higher threshold here is meaningless.
  • Small-window models (128K/64K): raise to 0.6–0.8, or you'll squeeze out useful working context.
  • Too low (below ~0.1) means compressing after every small task, and the summary swallows details that were still useful.

Tune by feel after a couple of long tasks: compressing after every little task / summaries getting coarse → raise it; still re-sending hundreds of thousands of tokens per turn → lower it. Drag the slider on the Auto-compact card (live) or edit cordis.patch.yml (base layer; restart).

Behavior details

  • Listens to the agent/status event and acts only on the idle transition — i.e. the current task's drive has fully drained. This is the "compress after finishing the current task" moment; it never interrupts a running task.
  • Uses the same pressure measurement as the built-in engine: tokenMeter.measure(session).totalTokens vs contextWindow × thresholdRatio (context window resolved via llm.resolveModelInfo).
  • Compaction is a single ctx.compaction.compactNow(agent, signal) call — the same operation /compact runs; compactNow reserves next-turn admission, so queued messages are correctly deferred until the compaction finishes. On rc.7+ ctx.compaction is the instance returned by agentPresets.serviceFor(agent, "compaction"); the operation is unchanged.
  • Expected failures are silent: busy (agent busy / a compaction already running) and cancelled are skipped; anything else is logged as a warning without disturbing agent lifecycle events.
  • If the agent's preset mounts no compaction group (e.g. minimal), serviceFor returns undefined and that agent is skipped.

Test

npm install
node test-compact-after-task.mjs

The unit test stubs the services and covers: idle + above threshold compacts, below threshold does not, running does not, busy is silent, disabled does nothing, onlyRoots filters subagents, the agentPresets.serviceFor and host-plane fallback paths, live .volatile() config reads (threshold and switch changed between events), and legacy plain-value config.

License

MIT