DeepSeek Harness 插件

dsh-context-guard

Token-efficient tool-result pruning policy for DeepSeek Harness presets.(英文原文)

跳到安装方式

来源信息

GitHub 仓库
kpl0111/dsh-context-guard
最近更新
2026年8月16日
分类
工具与能力
GitHub stars
0
载体类型
plugin
目录证据
上游声明已找到 dsh.bundle
证据路径
package.json#dsh.bundle
核对版本
0.1.0-rc.8
上游核对日期
2026-08-20

该证据由上游目录提供。本站没有安装、运行或安全审核这个插件。

安装

默认先复制一段 Prompt,让 Agent 读 GitHub 仓库和源码;需要自己装时再切到命令。

复制这段 Prompt,发给 DSH、Codex 或其他 Agent,让它先读 GitHub 仓库和源码。

请先不要安装或执行任何命令。阅读这个插件的 GitHub 仓库、README 和关键源码,然后用清楚、直接的方式回答以下问题,帮助我判断它是否适合我的需求:

1. 这个插件是什么,解决什么问题;
2. 适合哪些用户和典型使用场景;
3. 安装后如何使用,并给出一个最小使用示例;
4. 有哪些已知限制,以及隐私、安全、兼容性或维护风险;
5. 给出“推荐 / 有条件推荐 / 不推荐”的明确建议和理由。

请区分仓库明确说明、根据源码推断和未知信息。证据不足时请明确说明,不要猜测或照抄 README。

GitHub:https://github.com/kpl0111/dsh-context-guard
插件名:dsh-context-guard
作者:kpl0111

检查来源文件

安装前先看这个插件目录里的 README 和其他文件。

文件资源管理器3 个文件
README.md来源说明 · 只读预览

dsh-context-guard

dsh-context-guard is a small DeepSeek Harness (DSH) preset add-on for controlling long-agent-session token growth. It prunes oversized tool results before the next model request, while leaving durable session history intact for targeted recovery.

It does not replace DSH compaction and does not send its own LLM request.

Policy

The recommended balanced policy is:

LayerSettingPurpose
Immediate tool pruningthresholdRatio: 0.001Replace bulky tool output with a 2.3K-character preview before the next turn.
Previewhead 1792 / tail 448Retain the beginning plus terminal exit/spill-file marker.
Full compactionInstant at 80%Compact conversation history only when the useful context is genuinely large.
Recoveryrecall <= 4096 tokensPermit targeted recovery without a 16K accidental context refill.

Installation

This is a standard DSH bundle. Installing it adds an isolated runtime realm containing the guard and its toolResultPruner; no preset merge is required.

dsh plugin --profile web add github:kpl0111/dsh-context-guard#v0.2.0

For bounded search and recall recovery, install dsh-compaction-instant as a companion bundle:

dsh plugin --profile web add github:KitDoesIt/dsh-compaction-instant

If DSH Desktop does not expose the dsh command on your PATH, install the package through its Plugins settings or the active profile's package-manager environment. The preset fragment and realm placement are unchanged.

Add this sentence to the persona/system prompt when using pruned output:

> When prior tool output has been pruned, first use the retained file path, a narrow filesystem search, or search. Use recall only when that is insufficient, and recall the smallest relevant result or sequence; never broadly recall large historical output.

Restart DSH and create a new session after installing or updating bundles. The legacy [presets/standard-lite.fragment.yml](presets/standard-lite.fragment.yml) is retained only for users who deliberately manage the guard inside a preset; do not enable both the legacy row and this bundle at the same time.

Expected behavior

  • Large ordinary tool results are replaced with the configured compact preview before the next model request.
  • search results follow the normal pruning policy.
  • A recall result is preserved in full for exactly the next model step, then becomes eligible for normal pruning again.
  • Original tool output remains available in DSH's append-only session history for targeted search and recall.

Verify installation

1. In a new session, run a tool that produces a large result (for example, a PowerShell command printing many lines). 2. Inspect the session event log or context view: the next model step should retain a roughly 2.3K-character preview rather than the full result. 3. Ask the model to locate a known value with search, then require one recall of the matching event. The recalled result should not receive an immediate compaction/prune event, and the next assistant reply should be able to use the full recalled content.

Compatibility and safety

  • Requires DSH/Cordis packages compatible with @deepseek-ai/dsh-* 0.1.0-rc.6.
  • Works with the built-in @deepseek-ai/dsh-compaction-tool-result-pruner.
  • thresholdRatio: 0.001 is intentionally near-immediate but still checks the model context window. Use 0.20 if you prefer delayed pruning.
  • A recall result is deliberately kept intact for the immediately following model step once, then becomes eligible for normal pruning. This preserves recall usefulness without retaining its full payload for later turns.
  • Full original tool output remains in DSH's append-only session log. The plugin itself never deletes it.

Development

npm test
npm run check

License

MIT