返回目录
模型与 MCP 插件

dsh-unlimited-retry

xalor888/dsh-unlimited-retry

Unbounded model-request retry for the DeepSeek Harness agent loop, with a live Settings panel.

Stars
4
Forks
0
Issues
0
更新
9 天前

PROJECT TOPICS

项目标签

INSTALL REFERENCE

安装参考

未验证
dsh plugin --profile web add github:xalor888/dsh-unlimited-retry

该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。

PROJECT README

README

dsh-unlimited-retry

English · 简体中文

CI npm license node dsh

Unbounded model-request retry for the DeepSeek Harness agent loop, with a live Settings panel.

A long unattended run should not die because one request hit a transient network error. This plugin keeps such a request retrying — exponential backoff, with a delay ceiling — until it succeeds or you stop it.

Standard DSH bundle plugin, one-command install. The same package supports both the DSH Web UI and the official desktop client (Electron).

The Settings panel: live retry counters, the effective retry ladder, and the policy editor

Figures above are sample data. The layout, copy, and controls are the plugin's own.

Where to install it

This repository maintains one product line (main). The same package supports both surfaces.

Surface Install
DSH Web UI Open the Plugins page, click Add plugin, and enter dsh-unlimited-retry — or run dsh plugin --profile web add dsh-unlimited-retry in a terminal
Official desktop client (Electron) Open the Plugins page, click Add plugin, and enter dsh-unlimited-retry

Installing from the UI

Both surfaces ship the plugin manager, so the shortest path is the same:

  1. Open Plugins in the app.
  2. Click Add plugin.
  3. Enter dsh-unlimited-retry (or dsh-unlimited-retry@<version> to pin one).
  4. Confirm, then reopen the app or reload the page if the Settings page does not appear immediately.

The dialog accepts npm packages, Git repositories, and local directories, so the same box also takes github:xalor888/dsh-unlimited-retry or a link: path.

Why the desktop must not use dsh plugin --profile desktop

The desktop client reads a profile named desktop, which is reserved for the Electron application — the CLI refuses to touch it on purpose:

error: profile "desktop" is managed exclusively by the Electron application

A --profile web install therefore lands in the web profile, while the desktop window reads desktop, so nothing appears. The UI path above is scoped to whichever profile the running app actually owns, which is why it is the one to use.

Why the desktop works: the desktop profile is the Web template (base + web-app), and Electron loads the local Web UI URL. The dsh.client panel is therefore loaded by client-modules there too — no separate client build.

The dsh web command line uses its own web profile: restart the host after an update, then hard-reload the browser (Ctrl+F5, or Cmd+Shift+R on macOS) to bypass the cache.

Why a separate plugin

DSH ships @deepseek-ai/dsh-llm-retry, but it only executes retries — the budget lives on each provider adapter's retryPolicy. Its default mode: "normal" gives up after maxRetries (5 in this build) and then delegates, so the step fails, the turn closes with an error, and the run ends. mode: "always" exists but is all-or-nothing per provider and has no delay ceiling.

This plugin adds a layer behind all of them. agent/request-error is a waterfall event and Cordis runs listeners outermost-first, so the last-registered listener is the deepest: every other recovery gets the first word, and only a failure that nobody recovered reaches this plugin.

The retry ladder

With the stock 5-retry provider policy the effective order is:

Attempt Handled by Behaviour
1 – 5 the provider's retryPolicy Its own budget, codes, and delays
6 – ∞ this plugin Exponential backoff with jitter, capped at maxDelayMs

Other layers registering on the same event — context-overflow compaction, image offload (dsh-compaction-image-offload), any other retry plugin — sit ahead of this one too. That ordering is the entire reason this plugin registers itself last, and it is what keeps the provider's own policy authoritative.

Does it work everywhere?

It is a Host plugin, not a preset plugin, so it applies to every session the profile starts, under every preset. All of the following was verified against the shipped contracts, not assumed:

Situation Applies Basis
Any agent preset (standard / ptc / minimal / cordis) ✅ Host plugin, preset-independent
Sibling agents in one composition ✅ Each keeps its own ladder
An agent mounted inside a preset scope ✅ Real Cordis scope-dispatch test
headless / ACP / SDK composition (no Web server) ✅ retries, no panel One event listener; no Web service needed
DSH Web UI ✅ dsh.client panel
Official desktop client (Electron) ✅ Desktop profile = Web template, same Web UI
ABORTED (you cancelled) ❌ never retried, by design A cancellation is not a fault
A request the adapter never admitted ❌ never reaches the event No agent/request-error is produced
A failure before the loop has a turn ❌ never reaches the event Same

