Preface

In a DSH workflow, when a subagent terminates because of insufficient output tokens (max-tokens), the run sets stopReason to ‘max-tokens’ and stops. At this point, the parent agent must manually decide on and resume the subtask. dsh-subagent-watchdog targets this specific scenario and automatically performs one recovery through the official interfaces.

What It Is

This is a DSH plugin that automatically resumes native resumable subagents terminated by an explicit max-tokens stop. After performing one recovery, the plugin stops intervening; it includes no loops or timers.

  • Owner: quaner1234-cmd
  • Category: Workflow
  • License: MIT

Core Features

The plugin implements the following capabilities through official DSH interfaces:

  1. Automatic recovery: When a subagent is detected as terminated by max-tokens, it automatically performs one resumption.
  2. Deterministic judgment: It relies on persisted session IDs and logs for decisions, ensuring deterministic logic.
  3. Single-use guarantee: It guarantees that each subtask is resumed at most once, with no loops or timers.
  4. No external dependencies: No build step is required; it depends on Node >= 20.
  5. Interface usage: It is implemented through the official sessions.flush and subagents.followup interfaces.

Installation and Enablement

Install via the DSH plugin path:

dsh plugin --profile <profile> add dsh-subagent-watchdog

The package declares dsh.bundle.patch, and dsh plugin add automatically integrates it into the configuration stack.

Typical Usage

  1. Trigger recovery: When a subagent terminates due to insufficient output tokens (max-tokens), the plugin detects it automatically.
  2. Perform resumption: The plugin performs one resumption through the official interfaces, and the resumed run completes normally.
  3. Stop intervening: After the resumption completes, the plugin stops intervening.
  4. Manual handling: If it fails again, the plugin notifies the parent agent and provides manual options (such as send_message, interrupt_agent, etc.).

Applicable Scenarios and Notes

  • Compatibility: Only @deepseek-ai/dsh 0.1.1-rc.2 is supported; no other compatibility is declared or tested.
  • Dependency mechanism: Relies on the dsh.bundle.patch mechanism.
  • Runtime permissions: The plugin runs with the permissions of the current dsh process.
  • Risk notice: The source code and license should be reviewed before installation.

Summary

By using a single-recovery mechanism, this plugin reduces the manual intervention cost when native resumable subagents terminate with max-tokens.

Catalog Page
GitHub Repository