Shaw529/dsh-token-saver ↗★ 4

dsh-token-saver

DeepSeek Harness plugin: aggressive token optimization without affecting task quality. Trims tool results, manages context window pressure, optional LLM-summary compaction, stable prompt-cache layout. 适合需要控制 Token 消耗、缓解上下文压力并保持提示词缓存稳定的任务。

パッケージ
dsh-token-saver
互換性
未検証
Harness ピア範囲
>=0.0.1-rc.1 <0.1.0 || >=0.0.1-rc.1 <0.2.0-0
Cordis ピア範囲
>=3.0.0 <6.0.0-0 || >=4.0.1-rc.1 <5.0.0-0
バージョン
0.1.0
ライセンス
MIT
最終更新
2026/09/07

同名パッケージの別リポジトリ

インストール

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:Shaw529/dsh-token-saver

ドキュメント

README 全文を読む ↗

配置参考

cordis.yml 插件行示例:

- name: 'dsh-token-saver'
  config:
    mode: balanced
    headBytes: 16384
    tailBytes: 8192
    grepMaxMatches: 30
    grepContextLines: 2
    grepHeadBytes: 8192
    grepTailBytes: 4096
    pressureThreshold: 0.5
    compactPressureThreshold: 0.5
    llmSummaryEnabled: false
    llmSummaryMaxInputTokens: 16000
    replaceBasicCompaction: false
    includeToolNames: []
    excludeToolNames: ['interaction.ask_user', 'interaction.confirm']
    cacheStableSections: ['agent-identity', 'user-instructions', 'tool-list']
    telemetry:
      onFold: |
        (event) => logger.info({ kind: 'fold', ...event })
      onCompact: |
        (event) => metrics.histogram('tokens.saved', event.savedTokens, ['engine', event.engine])

字段说明

字段类型默认含义
mode'off' | 'conservative' | 'balanced' | 'aggressive''conservative'模式选择器
preserveStructurebooleantrue截断时按行边界切,避免在行中间断
headBytesnumber16384工具结果保留的头字节数
tailBytesnumber8192工具结果保留的尾字节数
grepMaxMatchesnumber30grep 匹配最大保留条数(带上下文)
grepContextLinesnumber2每条匹配保留的上下文行数
grepHeadBytes / grepTailBytesnumber8192 / 4096grep 折叠后的最终头/尾预算
pressureThresholdnumber (0..1)0.5pre-step 副作用生效的压力比
compactPressureThresholdnumber (0..1)0.5触发 ctx.compaction.compactIfNeeded 的压力比(balanced+ 生效)
llmSummaryEnabledbooleanfalse启用 LLM-summary engine(balanced/aggressive)
llmSummaryPromptstring内置自定义摘要 prompt
llmSummaryMaxInputTokensnumber16000单次摘要调用的输入 token 上限
replaceBasicCompactionbooleanfalse替换 dsh-compaction-basic(仅 aggressive 推荐)
includeToolNamesstring[][]白名单(空 = 所有工具)
excludeToolNamesstring[][]黑名单(优先级高于 include)
cacheStableSectionsstring[][]需要钉住的稳定段 id,用于 prompt-cache 命中率
telemetry.onFoldfunctionundefined每次 fold 后触发的同步钩子
telemetry.onCompactfunctionundefined每次 compaction 后触发的同步钩子