DSH’s default dsh-llm-retry mechanism usually stops after 5 retries when encountering timeouts, rate limits, or network fluctuations. If the request fails at that point, the session is often interrupted directly. dsh-session-robustness aims to address this issue. It runs after the official retry mechanism and continues retrying transient API failures until the request succeeds, is canceled, or is paused.

Plugin Positioning

This is a DSH workflow plugin maintained by bainianlaoyao. It does not change model policies or automatically send “continue” instructions. Instead, within the same open turn/step, it retries indefinitely for specific transient errors (such as TIMEOUT, RATE_LIMIT, STREAM_CLOSED, etc.) and does not write failed chunks into the historical context.

Installation

Install via the command line:

dsh plugin --profile web add dsh-session-robustness

After installation, restart the web profile. The “Session Robustness” option will appear in the settings page.

Core Features

1. Takes Over the Retry Flow

The plugin is mounted on the agent/request-error waterfall. Its execution order is after the official dsh-llm-retry and before compaction (context compression):
1. adapter stream failure
2. agent/request-error waterfall
3. compaction (only handles CONTEXT_WINDOW_EXCEEDED)
4. dsh-llm-retry (official 5 retries)
5. this plugin (after the official retry budget is exhausted, transient failures are retried)

2. Retry Strategy

  • Coverage: In addition to the eligible codes for official retries (EMPTY_RESPONSE, RATE_LIMIT, SERVER, TIMEOUT, TRANSPORT), this plugin additionally and unconditionally covers STREAM_CLOSED, MALFORMED_RESPONSE, STREAM, HTTP_408, HTTP_409, HTTP_425, HTTP_429, HTTP_499, and HTTP_5xx.
  • Backoff mechanism: Uses exponential plus jitter backoff, preferring the Retry-After header returned by the server.
  • Codex-specific handling: Starting from version 0.1.6, for the openai-codex provider, it handles WebSocket continuation loss to prevent subsequent requests from being anchored to an old response.id due to stream failure.
  • Control: It can be paused or disabled from the settings page without uninstalling the plugin.

Configuration and Usage

Interface Operations

  1. Open Settings → Session Robustness.
  2. By default, it is enabled with a retry limit of 0 (that is, indefinite retries).
  3. While the official retry is still in progress, the UI displays “Retried model request (n/5)”.
  4. After the official 5 retries are exhausted, above the composer it will show “Official 5 retries exhausted, taking over retry N”, and you can pause it on the spot.

YAML Configuration

If a hard limit is required, edit $DSH_HOME/settings.yaml:

session-robustness:
  enabled: true
  paused: false
  maxRetries: 0          # 0 = infinite (after official 5 retries)
  initialDelayMs: 1000
  maxDelayMs: 30000
  jitterRatio: 0.2
  extraRetryableCodes: [] # for example, INVALID_REQUEST; permanent errors are still rejected

Notes

  • Permanent errors are not retried: Permanent errors such as AUTH, QUOTA, CONTEXT_WINDOW_EXCEEDED, MISSING_CREDENTIAL, INVALID_CREDENTIAL, NO_ADAPTER, and ABORTED do not enter this plugin’s retry flow. Context overflow is still handled by official compaction.
  • Out-of-process isolation: Out-of-process / ACP child agents are not covered by this plugin; only in-process child agents within the current process are subject to it.
  • No stream wrapping: It does not wrap ctx.llm.stream() and does not automatically send “continue”.
  • License: MIT.

This plugin is suitable for scenarios with high API stability requirements. It reduces session interruptions caused by transient network fluctuations by adding a fault-tolerance layer. See GitHub for more details.