DeepSeek Harness Session Recovery Plugin: Automatically Recovering Failed and Truncated Conversations

Introduction

When running agents using the DSH Web profile, models encountering transient errors or truncated outputs typically require manual intervention. jayyuen666/dsh-session-rescue aims to reduce this manual operation through automatic recovery logic and a client interaction interface.

Plugin Positioning

Maintained by JayYuen666, this plugin is positioned as a DSH Web session rescue tool. It handles model failures, truncation, and unfinished todo lists by automatically injecting messages and providing a client-side UI.

Core Features

  • Three Recovery Modes: Automatic rescue for transient failures, max-tokens truncation, and unfinished todo lists.
  • Request-level 429 Fallback: Takes over 429 requests when the host has no retryPolicy configured.
  • Client Interaction UI: Provides functions for edit & resend, fork & resend, stop & re-ask, manual retry, and continue output.
  • Self-scheduling Polling: Polls status at 1s (when pending) or 5s (fallback) intervals.
  • Settings & Validation: Includes a settings card, 429 retry presets, and version compatibility checks against @deepseek-ai/dsh-plugin-shared.

Installation & Dependencies

Ensure DeepSeek Harness (DSH) version ^0.2.1-rc.2 is installed before proceeding.

dsh plugin --profile web add @jayyuen66/dsh-session-rescue

Automatic Recovery Mechanism

The plugin listens for specific Cordis events and automatically injects messages when conditions are met:

  1. resume: Listens for agent/error. When failure is determined to be transient (e.g., RATE_LIMIT, SERVER, TIMEOUT, TRANSPORT, EMPTY_RESPONSE, HTTP 429, 5xx, QUOTA, PI_AI_ERROR), it resumes after resumeDelayMs.
  2. continue: Listens for agent/status. When the status changes to idle and the reason.kind of the last turn/end is max-tokens, it continues the conversation after continueDelayMs.
  3. unfinished: Listens for turn/end and todo/write. When turn/end completes but todo/write still contains unfinished items, it rescues the unfinished todos after unfinishedDelayMs.

429 Request Fallback Strategy

The plugin only takes over 429 requests when the host does not have a retryPolicy configured.

  • Timeline: The default fallback strategy is 2s/5s/10s/20s/30s, with a maximum of 5 retries per session.
  • Limits: If the host returns Retry-After, that value is prioritized; if it exceeds 30s (requestRetryBackoffCapMs), it does not wait and delegates directly to the host.
  • Reset: The counter resets when agent/status changes to idle.

Client UI

The client UI floats below the input box and provides the following actions:

  • Edit & Resend: Edit the current session content and resend.
  • Fork & Resend: Create a new branch and resend.
  • Stop & Re-ask: Stop the current turn and re-ask the question.
  • Manual Control: Manually retry or continue output.
  • Status Display: Countdown banner and session toggle.

Limitations & Notes

  • Inapplicable Scenarios: Not applicable to sub-agents, aborted/interrupted turns, ask_user_question, or turns where the first user/message source is schedule.
  • Permanent Failures: Does not handle permanent errors such as AUTH, INVALID_CREDENTIAL, MISSING_CREDENTIAL, INVALID_REQUEST, NO_ADAPTER, or insufficient balance.
  • Version Dependency: If the profile pins @deepseek-ai/dsh-plugin-shared, the version must match; otherwise, the plugin may fail to load.

Summary

By automatically handling common network errors and truncation issues, along with providing rich client interaction capabilities, this plugin is suitable for scenarios requiring session continuity within the Web profile.

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

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

Xiaoye