dsh-turn-continue: Automatic Resumption of Session Turns and Fallback Routing

Introduction

When running agent tasks in DeepSeek Harness (DSH), turns sometimes end silently: the model only outputs reasoning without body text or tool calls; a single output hits the max-tokens limit and is truncated; or the request returns errors like rate limiting or timeout causing turn/end. These situations often require manually sending “continue” again or manually switching models to retry. dsh-turn-continue (Session Guardian), after the host reports corresponding events, automatically continues running according to the strategy or switches to a backup model to arrange the next round; it does not intervene when there is normal body text or tool calls. Below is an introduction to its positioning, behavior, configuration, and installation methods.

What is it

dsh-turn-continue is released by maintainer lmmcsb, categorized under Model Inference, current version 0.1.0, MIT license. It listens to session turn events and automatically continues in scenarios like empty turns, output truncation, or model errors hitting configured error codes; when a model error causes the turn to terminate, it first isolates the failed route, selects a healthy backup according to the list, and then submits “continue”. The plugin does not analyze if the task is complete, nor does it override host exit, process crash, or long idle requests.

Core Behavior

The handling logic can be summarized in the table below (consistent with the README):

Scenario Handling
Turn has body text or tool calls Do not continue as an empty turn
No body text, no tool calls, and reasoning character count reaches minReasoningChars Before the turn ends, use steer to resend steerText (default “continue”)
Host reports max-tokens Arrange the next round using followup
Request error code hits tripCodes Counted as a circuit breaker; keep other host retries
The above errors eventually lead to turn/end Isolate failed route, select backup in order of fallbacks, then arrange continuation
No available backup Can continue trying on the original route; stop continuing when unable to switch to an available route for the 3rd consecutive time
User stops, archives, disables plugin, new input, or new turn Cancel pending resend; only allow resending on user interruption if continueOnAbort is true

Budget: Maximum maxContinuePerTurn times per turn, maximum maxContinuePerSession times per 10-minute session window; if either is 0, no continuation occurs. Duplicate end events will not be resent multiple times; during the wait for resend, configuration, session identity, turn status, and budget are verified again.

Interface and Status

Every session input box toolbar has a “Session Guardian” indicator light. The master switch is a global switch, reading and writing to all sessions under the same status file, not a single-session independent switch. Green is on, gray is off, yellow indicates read/write failure.

“Settings → Session Guardian” allows changing the continuation strategy, values, fallback models, circuit breaker and recovery, and runtime status. Ordinary settings require clicking “Save Settings”; the master switch is saved individually and immediately. Fallback models are two-level dropdowns (Vendor → Model), merging host declarations, activated vendors, and model configurations; non-enumerable saved items are still displayed.

Status and settings are saved in $DSH_HOME/turn-continue.json (or .dsh in the user directory if DSH_HOME is not set). The same file is shared by the same DSH_HOME, currently not isolated by profile.

Circuit Breaker and Health Probe

Model-level and vendor-level circuit breakers jointly determine routing. Default tripCodes include: RATE_LIMIT, SERVER, TIMEOUT, TRANSPORT, QUOTA, EMPTY_RESPONSE; authentication, permission, and parameter errors are not on this list and will not trigger automatic continuation.

When enableProbe is enabled, after the cooldown expires, a ping health probe is sent via a real model request (may incur charges). It is only considered successful if it has non-empty content and ends normally or is truncated; disabling the probe recovers based on the cooldown time. The health probe is restricted by probeTimeoutMs, probeMaxTokens, etc.; the scheduled task is cancelled and cancellation signals are sent to in-flight requests when the master switch is off, the probe is disabled, or the plugin is destroyed.

Configuration Highlights

Initial plugin configuration is merged with turn-continue.json, with the file taking priority. Fields are validated for type and range; fallbacks is [{provider, model}], de-duplicated in order, with a maximum of eight items.

Common Items Examples:

Field Default Meaning or Range
enabled true Master Switch
steerText 继续 Resend content, max 200 chars
maxContinuePerTurn 3 Per-turn limit, 0–20
maxContinuePerSession 30 Per-10min session limit, 0–500
continueOnEmptyTurn true Continue on empty turn
continueOnMaxTokens true Continue on truncation
continueOnModelError true Continue on specific model errors
minReasoningChars 40 Empty turn reasoning char threshold, 0–4000
continueCooldownMs 1200 Wait before resend, 0–60000
fallbacks [] Fallback route list
modelCircuitThreshold 2 Model failure count threshold, 1–20
platformCircuitThreshold 2 Circuit-breaker model count threshold within vendor, 1–50

See the GitHub README for the complete field table.

The host also provides HTTP APIs (unified authentication): GET|POST /api/dsh-turn-continue/state, /settings, GET /api/dsh-turn-continue/models; and emits events like turn-continue/fallback, turn-continue/circuit-opened, turn-continue/probe, facilitating integration for monitoring or secondary development.

Installation and Enablement

The plugin runs with the current DSH process permissions. It is recommended to review the repository source code and MIT license before installation. The official installation methods are as follows.

  1. Install from a pre-built package (no build required, no allowBuilds needed):
dsh plugin --profile <profile> add https://github.com/lmmcsb/dsh-turn-continue/releases/latest/download/dsh-turn-continue.tgz
  1. Or install directly from the repository source code:
dsh plugin --profile <profile> add github:lmmcsb/dsh-turn-continue

Replace <profile> with your profile name (usually desktop on the desktop). After installation, you need to restart the DSH Desktop App once: the desktop side injects the manifest into the snapshot when the host starts; newly installed client plugins will only enter the page after a restart.

Typical Usage

  1. After installation and restart, open the “Session Guardian” master switch in the input box toolbar (takes effect globally).

  2. Go to “Settings → Session Guardian”, enable continuation for empty turns, max-tokens, and model errors as needed; set limits like minReasoningChars and maxContinuePerTurn to avoid infinite resending for long tasks.

  3. Configure backup provider / model in fallbacks by priority (up to eight items). When a model error causes the turn to end, the plugin will isolate the failed route and try the healthy routes in the list, appending a switch notification in the session if necessary (notifySwitch defaults to true).

  4. If enabled simultaneously with dsh-model-failover, they will compete for model routing, so only one should be kept. If processing empty turns simultaneously with @nlflora/dsh-empty-turn-guard, resending will be duplicated, so one of the empty turn entry points should be disabled.

Applicable Scenarios and Notes

Suitable for agent development and long task debugging where you need to reduce manual interruption caused by “empty turns, truncation, and recoverable model errors”. Not suitable for replacing task completion judgment, nor can it guarantee that the vendor side immediately stops sent probes or requests (depending on the adapter’s support for cancellation signals).

This plugin relies on the host Agent lifecycle, agents, llm, Webserver, and Client Slots; it selects a backup and submits the next round after turn/end, and cannot rewrite the frozen current request. When the status file is corrupted, automatic operations will pause, requiring a “Reload” in the settings page or repairing turn-continue.json.

The community directory SkillHub Plugin Page and GitHub Repository are independent sources with no official affiliation to DeepSeek / Fangfei; the DSH ecosystem emphasizes “everything is a plugin,” and installation and configuration follow the repository README.

Following the steps above, you can use configurable continuation and failover in DSH sessions, letting the plugin handle common “stuck turns” according to strategy, while focusing your energy on the design and acceptance of the task itself.

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

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

Xiaoye