DSH Rice Guard (dsh-rice-guard): A passive watchdog for repetitive output in assistant streams

Preface

When running an agent in DeepSeek Harness (DSH), the model occasionally outputs the same fragment repeatedly within the same turn, or fakes progress by swapping numbers in a “Step N” pattern. Such runaway turns keep consuming tokens, and already-outputted content cannot be retracted. The common practice is to manually watch the conversation area and stop it, or filter through logs afterwards. Below we introduce the standalone plugin dsh-rice-guard published by maintainer XiaoSHang05 (called “Rice Guard” in the README): it does not generate any model text, only subscribes to the current turn’s thinking stream and formal output stream, raises alerts when it detects repetitive patterns, and optionally auto-cancels the turn.

What Is This

dsh-rice-guard is a workflow-class plugin for DSH: it passively monitors the real-time increments of agent/assistant-stream, and once a rule is hit, it can call agent.cancel through the host to perform turn-level loss containment. No group chat plugin is needed; when the dock bridge is available, an entry point will be registered, and when unavailable, it can still work via the monitoring page and the global overlay alert.

Repository: https://github.com/XiaoSHang05/dsh-rice-guard
License: MIT (see the repository LICENSE).

Core Features

The plugin itself does not produce text; detection is performed incrementally within a tail window. By default it monitors the thinking stream and output stream of all sessions simultaneously; it can be globally toggled on the monitoring page, or paused/resumed for individual sessions.

The four detection rules are evaluated in a fixed order, and the first one hit takes effect: Periodic Repetition → Custom Phrase → Numbered Loop → Repeated Line Density.

  1. Periodic Repetition: Look for consecutive identical fragments within the tail window; “Repeat Count” defaults to 5, controlling the threshold for consecutive periodic repetitions.
  2. Custom Phrase (disabled by default): Enable on the monitoring page and fill in the sentences you most fear being repeated, one sentence per line (each sentence at least two characters). If it appears customRepeat (default 5) times within a short span, it triggers an alert; normal citations in long texts will not cause false triggers.
  3. Numbered Loop: Identifies fake progress of “the same sentence pattern, with only a number changed on each line”; by default, ≥12 consecutive lines with the same sentence pattern and the ratio of letters to (letters + numbers) ≥60%. Can be disabled with structLines: 0, or the line threshold can be raised.
  4. Repeated Line Density: Normalizes the beginning and end of lines and consecutive whitespace, then compares identical lines; “Repeated Line Ratio” defaults to 75% of the most recent 8 lines being already-seen lines. Raising “Repeat Count” will not disable this rule; the ratio must also be changed.

When a rule is hit, it displays the session, stream, repeated fragment, count, and interruption status. The alert card must be closed by clicking “Got it”; the beep uses WebAudio, and the browser may require prior interaction with the page. Each stream is reported at most once within the same request.

Behavior switches (configuration or monitoring page):

  • cancel: false: Only alerts, does not automatically interrupt.
  • alarm: false: Does not display the alert card.
  • sound: false: Turns off the beep.

The interruption is implemented as a turn-level cancellation; already-outputted characters cannot be retracted; keepInbox: true preserves queued input, which is not equivalent to revoking already-executed tool operations.

Installation and Enablement

The README states compatibility with the currently verified DSH 0.2.0-rc.2; the package declares the peer range as >=0.2.0-0 <0.3.0. The host must provide webServer, the agent runtime, and @deepseek-ai/schemastery ^3.18.1.

In the plugin directory containing the README and package.json, install via local link:

dsh plugin --profile desktop add "link:$($PWD.Path)"

Install from GitHub (no clone needed):

dsh plugin --profile desktop add "github:XiaoSHang05/dsh-rice-guard"

Restart DSH after installing or updating the host code, then refresh the webpage. A “Monitor” tab will appear in the conversation area; alerts are attached to the global overlay. If an old directory link was previously registered on this machine, please handle the old link in the plugin manager before installing the delivery directory, to avoid mixing plugins with the same name. Installation goes through the DSH package flow; if other dependencies in the profile trigger supply chain restrictions, installation may fail — do not relax the entire profile’s security policy for this plugin, and handle the corresponding dependencies according to the failure message.

Typical Usage

  1. After installing and restarting DSH, open the “Monitor” tab in the conversation area.
  2. Confirm that “Enable Monitoring” is on; adjust “Repeat Count”, “Repeated Line Ratio”, and “Numbered Loop Share” as needed.
  3. If the model is known to often get stuck on certain sentences, turn on the custom phrase switch and fill in the sentences line by line.
  4. When a session temporarily does not need monitoring, pause monitoring on that session row; for global silence, you can set cancel: false to keep only alerts.

Changes to the monitoring page take effect immediately, and it tries to persist through the host Settings; when Settings is unavailable or the write fails, the configuration is only kept in memory. The session-level pause list and hit history are memory data, cleared after restart; the history is capped at 50 entries, and the interface shows the latest 20 by default.

HTTP reads and writes are located at /dsh-rice-guard/api/ (e.g., health, state, config, monitor, hits, events); SSE only notifies to re-read, and the status is based on GET state.

Configuration Essentials

Config Key Default Meaning
enabled true Global monitoring switch
minRepeat 5 Consecutive periodic repetition threshold
minUnit / maxUnit 6 / 1024 Search period length range
windowChars 8192 Tail window retained for each stream
densityLines / densityRatio 8 / 0.75 Repeated line window and ratio
structLines / structShare 12 / 0.6 Numbered loop line count and letter ratio
customPhrases [] Custom phrases; empty array means disabled
customRepeat 5 Custom phrase hit count
cancel / alarm / sound true Auto interrupt, alert card, beep
scopeDefault all Default monitoring of all sessions

checkEvery=32 is the internal scanning step size, not a host HTTP configuration field.

Use Cases and Notes

Suitable for: Users of the DSH desktop profile who run agents unattended for long periods and are worried about the thinking stream or output stream repeating text or faking progress with numbered loops.

Boundaries (trade-offs explicitly stated in the README): Very long normal enumerations (e.g., multiple lines of port xxxx is listening) may overlap syntactically with numbered loops, potentially triggering alerts; if you do not agree, you can turn off numbered loops or raise the threshold. Single-character spam or repetitions exceeding the window/period length may be missed; output before the plugin is loaded cannot be retroactively tracked. Intentionally heavy repetition in normal articles may also be interrupted; you can pause monitoring or switch to alert-only according to the scenario.

Security: The plugin runs with the permissions of the current DSH process. Before installing, please read the source code and the MIT license, and confirm that you accept its behavior of subscribing to the global assistant stream and calling cancel on hits. The interface uses the host Web’s authentication boundary and does not provide additional public network authentication.

The community directory site skillhub.cn has no official affiliation with DeepSeek / High-Flyer; the DSH ecosystem emphasizes “everything is a plugin”, and this plugin is an independent community delivery.

Conclusion

dsh-rice-guard turns repetitive output detection into a zero-token-cost side-channel watchdog: thinking and output dual streams, four complementary rules, optional auto cancel, and toggleable alerts. For details, validation records, and development notes, please directly consult the repository README, CONTRACT.md, and VALIDATION.md.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye