Introduction

When using DeepSeek Harness (DSH), some upstream model providers or API gateways may leak raw DSML (DeepSeek Markup Language) protocol tags into assistant-visible text streams. User interfaces often display trailing protocol junk such as </|DSML|parameter> </|DSML|invoke>, causing chat bubble visual pollution, Markdown rendering failures, and potentially interfering with downstream agents or clipboard exports.

@goodandready/dsh-dsml-artifact-guard is a lightweight, host-side runtime stream interceptor designed specifically for DeepSeek Harness. It cleans up these terminal artifacts in real time before text reaches the user interface.

Core Features

Synchronous Stream Contract Preservation

In the Cordis framework, llm/stream event listeners must synchronously return an AsyncIterable. If the interceptor is asynchronous, it returns a Promise, causing Harness to throw TypeError: stream is not async iterable at runtime. This plugin strictly follows the synchronous hook contract to ensure runtime stability.

Chunked Buffer Pipeline

Protocol tags often arrive across multiple TCP or WebSocket text increments. The plugin maintains a small sliding buffer (96 bytes) to reliably match and remove multi-chunk tails. This ensures that split tags are detected and cleaned as a single terminal artifact.

100% Fail-Open Safety

The plugin never discards legitimate user or assistant text. Genuine discussions about DSML syntax or internal tool calls remain intact. Non-text chunks (tool call increments, usage, completion signals) are forwarded immediately, without any delay.

Targeted Provider and Model Scope

The plugin restricts handling specifically to provider and model configurations that exhibit tag leakage, while traffic for other models passes through with zero overhead.

Native Web UI Settings Card

The plugin registers directly in DeepSeek Harness’s settings.plugin.item slot. Configuration items (mode, providerId, modelId) are updated reactively through scope.watch, without requiring a Harness restart. It also handles snapshot state awareness and protection bypass warnings.

One-Click In-Place Auto-Updater

A standard HTTP management route /api/dsh-dsml-artifact-guard/update is mounted via lib/updater.js. It uses semantic version checking and strictly restricts write operations (POST) to local loopback connections, ensuring secure updates.

Full Dark and Light Theme Compliance

All client UI styles are defined strictly through DSH’s --dsw-alias-... CSS custom properties and the color-mix() function, with no hardcoded hexadecimal or rgba color literals, ensuring high contrast across all themes.

Dependencies and Environment

  • Runtime: Requires Node.js 20 or later.
  • Peer Dependencies:
    • @deepseek-ai/cordis ^4.0.1
    • @deepseek-ai/schemastery ^3.18.1
  • Core Architecture Note: DSH’s upstream core stream pipelines (such as dsh-llm-pi-ai and dsh-llm-deepseek*) do not perform terminal DSML protocol cleanup, which is the gap this plugin fills.

Typical Usage

Flexible Operation Modes

The plugin supports three operation modes:
* sanitize (default): Removes terminal DSML closing tags and logs a warning with the number of artifacts removed.
* audit: Emits diagnostic logs only via ctx.logger.info(...), without modifying the user-visible stream.
* disabled: Completely bypasses processing.

API Management Route

Administrative updates are handled via the following route: /api/dsh-dsml-artifact-guard/update.

Use Cases

This plugin is suitable for any setup that runs model inference with DSH and encounters upstream providers leaking DSML closing tags in streaming responses. It provides zero-overhead filtering through a native settings card and is ideal for developers who want to keep the chat interface clean and avoid downstream agent parsing errors.

Summary

dsh-dsml-artifact-guard provides a reliable stream interception solution that addresses upstream protocol tag leakage while complying with DSH’s synchronous hook contract and fail-open safety principles.