dsh-compactor
Context Compaction plugin for DeepSeek Harness: tool-result pruning, LLM or offline-rule summarization with a user-facing compression report, dead-loop guard, and /restore rollback.
安装
此插件尚未提供可验证的 bundle,或兼容性检查未通过。请先阅读仓库说明。 阅读完整 README ↗
说明文档
阅读完整 README ↗配置方式
cordis.patch.yml:
plugins:
dsh-compactor:
thresholdTokens: 32768 # 触发压缩的 token 阈值
targetTokens: 8192 # 压缩目标 token 数(参考值)
compressInterval: 300 # 定时扫描间隔(秒)
retainRecentRounds: 3 # 最近 N 条消息永不压缩
summaryModel: deepseek-chat
enablePruning: true # 实时层剪枝
enableSummary: true # API 摘要(无 Key 时自动降级本地兜底)
exemptTools: [write, edit, task] # 豁免工具(剪枝/护栏/本地压缩均跳过)
qualityThreshold: 0.85 # 关键信息保留率告警阈值
# localRulesPath: /path/to/my-rules.json # 可选:本地规则文件路径
API 摘要需要密钥:export DEEPSEEK_API_KEY=sk-...(不设置则 API 路径自动使用本地抽取式兜底)。
/local-compact 规则文件(local-rules.json)
规则/正则全部集中在包根 local-rules.json,加载优先级(深合并,后者覆盖前者):
内置默认 ← 包根 local-rules.json ← 环境变量 DSH_COMPACTOR_RULES= ← 配置 localRulesPath(显式路径读取失败会报错)。
{
"maxSummaryChars": 1200, // 本地摘要硬上限(超出截断并标注)
"maxKeptSentences": 8, // 长回复最多保留句数(先去重再截断)
"userLineMaxChars": 200, // 用户问题行保留上限(骨架优先保留)
"callArgsMaxChars": 80, // 工具调用参数行截断
"fallback": { "headChars": 300, "tailChars": 160 },
"toolRules": {
"web_search": { "keepTopResults": 5, "relevanceField": "relevance_score", "titleField": "title", "urlField": "url", "linkField": "link", "dropFields": ["snippet", "description"] },
"read_file": { "headLines": 20, "tailLines": 5 },
"code_execution": { "maxStdoutLines": 30, "maxStderrLines": 10, "errorPattern": "error|exception|failed|traceback|panic|错误|失败|异常|报错" }
},
"patternRules": {
"research_chain": { "mergeUrls": true, "maxMergedUrls": 8 },
"code_debug": { "attemptPattern": "第\\s*\\d+\\s*次|attempt\\s+\\d+|retry|重试|再次", "keepLast": true }
}
}