Preface

The DSH plugin mechanism allows different capabilities to be attached to the same runtime flow. For model streaming output, a common issue is that adjacent text increments generate numerous small events; in long sessions or multi-agent concurrency scenarios, these events enter the session log, push, and frontend processing pipelines.

dsh-pref-kit is a DSH performance plugin that merges adjacent text / reasoning increments within the same text block at the data stream source before writing them to the session log and push. This reduces the volume of session events, alleviating lag and resource consumption in long sessions and multi-agent concurrency. The plugin does not alter any interfaces or protocols.

What This Is

gameswu/dsh-pref-kit is maintained by gameswu, licensed under MIT, currently at version 0.2.1, and requires node >= 20.

It targets DSH’s web profile, provides streaming merge capability by default, and offers a configuration card in Settings → Plugins. All experimental switches are disabled by default.

Core Features

  • Streaming Merge (enabled by default): Merges adjacent text / reasoning increments within the same text block before writing them to the session log and push.
  • Fully Transparent Mode: When windowMs = 0, merging is disabled, and tokens are passed through individually, equivalent to the per-event behavior without the plugin.
  • Configuration Card: Settings → Plugins provides a dsh-pref-kit configuration card. Changes take effect immediately after saving and persist across restarts.
  • Experimental Switches (all off by default): Include replacing the trajectory view, chat-area rendering hints, and runtime line management.
  • Runtime Line Management: Official plugin lines can be disabled or enabled based on a whitelist. Changes take effect immediately on the Host and persist, but clients need to refresh the page.
  • Compatibility Boundary: No interfaces or protocols are altered.

Installation and Enablement

Before installing, obtain the dsh-pref-kit source directory locally. After building, load it into the target profile using the file: method.

cd dsh-pref-kit
npm run build
dsh plugin --profile web add "file:$(pwd)"

The first command enters the plugin source directory, the second builds the plugin, and the third loads the current directory as a local plugin into the web profile.

After loading, a DSH restart is required for the plugin to take effect. The following line in the startup log indicates that the streaming coalescer is active:

[dsh-pref-kit] llm/stream coalescer active

To update the plugin, rebuild first, then remove the old plugin and re-add it:

npm run build
dsh plugin --profile web remove dsh-pref-kit
dsh plugin --profile web add "file:$(pwd)"

To uninstall, use:

dsh plugin --profile web remove dsh-pref-kit

Typical Usage

By default, the plugin enables streaming merge. The merge window is controlled by windowMs, with a default value of 30 ms.

windowMs = 30
windowMs = 0

windowMs = 30 means merging adjacent text increments within a 30 ms window; windowMs = 0 disables merging and passes tokens through individually. A larger window reduces events more significantly, but the latency of the first character is approximately equal to the window size.

Experimental items are disabled by default and can be configured via the Settings → Plugins → dsh-pref-kit card:

  • Replace Trajectory View: Used to take over the official trajectory entry; the official ui-trajectory line must be disabled first.
  • Chat-area Rendering Hints: The display remains unchanged, but the browser reduces drawing of content outside the viewport.
  • Runtime Line Management: Disables or enables official plugin lines based on a whitelist. Changes take effect immediately on the Host and persist; clients need to refresh the page.

Offline benchmarks show that with a 30 ms merge window, event volume decreases by 11–56%; specifically, short replies −45.6%, long replies −53.5%, 6-way concurrency −55.6%, and complex long sessions −11%.

Applicable Scenarios and Notes

Suitable for DSH use cases with long sessions, multi-agent concurrency, and a high volume of streaming events. If you want to reduce pressure on session logs, push, and frontend processing, keep the default streaming merge; if you need the lowest per-token latency, set windowMs to 0 to restore per-event transparent pass-through.

Before using experimental items, confirm whether the corresponding official lines are disabled or enabled. For example, replacing the trajectory view requires disabling the official ui-trajectory line first; runtime line management takes effect immediately on the Host and persists, but clients see the final state only after refreshing the page.

The plugin runs with the permissions of the current DSH process. Before installation, review the source code, MIT license, and the plugin lines and runtime behaviors it modifies, and confirm they meet your environment’s requirements.

References

The value of dsh-pref-kit lies in merging adjacent text increments in streaming output without altering interfaces or protocols, reducing session event volume while retaining control over merge disabling and experimental switches.

Directory page (from plugin clues): https://www.skillhub.cn/plugins/gameswu/dsh-pref-kit
GitHub: https://github.com/gameswu/dsh-pref-kit