Features

Retry behaviour

  • 🔁 Unbounded where that is honest: no per-step attempt limit for codes that can recover, and a hard per-turn ceiling so a permanent fault cannot hold a turn open
  • ⏱️ Exponential backoff with jitter: starts at initialDelayMs, doubles, capped at maxDelayMs, with per-delay randomization so synchronized storms cannot form
  • 🚧 The ceiling is a hard constraint: maxDelayMs wins any conflict. Ask for 10 ms and you get 10 ms — it is never silently raised because initialDelayMs was larger
  • 🛑 A cancellation is never retried: ABORTED is terminal at any configuration (see below)
  • 🎯 Provider delays are honoured but clamped: providerRetryAfterMs is respected and capped by maxDelayMs, so one provider cannot park the run indefinitely
  • 🧭 Per-step ladders: a ladder belongs to one step, so a new step restarts at the initial delay instead of resuming at the previous ceiling
  • 🔌 Works without a provider policy: also retries when the adapter published no retryPolicy (toggleable)

Durable events

Each scheduled retry appends two events, in the same order as dsh-llm-retry:

  1. llm/retry — before the wait, so the log shows a wait that really happened;
  2. llm/retry-started — after the wait, when the request is actually re-sent.

A retry cancelled by an abort or a plugin unload therefore leaves a llm/retry record with no matching llm/retry-started, which is exactly what happened. mode is recorded as always, and policyKey is the fixed namespace unlimited-retry, which cannot collide with a provider budget.

Settings panel

The top of the panel: live status, counters, and the ladder showing where this plugin sits

  • 📊 Live status: a pill shows whether the host half answers
  • 🔢 Counters: total retries, waits in flight, sessions retrying, last retry, uptime
  • 🪜 Effective ladder: what happens on each attempt, with an honest No limit instead of a fabricated cap
  • 📈 Breakdown: retries per failure code and per provider, plus the failures declined because their code is terminal
  • 🕒 Recent retries: attempt, code, provider, delay, and when, with relative times
  • ⚙️ Policy editor: switches and numbers write straight back to the profile patch layer through the Harness configEditor, surviving a restart and hot-reloading the host half
  • 🏷️ Terminal codes: add one at a time (with suggestions from the real Harness vocabulary), or apply the recommended set in one click
  • 🧹 Reset counters: behind an explicit confirmation
  • 🎨 Theme-driven: only --dsw-alias-* tokens, so light/dark and future rethemes follow automatically
  • ♿ Accessible: switches are real role="switch" controls with aria-checked; no DOM outside the component tree
  • 🌏 Bilingual: panel and display metadata, English and Chinese

ABORTED: the one unconditional terminal code

A cancellation is not a fault — the turn was stopped, or the process is shutting down. dsh-llm produces an aborted finish when signal.aborted || code === "ABORTED", which means an ABORTED failure can arrive while the loop's own signal is still live.

Retrying it would re-run work you just cancelled, so the guard runs before excludeCodes and clearing that list does not re-enable it. Code matching is case-insensitive and whitespace-trimmed on both sides, so Aborted, ABORTED and aborted are the same code.

The panel states this rule explicitly, so it never looks like a setting was silently ignored.

Defaults, and what they cost

autoRetry: true
maxAttempts: null        # no per-step attempt limit
initialDelayMs: 1000
maxDelayMs: 60000
jitterRatio: 0.2
retryWithoutProviderPolicy: true
retryCodes:              # the set the Harness itself retries
  - EMPTY_RESPONSE
  - RATE_LIMIT
  - SERVER
  - TIMEOUT
  - TRANSPORT
retryAllCodes: false     # true = retry everything that is not excluded
maxRetriesPerTurn: 40    # hard stop across all steps of one turn
excludeCodes: []
recordSessionEvents: true
log: true
markerFile: null

Only the codes the Harness itself declares retryable are retried. That list is copied from dsh-llm's own DEFAULT_RETRYABLE_CODES rather than invented here: it is the judgement of the layer that knows what each failure means. Everything else — auth, quota, billing, context overflow, and any code no adapter classified — is handed straight back to the loop.

Version 2.x defaulted to the opposite, and it was wrong in a specific and expensive way: an adapter that cannot classify a stream error reports an opaque code (dsh-llm-pi-ai calls it PI_AI_ERROR) that also covers its explicitly non-retryable states, so 2.x retried a permanent fault with no ceiling while the turn never ended. A code nobody recognised is not evidence that a retry helps.

