dsh-compaction-tool-result-pruner/packages/compaction/compaction-tool-result-pruner官方
专门压缩tool result的head/middle/tail截断服务,保留原始事件用于重放,配合compaction-basic使用
ⓘ 此插件是大仓库 deepseek-ai/deepseek-harness 的子包,星数与活跃度统计的是整个仓库。
- 语言
- TypeScript
- License
- MIT
- 分支
- master
安装
$ dsh plugin --profile web add npm:@deepseek-ai/dsh-compaction-tool-result-pruner在终端中运行以上命令,通过 dsh CLI 安装此插件。可在右上角切换 Profile。 第一次用 dsh?看这篇新手教程
对话式安装
帮我安装 DeepSeek Harness 插件 deepseek-ai/deepseek-harness/packages/compaction/compaction-tool-result-pruner:先查看仓库 https://github.com/deepseek-ai/deepseek-harness 确认安全性,然后执行安装命令并验证插件加载成功。
把这段指令粘贴给 DSH Web GUI 里的助手,由它代你完成安装与验证。
English | 中文
The replay-safe model-free pruning service (ctx.toolResultPruner). It rewrites over-budget tool/result surface nodes to a bounded head, a fixed omission marker, and a bounded tail while retaining the full original event in the append-only session log.
This is a concrete companion to dsh-compaction-basic, not a compaction backend or model-facing tool. Compact-basic reads it through optional ctx.get('toolResultPruner'), so either package remains independently composable.
Service API
pruneSession(session) scans one stable snapshot of the current surface. Every over-budget tool result is replaced by one newly appended tool/result carrying { surfaceOp: { op: 'replace', start: originalSeq, end: originalSeq }, sourceEventSeqs: [originalSeq] }. The replacement spreads the complete original data and changes only content, preserving turn, step, callId, error fields, meta, and later data additions. The original event remains available for persistence, replay, and exact-log inspection.
The method throws synchronously when the session rejects a replacement. Replacements committed earlier in the pass remain durable.
measureContent(blocks) counts Unicode code points in text blocks. pruneContent(blocks) returns the bounded replacement or null when content is already within the threshold. Non-text blocks are retained at their original relative positions; text slicing never splits a UTF-16 surrogate pair, though it can split a multi-code-point grapheme cluster.
Every emitted result has exactly the configured head budget, fixed marker, and tail budget in text code points, is no larger than thresholdChars, and is strictly smaller than the triggering input. A second pass therefore emits no replacement.
Config
Unrecognized keys fail at plugin construction. Resolved config is detached and deeply immutable.
| Key | Required | Meaning |
|---|---|---|
thresholdChars | no (default 8192) | Prune when combined text exceeds this many Unicode code points. |
headChars | no (default 4096) | Leading Unicode code points retained. |
tailChars | no (default 1024) | Trailing Unicode code points retained. |
All values are integers; the threshold is positive and head/tail are non-negative. headChars + marker + tailChars must fit within thresholdChars, so a valid configuration can prune every over-budget result without growth or repeated rewriting.
Usage
import type { Context } from '@deepseek-ai/cordis'
import ToolResultPruner from '@deepseek-ai/dsh-compaction-tool-result-pruner'
export function apply(ctx: Context): void {
ctx.plugin(ToolResultPruner)
}
Model Experience
Pruned tool result
What the model sees
Once a compaction trigger qualifies, future requests see the retained head, \n\n[... tool result middle pruned ...]\n\n, and retained tail in place of the removed text. Rich blocks keep their order. The model does not see a second copy of the original.
Token effect
Each rewritten tool result has at most thresholdChars text code points. Pruning itself makes no model call; compaction-basic skips summarization when the remeasured request falls below pressure, otherwise the summarizer reads the pruned surface.
KV Cache effect
Replacing an earlier result invalidates reuse from the first changed token. The pruned prefix is eligible for reuse while its route, envelope, and preceding history remain identical.
Known Limitations and Deferred Work
- Character budgets are not token budgets — provider token density varies, so
ctx.tokenMeterremains the authority for deciding whether pruning relieved request pressure. - Pruning is syntactic — it retains the beginning and end without interpreting which middle lines are semantically important.
- Grapheme clusters can split — code-point slicing protects surrogate pairs but does not perform locale-aware grapheme segmentation.
收录徽章
[](https://deepseek-plugin.org/plugins/deepseek-ai/deepseek-harness/packages/compaction/compaction-tool-result-pruner)把这段 markdown 粘贴到你的 GitHub README,链接回本插件详情页。徽章只声明已被本站收录,不代表安全认证。