CHIP-PHILO-GH/dsh-loop-breaker ↗★ 0
dsh-loop-breaker
DSH 流式复读熔断器:在 llm/stream 层边收边判,命中退化复读就地掐断(底层 HTTP 随即取消,token 停止计费),掐断时消毒正文避免污染上下文 适合需要防止模型无限复读、节省Token费用并消毒上下文的用户。
Other repositories with this package name
Install
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:CHIP-PHILO-GH/dsh-loop-breakerREADME
Read the full README ↗配置
- id: loop-breaker
name: 'dsh-loop-breaker' # 与包名一致(install.ps1 就装在这个名字下);若装在 @local\ 作用域里则写 '@local/dsh-loop-breaker'
config:
enabled: true # 总开关
recover: true # 命中后是否注入补救提示
maxRecoveriesPerTurn: 2 # 同一轮最多补救几次(按轮号归零,跨轮重新计数)
nudge: '' # 补救提示文本,留空用内置文案
# --- L0 消毒:防止复读原文落盘污染后续生成 ---
sanitize: true # 是否改写掐断时写回会话的正文
sanitizeHeadChars: 240 # 保留原文开头的字数(0 = 全丢;开头已塌缩时同样全丢)
degradePlaceholder: '' # 替换复读原文的占位符,留空用内置文案
# --- 检测阈值 ---
windowChars: 1600 # 滚动统计窗口(归一化字符数)
periodMax: 48 # 短周期检测的最大周期;超过它的重复视为长块模板重复
periodMatch: 0.92 # 短周期自吻合率阈值
periodMaxPieces: 6 # 窗口内片段种类上限(用字单调 ≠ 复读,还要碎片少)
collapseUniqueRatio: 0.10 # 去重字符占比阈值(正常中文 0.3~0.6)
stallMinChars: 400 # 零信息增量助推门槛(0 = 关闭)
sentRecycle: 0.80 # 句子回收率阈值
gramRecycle16: 0.80 # 16-gram 回收率阈值
tightRedundancy: 0.90 # 窗口字面冗余度阈值
maxChars: 200000 # 单次输出硬上限(0 = 关闭)
maxReasoningChars: 120000 # 单次思考链硬上限(0 = 关闭)
调参方向:
- 误杀正常长输出 → 调高
sentRecycle/gramRecycle16/tightRedundancy,或调大windowChars - 误杀批量同构内容(清单 / 条款 / 近似函数) → 这类靠句子回收命中,调高
sentRecycle - 误杀碎片循环判定 → 调高
periodMatch,或调低periodMax(周期越小越像退化) - 漏过复读 → 反向调低;或调小
windowChars(循环占比更高,更早命中) - 只想掐断不想要补救 →
recover: false - 排查期想看模型到底复读了什么 →
sanitize: false(让原文落盘)