filantropo17/dsh-llm-repetition-guard

filantropo17★ 0TypeScript最后同步: 2026-08-19

在 GitHub 打开

README 摘要

dsh-llm-repetition-guard English 中文 Function plugin that fails a model request whose streamed output degenerates into repetition — a loop over one word, phrase, or n-gram — so the agent loop's agent/request-error recovery can retry it under the provider's retry policy. It wraps the llm/stream waterfall on ctx.llm : each model call gets a fresh per-stream detector, and the wrapper yields a terminal DEGENERATE OUTPUT error finish (then truncates the stream) as soon as the trailing text shows one unit repeated maxRepeats times. Retry happens inside the same turn/step — the loop re-issues the request against the same durable history — and the truncated chunks never enter derived messages. This plugin only classifies ; it never re-dispatches the adapter. Detection is per content block, keyed by stream index, under a bounded sliding window. text deltas are guarded by default; reasoning deltas are ignored unless checkReasoning is set, because reasoning text is pattern-heavy by nature and would trip conservative thresholds. Tool-call argument streams are never guarded — JSON fragments legitimately repeat keys and separators. A block must accumulate minOutputLength characters before detecti…

在 GitHub 查看完整 README →
工具/开发dsh-pluginterminalagent

分类