DeepSeek Harness (DSH) is a plugin-based agent runtime. When an integrated third-party gateway (such as pi-ai) does not send a termination event message_stop or done after streaming content completion, DSH may misidentify it as a TRANSPORT error and trigger up to 5 exponential backoff retries within the same step. This plugin listens to the llm/stream horizontal waterfall and handles the condition where content has arrived but the termination signal is missing, so the response can be committed normally and unnecessary retries are avoided.

Core Features

  • Listen and repair stream events: Listens to dsh host-side llm/stream horizontal waterfall and intercepts specific errors.
  • Conditional error swallowing: Only discards the error and cleanly terminates the stream when content has fully arrived and unclosed tool-call arguments are valid JSON.
  • Precise scope: Supports specifying providers and models via configuration, without affecting other interfaces.
  • No credential access: Acts only as a stream wrapper layer, does not initiate additional network requests, and does not involve sensitive information.

Installation

Ensure the dsh web version meets the requirement (>= 0.1.0-rc.6) before installing.

dsh plugin --profile web add dsh-missing-stop-heal

After installation, restart the dsh process (profile bundles are read at startup).

Configuration

Configuration can be provided via inline configuration (agent.cordis.yml) or the settings page (GUI). The core configuration item is the rules array; each rule contains provider and models.

After installation as a web profile bundle, the dsh web settings sidebar will show a “Stream Retry Repair” entry. In the settings page:
- Provider: Select from a dropdown or manually enter the provider identifier (e.g., xjhc).
- Models: Supports the * wildcard; enter a specific model or leave empty to apply to all models.
- Enable: Check to enable the rule; changes take effect immediately after saving.

Option B: Inline YAML Configuration

Append to the end of the agent preset’s agent.cordis.yml:

- id: missing-stop-heal
  name: './heal.mjs'
  config:
    rules:
      - provider: xjhc
        models: ['*']
        enabled: true

Usage

  1. Effective scope: Only applies to requests whose provider and model match a rule. Requests that do not match any rule (such as official APIs) are completely unaffected.
  2. Repair logic: When a STREAM_CLOSED error is detected and the condition “content arrived, tool-call args are valid JSON” is satisfied, the plugin swallows the error and lets the stream end normally.
  3. Does not mask errors: For errors such as incomplete arguments, empty responses, genuine network failures, authentication failures, etc., the plugin lets them pass through or throws them as usual, without masking real errors.

Notes

  • Version requirement: Requires dsh web >= 0.1.0-rc.6.
  • Rule application: Configuration changes do not apply retroactively to in-flight requests; they only affect the next request.
  • License: MIT License.

Verification

Check the $DSH_HOME/sessions/.../session.jsonl log to determine repair effect:
- Before repair: llm/retry, TRANSPORT, and Anthropic stream ended before message_stop may be visible.
- After repair: sourceEventSeqs of assistant/message form a single contiguous interval, and llm/retry events no longer appear.

Ecosystem Context

The philosophy of DeepSeek Harness is “everything is a plugin”. This plugin is maintained by the community, has no affiliation with the official DeepSeek team, and is intended for developers to integrate according to their own needs.