DeepSeek Harness Plugin: Fallback Retry + In-Place Patch

Preface

DeepSeek Harness (DSH) embraces the “everything is a plugin” philosophy, exposing extension points to the community. However, in practice, certain errors are silently swallowed by the built-in @deepseek-ai/dsh-llm-retry plugin, causing the entire turn to fail. One category is when sampling produces malformed JSON in tool arguments; the other is when the gateway reports a concurrency limit breach as a plain text message. This plugin addresses both failure types by providing in-place repair and fallback retry at two public extension points.

Plugin Overview

  • Name: dongasai/dsh-llm-retry-guard
  • Maintainer: dongasai
  • Category: Workflow
  • Core Value: For failures that would otherwise kill the entire turn, neither wait pointlessly nor die pointlessly.

Core Features

  1. In-place repair (llm/stream seam)
    - When sampling produces malformed JSON in tool arguments, the adapter throws MALFORMED_RESPONSE.
    - The plugin attempts a repair: for arguments consisting of “two complete JSON values concatenated,” it extracts the first complete value, validates it against the tool schema, and appends a block-end; for arguments with “an unclosed trailing,” it closes the quotes and brackets.
    - If repair fails, the response is passed through as-is, behaving identically to running without the plugin.
    - Real-world malformed-buffer coverage: 207/220 (salvage layer).

  2. Fallback retry (agent/request-error seam)
    - Adds 4 backoff retries for MALFORMED_RESPONSE (3s → 6s → 12s → 24s, with jitter).
    - Adds 5 backoff retries for concurrency/overload phrasing (text mode) (3s → 6s → 12s → 24s → 48s).
    - The retry layer matches on failure codes and a text vocabulary, case-insensitive.
    - Measured retry recovery rate for MALFORMED_RESPONSE: 0/41, so retry serves as a last resort.

  3. Operational tooling
    - Heartbeat file: each apply() overwrites one line of JSON, proving the plugin is mounted and running.
    - Decision ledger: each decision appends one line of NDJSON, queryable for “retry/repair” outcomes.
    - Fully configurable: budget, backoff, jitter, additional codes, additional regex patterns, and disabling the salvage layer.

Installation & Activation

This package is private: true, so there is no registry-based install. Three methods are provided:

DSH Web → left sidebar “Plugins” → “Add Plugin” → enter the repository URL → “Install” → “Activate Now”.
Repository URL: https://github.com/dongasai/dsh-llm-retry-guard

Method 2: Command Line · Git Source

dsh plugin --profile web add github:dongasai/dsh-llm-retry-guard
# or
dsh plugin --profile web add git+https://github.com/dongasai/dsh-llm-retry-guard.git
# Pin to a version (lock to a specific release tag; omit # to track main)
dsh plugin --profile web add github:dongasai/dsh-llm-retry-guard#v0.4.0
dsh plugin --profile web add link:<absolute path to this repo>

Installed as a link: dependency, so code changes take effect immediately. Changes to index.js require restarting the dsh process.

Verify Installation

dsh --profile web --dump-config | grep -A2 'id: llm-retry-guard'

Expected output:

- id: llm-retry-guard
  name: '@dongasai/dsh-llm-retry-guard'

Configuration

By default, the salvage layer is enabled, with 4 retries by code and 5 by text. To customize or verify, override settings in the profile’s cordis.patch.yml:

- id: llm-retry-guard
  config:
    mountFile: ~/.dsh/storages/llm-retry-guard.mount
    decisionFile: ~/.dsh/storages/llm-retry-guard.decisions.jsonl

Common configuration options (defaults):

  • maxRetries: 5 (maximum fallback retries for the same step)
  • initialDelayMs: 3000 (initial backoff delay)
  • maxDelayMs: 60000 (backoff ceiling)
  • jitterRatio: 0.2 (jitter ratio)
  • retryCodes: [] (additional failure codes for fallback; built-in already includes MALFORMED_RESPONSE)
  • maxRetriesByCode: {MALFORMED_RESPONSE:4} (per-code budget override)
  • extraPatterns: [] (additional text pattern regexes)
  • salvage: true (in-place repair toggle; false keeps only the retry layer)
  • mountFile: unset (disables heartbeat)
  • decisionFile: unset (disables ledger)

Typical Usage

After installation and restart, no action is required. The next time sampling produces malformed arguments, the plugin catches it automatically—if repair succeeds, the tool call proceeds; if not, it falls back to backoff retry.

Verify the plugin is working:

cat ~/.dsh/storages/llm-retry-guard.mount
# {"at":"2026-11-18T16:12:32.956Z","pid":1023238,"name":"llm-retry-guard",
#  "maxRetries":5,"initialDelayMs":3000,"maxDelayMs":60000,"jitterRatio":0.2,
#  "extraPatterns":0,"retryCodes":["MALFORMED_RESPONSE","INVALID_REQUEST"],
#  "maxRetriesByCode":{"MALFORMED_RESPONSE":4,"INVALID_REQUEST":2},
#  "salvage":true,"decisionFile":"…/llm-retry-guard.decisions.jsonl"}

Inspect repair decisions:

grep '"outcome":"salvaged"' ~/.dsh/storages/llm-retry-guard.decisions.jsonl | tail -1
# {"at":"2026-11-18T03:47:53.441Z","pid":597975,"provider":"opendisign",
#  "model":"deepseek-v4.1-flash-eco","code":"MALFORMED_RESPONSE","outcome":"salvaged",
#  "tool":"bash","index":0,"rule":"glued","droppedValues":1,"argumentsBytes":405,"message":"…"}

Applicable Scenarios & Caveats

  • Designed for use within DSH, handling failures such as malformed JSON in tool arguments and concurrency limit breaches.
  • The plugin runs with the permissions of the current dsh process; review the source code and license before installing.
  • Does not provide any tools, UI panels, or settings pages; does not retry RATE_LIMIT/429/5xx/TIMEOUT—those are left to the dsh-llm-retry budget.
  • Does not rewrite request bodies, error text, or reclassify upstream errors; does not repair the 13 samples where JSON is cut mid-stream into XML parameter syntax.

Closing Note

This plugin provides in-place repair and fallback retry through two seams, improving the robustness of DSH workflows. Full documentation and source code are available on the directory page and GitHub.

Directory Page

https://www.skillhub.cn/plugins/dongasai/dsh-llm-retry-guard

GitHub

https://github.com/dongasai/dsh-llm-retry-guard

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

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

Xiaoye