LM Studio 实时重复输出守卫:本地模型正文 / 思考流一开始"复读",立刻自动截停,已生成内容完整保留。
量化模型(尤其是小模型)长生成时容易陷入循环:wait wait wait wait …、思考里反复念同一句话、工具调用参数刷同一段 JSON——白烧 token 还占着上下文。目前 LM Studio 没有内置的"检测到循环就停"机制,本插件补上这一环。
插件注册一个 Guarded Generator,包裹本地已加载的模型,逐片段转发输出的同时做两层检测:
检测同时作用于三路流:正文、思考(reasoning)、工具调用参数,可分别开关。
触发后:底层预测立即 abort(服务端停止生成)、已输出片段保留、本轮正常收尾(等同用户点停止),并在末尾附一行提示(可关闭)。不删除任何内容。
- | 默认忽略字符)不会误判。| 项 | 默认 | 说明 |
|---|---|---|
| Model Key | (空=当前模型) | 要守护的本地模型 |
| Temperature | 0.8 | 透传给模型 |
| Repeat Threshold | 10 | 连续重复触发阈值,越小截停越早 |
| Chant Threshold | 4 | 整句循环触发阈值 |
| Guard Thinking Stream | 开 | 检测思考流 |
| Guard Answer Stream | 开 | 检测正文流 |
| Notify On Stop | 开 | 截停时附提示行 |
在聊天的模型选择器里选本插件提供的 guarded 生成器即可生效。
Real-time repetition guard for LM Studio: the moment a local model starts looping on repeated text — in the answer, in the thinking stream, or in tool-call arguments — generation is stopped automatically. Everything generated before the loop is kept intact.
Quantized local models (especially small ones) can degenerate into wait wait wait wait … loops mid-generation, chant the same sentence in reasoning, or spam identical tool-call JSON — burning tokens and polluting the context. LM Studio ships no built-in loop breaker; this plugin adds one.
The plugin registers a Guarded Generator that wraps a locally loaded model. Every fragment is forwarded to the UI and inspected by two detectors:
All three streams are guarded independently: answer text, thinking/reasoning, and tool-call arguments, each toggleable.
On trigger: the underlying prediction is aborted immediately (the server stops generating), emitted fragments are preserved, the turn finishes cleanly (exactly like a user stop), and an optional one-line note is appended. Nothing is deleted.
- | are ignored chars) never trigger.| Setting | Default | Meaning |
|---|---|---|
| Model Key | (empty = current) | Local model to guard |
| Temperature | 0.8 | Passed through to the model |
| Repeat Threshold | 10 | Consecutive-repeat trigger; lower cuts earlier |
| Chant Threshold | 4 | Sentence-loop trigger |
| Guard Thinking Stream | on | Detect loops in reasoning |
| Guard Answer Stream | on | Detect loops in the answer |
| Notify On Stop | on | Append a note when cut off |
Pick the guarded generator provided by this plugin in the chat model selector.
Detection strategy inspired by dsh-repetition-guard / dsh-dupguard (DeepSeek Harness) and Qwen Code's LoopDetectionService.
MIT
LM Studio 实时重复输出守卫:本地模型正文 / 思考流一开始"复读",立刻自动截停,已生成内容完整保留。
量化模型(尤其是小模型)长生成时容易陷入循环:wait wait wait wait …、思考里反复念同一句话、工具调用参数刷同一段 JSON——白烧 token 还占着上下文。目前 LM Studio 没有内置的"检测到循环就停"机制,本插件补上这一环。
插件注册一个 Guarded Generator,包裹本地已加载的模型,逐片段转发输出的同时做两层检测:
检测同时作用于三路流:正文、思考(reasoning)、工具调用参数,可分别开关。
触发后:底层预测立即 abort(服务端停止生成)、已输出片段保留、本轮正常收尾(等同用户点停止),并在末尾附一行提示(可关闭)。不删除任何内容。
- | 默认忽略字符)不会误判。| 项 | 默认 | 说明 |
|---|---|---|
| Model Key | (空=当前模型) | 要守护的本地模型 |
| Temperature | 0.8 | 透传给模型 |
| Repeat Threshold | 10 | 连续重复触发阈值,越小截停越早 |
| Chant Threshold | 4 | 整句循环触发阈值 |
| Guard Thinking Stream | 开 | 检测思考流 |
| Guard Answer Stream | 开 | 检测正文流 |
| Notify On Stop | 开 | 截停时附提示行 |
在聊天的模型选择器里选本插件提供的 guarded 生成器即可生效。
Real-time repetition guard for LM Studio: the moment a local model starts looping on repeated text — in the answer, in the thinking stream, or in tool-call arguments — generation is stopped automatically. Everything generated before the loop is kept intact.
Quantized local models (especially small ones) can degenerate into wait wait wait wait … loops mid-generation, chant the same sentence in reasoning, or spam identical tool-call JSON — burning tokens and polluting the context. LM Studio ships no built-in loop breaker; this plugin adds one.
The plugin registers a Guarded Generator that wraps a locally loaded model. Every fragment is forwarded to the UI and inspected by two detectors:
All three streams are guarded independently: answer text, thinking/reasoning, and tool-call arguments, each toggleable.
On trigger: the underlying prediction is aborted immediately (the server stops generating), emitted fragments are preserved, the turn finishes cleanly (exactly like a user stop), and an optional one-line note is appended. Nothing is deleted.
- | are ignored chars) never trigger.| Setting | Default | Meaning |
|---|---|---|
| Model Key | (empty = current) | Local model to guard |
| Temperature | 0.8 | Passed through to the model |
| Repeat Threshold | 10 | Consecutive-repeat trigger; lower cuts earlier |
| Chant Threshold | 4 | Sentence-loop trigger |
| Guard Thinking Stream | on | Detect loops in reasoning |
| Guard Answer Stream | on | Detect loops in the answer |
| Notify On Stop | on | Append a note when cut off |
Pick the guarded generator provided by this plugin in the chat model selector.
Detection strategy inspired by dsh-repetition-guard / dsh-dupguard (DeepSeek Harness) and Qwen Code's LoopDetectionService.
MIT
npm install
npm run dev # 开发模式(热重载)
npm run push # 发布到 LM Studio Hub
npm install
npm run dev # development mode (hot reload)
npm run push # publish to LM Studio Hub
npm install
npm run dev # 开发模式(热重载)
npm run push # 发布到 LM Studio Hub
npm install
npm run dev # development mode (hot reload)
npm run push # publish to LM Studio Hub