Two more bounds:

  1. maxRetriesPerTurn (default 40) is a hard stop across all steps of a turn. The step ladder restarts every step, so without it a fault that survives each step would begin again at attempt 1 forever.
  2. maxAttempts caps per step, exactly as before.

Ways to adjust the scope:

  1. Set maxAttempts to a positive integer — this plugin then stops after that many tries per step and delegates, exactly as if it were not installed.

  2. Widen the scope with retryAllCodes: true, or add a specific code to retryCodes. Then narrow it with excludeCodes, which always wins.

  3. List codes in excludeCodes. The panel has a one-click Use recommended set action for the codes where a retry re-sends a request that fails identically:

    AUTH, UNAUTHORIZED, FORBIDDEN, BILLING, QUOTA, ACCOUNT_QUOTA, MISSING_CREDENTIAL, INVALID_CREDENTIAL, MODEL_NOT_FOUND, NO_ADAPTER, CONTEXT_WINDOW_EXCEEDED, CONTEXT_OVERFLOW, CONTEXT_LENGTH, INVALID_REQUEST

    IMAGE_OFFLOAD_REQUIRED is deliberately absent: dsh-compaction-image-offload recovers it by shrinking the request and registers ahead of this plugin. If it declines, retrying is the correct next move.

A cleared numeric field falls back to its default rather than being read as zero — Number(null) is 0, which for a delay is a busy loop and for jitter is no jitter at all.

Install

From npm (recommended)

# Web UI
dsh plugin --profile web add dsh-unlimited-retry

For the official desktop client, use the in-app Plugins → Add plugin dialog instead — see Where to install it. The CLI refuses --profile desktop by design.

From this repository

dsh plugin --profile web add github:xalor888/dsh-unlimited-retry

⚠️ The npm name and the github: spec are the same package name — don't mix them; installing both leaves conflicting entries. If you installed via github:, run dsh plugin --profile web remove dsh-unlimited-retry first.

Local development

dsh plugin --profile web add link:/absolute/path/to/dsh-unlimited-retry

Then open Settings → Retry.

Verifying a mount

If the panel does not appear, check the host half and the client half separately:

  1. Host half: ~/.dsh/adapters/unlimited-retry/mounted.json exists and its version is the version you meant to install;
  2. Client half: /plugins/??dsh-unlimited-retry/client.js&rev=… returns 200 in the browser (or the desktop's devtools).

Host half present but client half missing is a cache problem — hard-reload (Ctrl+F5, or Cmd+Shift+R on macOS). If the host half is absent, the plugin never mounted: go back to the install step and confirm which profile you installed into.

Layout

dsh-unlimited-retry/
├── package.json          # bundle metadata (dsh.bundle.patch / dsh.client / icon / exports)
├── cordis.patch.yml      # mount declaration, with every default
├── icon.svg              # plugin-list icon (the host reads it as a data URL)
├── index.js              # host half: listener, backoff, session events, counters, routes, Config schema
├── client.js             # browser half: the Settings panel (browser bundle format)
├── locale/
│   ├── en.json           # display title/description (English)
│   └── zh.json           # display title/description (Chinese)
├── test/
│   ├── host.test.mjs     # retry decision path + every endpoint
│   ├── client.test.mjs   # panel registration, i18n parity, rendering, states
│   ├── bundle.test.mjs   # package shape, patch completeness, icon, license
│   └── projection.test.mjs # integration against the real projection service + dispatcher
├── README.md / README.zh.md
└── LICENSE

Configuration

Edit the config block on the unlimited-retry row, or use the panel. An override anywhere above the bundle patch replaces the whole config, so a layer that overrides this row must restate every field it wants to keep.

The plugin also exports a Config schema, so its fields appear in Config.listConfigs and are validated by the Loader.

Field Type Default Purpose
autoRetry boolean true Turn off to leave every failure to the loop
maxAttempts number | null null Cap per step; null/empty means no limit
initialDelayMs number 1000 First backoff delay; clamped by the ceiling
maxDelayMs number 60000 Single-delay ceiling; wins any conflict
jitterRatio number 0.2 Randomization per delay (0–1)
retryWithoutProviderPolicy boolean true Also retry when the adapter published no policy
retryCodes string[] the five retryable Harness codes Codes this plugin retries; anything else is left to the loop
retryAllCodes boolean false Retry every code that is not a cancellation or an exclusion
maxRetriesPerTurn number | null 40 Hard stop across all steps of one turn; null = no turn ceiling
excludeCodes string[] [] Always-terminal codes (case/whitespace-insensitive); wins over retryCodes
recordSessionEvents boolean true Append llm/retry / llm/retry-started
log boolean true Write retry decisions to the DSH log
markerFile string | null null Optional mount-probe path (diagnostics)

HTTP endpoints

The host half adds three routes. They register through the DSH Web server and therefore apply the same browser admission check the rest of the composition uses: an unauthenticated browser request gets 401, an untrusted origin gets 403. Unlike a plain route handler, these do not silently bypass the cookie gate.

Route Method Purpose
/unlimited-retry/stats GET, HEAD The read model the panel renders
/unlimited-retry/config POST Validate and persist a policy change
/unlimited-retry/reset POST Clear the counters ({"confirm": true} required)

Writes return 403 when the composition exposes no admission service, and 409 when the row is not addressable or there is no configEditor. Bodies are capped at 8 KiB and must be application/json.

These routes are a convenience for the panel. The retry behaviour never depends on them, so a headless / ACP / SDK composition mounts the policy with no routes at all.

Verify

npm test        # or node --test test/

Covers the retry decision path (delegation, exclusion, attempt limits, provider delays, abort, dispose, per-step reset, legacy 1.x config keys), every endpoint (status codes, HEAD, admission, body validation, unknown keys, the preset, reset confirmation, a failing editor), the client bundle (registration, i18n parity and placeholder parity, rendering, error/empty/read-only states, token-only styling), the package shape (manifest, patch completeness, icon, license), and integration tests against the real projection service and the real Cordis dispatcher.

To verify a live mount (an unauthenticated 401 there is correct — open the authenticated GUI URL and read the panel):

curl -s http://127.0.0.1:3080/unlimited-retry/stats | head -c 400

Compatibility

Requirement Value
Node.js >= 20
DSH >= 0.2.0-0 < 0.3.0-0 (engines.dsh, enforced by the host's compatibility preflight). Verified against 0.2.1-rc.3, 0.2.1-rc.5, 0.2.2-alpha.2, 0.2.2-rc.1 and 0.2.2-rc.3
Ships dsh-agent-loop and dsh-llm-retry Yes — the retry listener hangs off that event

The session-projection reader adapts to both registration shapes the Host has shipped: the disposer returned before 0.2.2, and the callable thenable returned from 0.2.2 on, whose typeof is "function" while it still carries then. The handle is preferred where it exists, so no deprecated read is performed on a runtime that deprecated it.

The -0 lower bound in engines.dsh is deliberate: the host matches with includePrerelease: true, and only a boundary carrying a prerelease tag admits a prerelease runtime such as 0.2.1-rc.3. A plain >=0.2.0 would silently exclude every -rc build.

  • AbortSignal.any is used when present; a controller-based fallback covers runtimes without it.
  • A 1.x config still mounts: retryAllCodes is ignored and terminalCodes is read as excludeCodes, each with a one-line warning naming the replacement.
  • The Web panel additionally needs configEditor and the settings.section slot. Without them the policy still applies; the page is simply absent or read-only.

How an unfamiliar code is judged

Codes are not the only evidence. When a failure's code is not one this plugin recognises, it reads the message, because a provider that namespaces its own errors — InferHub.ModelArts.81001.400 is one observed shape — can never match a Harness literal, and a policy built only from literals therefore degrades to "retry nothing" for exactly the providers most likely to be flaky.

Evidence in the message Verdict
rate limit, concurrency limit, too many requests, timeout, connection reset, socket hang up, 502/503/504 retry
invalid argument, invalid request, unsupported, context length, payload too large, unauthorized, quota, billing terminal
HTTP 400 except 408/409/425/429, and any other 4xx terminal
HTTP 429, 408, 409, 425, and any 5xx retry
nothing recognisable terminal, and listed in the panel

Transient evidence is checked before permanent evidence on purpose: a gateway can wrap a recoverable condition in a 4xx (the local tier_limit_exceeded ... concurrency limit exceeded failure arrived as a generic upstream error), and wrongly declining a transient failure strands a working turn, while wrongly retrying a permanent one is bounded by the turn ceiling.

Turn this off with classifyTransientFailures: false to restore literal-only matching.

Nothing here is silent. Every refusal lands in a Left to the loop table in the panel with its code, its reason, and its original message, plus a one-click Retry this code too button that adds it to retryCodes.

What this plugin does not touch: tool calls and MCP calls

A retry here re-issues the model request only. It never re-runs a tool.

That is structural, not a promise: agent/request-error is emitted by dsh-agent-loop at exactly one place — when the assistant stream finished with kind === "error" or "aborted" — and the loop's tool execution happens after a message has been produced. A tool that throws never becomes a request-error; it becomes a tool/result error and is thrown by the loop.

Verified against real transcripts rather than by reading code: across 41 recorded retries in the local session store, 41 were preceded by assistant/attempt — the failed stream settlement — and none by tool/result.

So if a turn appears to loop while calling the same tool, the loop belongs to the model or to the tool, not to this plugin:

  • a model that keeps choosing a failing tool is what dsh-repeat-tool-reminder exists for;
  • an MCP server that returns errors will keep returning them until it is fixed;
  • this plugin only decides whether to re-send the request, and since 3.0.0 it only does so for codes that can plausibly recover.

3.1.0

3.0.0 fixed over-retry by allowing only five codes — and over-corrected. A provider that namespaces its errors (InferHub.ModelArts.81001.400) never matches a literal, so that provider stopped being retried for anything at all, transient or not.

  • An unfamiliar code is now judged by its message: rate/concurrency limits, timeouts, connection failures and 5xx retry; invalid argument, context overflow, auth, quota and other 4xx stay terminal.
  • The reported CodeArts: Invalid Argument 400 stays terminal — the bytes are wrong, so the same bytes get the same 400. That part of the 3.0.0 decision was right.
  • Every refusal is listed in the panel with its reason and original message, and each row offers Retry this code too. A plugin that declines silently is indistinguishable from a broken one; that was the real complaint behind the 3.0.0 question.
  • classifyTransientFailures turns the message reading off if you would rather judge by code alone.

3.0.0

Breaking: the retry scope was inverted. 2.x retried every code except a cancellation. In practice that meant an adapter that could not classify a stream error (PI_AI_ERROR) — which also covers its explicitly non-retryable states — was retried with no ceiling, and a turn whose fault survived each step never ended. Real transcripts show the ladder advancing step after step against the same tier_limit_exceeded condition.

  • Default is now the Harness's own retryable set (EMPTY_RESPONSE, RATE_LIMIT, SERVER, TIMEOUT, TRANSPORT). Anything else — including an unclassified code — is left to the loop.
  • retryCodes and retryAllCodes make the scope explicit and reversible. excludeCodes still wins over both.
  • maxRetriesPerTurn (default 40) stops a fault that survives every step, which the per-step ladder alone could never catch.
  • Tool calls and MCP calls were never retried — see the section above, which is backed by 41 recorded retries with no tool/result predecessor among them.

If you relied on 2.x's behaviour, set retryAllCodes: true. The panel's "What gets retried" card makes that a switch rather than a config edit.

Changelog

2.5.1

  • Infrastructure release. The release workflow now publishes through npm trusted publishing (GitHub OIDC) instead of a static token, so there is no credential to store, rotate, or lose, and the long-lived bypass-2FA token is gone.

2.5.0

  • The ladder's last row printed the plugin's first delay beside a label that named the ceiling, so it read "every delay capped at 1.0 min — 1.0 s". It now shows the ceiling itself.
  • "Sessions retrying" dropped to zero while a wait was still running when two failures for one session were waiting at once. The count is now per session rather than one flag per session.
  • Install instructions: both surfaces have the plugin manager, so the desktop client installs from Plugins → Add plugin like any other. The earlier text sent you through a chat session for no reason.

Releasing

Publishing is tag-driven; nothing publishes from a branch, and no npm credential is stored anywhere. The workflow authenticates with trusted publishing: npm verifies a short-lived OIDC token that GitHub issues to this job, matched against the repository and workflow file registered on the package.

# 1. bump the version in package.json (and PLUGIN_VERSION in index.js)
npm version patch --no-git-tag-version   # or minor / major
# 2. land it, then tag the merged commit
git tag v2.1.3 && git push origin v2.1.3

The Release workflow then refuses a tag that disagrees with package.json, tests the tree, packs, publishes with npm provenance, creates the GitHub release with the tarball attached, and finally re-installs the published version from the registry to prove that copy mounts. It needs no secret: only id-token: write, which the workflow already declares.

CI runs the suite on Node 20, 22 and 24, then packs the tarball, asserts the published file set has not drifted, installs it into a clean project, and mounts the installed host half — including the rule that a cancellation never retries.

The integration suite (test/projection.test.mjs) mounts a real Harness, which CI has none of, so it skips there. Run it locally with DSH_INSTALL_DIR=~/.local/lib/node_modules/@deepseek-ai/dsh/node_modules npm test.

License

MIT — see LICENSE.

CLASSIFICATION EVIDENCE

分类依据

项目类型插件
功能分类模型与 MCP
规则置信度中

系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。