dsh-plugin-durable-subagent: Subagent Delegation Does Not Re-run After Crash

Preface

When delegating tasks to subagents in DeepSeek Harness (DSH), the Harness persists the “execution intent” but does not guarantee that tools with side effects will execute exactly once. If the process crashes between the “decision to commit” and “writing results back to the session,” and the same delegation is executed again during retry, problems such as duplicate task execution, repeated disk writes, or redundant external API calls may occur.

The community plugin dsh-plugin-durable-subagent (maintained by Tim-ReJet, categorized under Workflows) registers a durable subagent provider on the Harness side and exposes a model-facing durable_subagent tool. Together, they drive pi-durable-subagents. The core guarantee is: For delegations already accepted by the Harness before a crash, the system reads back the first result upon recovery rather than running it again.

What is this?

In short: It connects DSH’s persisted execution intent with pi-durable-subagents’ per-id single-decision logic, allowing subagent delegations to converge to the first result in crash and retry scenarios.

DSH’s session checkpoint policy explicitly states: the policy persists execution intent, not generic exactly-once semantics; tools with side effects should forward exec.callId as an idempotency key when supported by the provider. pi-durable-subagents accepts this key via --request <id>: under the same id, the first submission is decided once, and subsequent retries with the same content return that first result. This plugin is responsible for passing the Harness-side durable intent and key to the durable orchestrator, forming a “read-before-write” state machine: every attempt first runs describe --key <id>, and only executes run if the id has not yet been decided; if the process exits between deciding and reporting, the next attempt will read the persisted decision instead of executing again.

Core Features

Provider and Tool

  • Registers a provider named durable on ctx.subagents (default config provider: durable).
  • Optionally registers a model-facing tool (default enableTool: true, tool name durable_subagent).
  • Both interact with the orchestrator via the configured CLI (default pi-durable-subagents).

How a call becomes a durable request

  1. Harness persists the intent for the call, then executes the tool body with exec.callId.
  2. The tool derives the request id from the call session id and exec.callId; replays of the same call will derive the same id.
  3. The plugin reads the durable state for that id: only absent and pending proceed to run; running and asking are returned as is; sealed, rejected, and pruned are terminal states.
  4. run --request <id> --spec - --cwd <cwd> --json either decides the request and returns the first result, or reports “not decided” (exit code 75). In the latter case, the next attempt reads the state again before submitting.

The Provider path goes through ctx.subagents; the request body ResolvedSubagentStartRequest does not carry call identity, so the id is generated by configuration: unique generates a new id for every start (non-conflicting but not replay-stable); content is replay-stable for identical delegation content, but two identical delegations in the same session will result in a request-conflict. Only choose content when delegation content is distinguishable.

Model-side Tool durable_subagent

Parameters include action (run, status, answer, steer, notify, stop), as well as task, agent, to, message, qid, rev required by each action.

  • run: Returns as soon as the delegation is “decided,” rather than waiting for the subagent to finish all work; returns sealed, running, pending, or asking along with the request address.
  • status: Reads the address again; asking state includes the question id and revision needed for answer.
  • The plugin does not poll long tasks on behalf of the model; long delegations do not consume parent session tokens during runtime.

The reply for run is usually a single short text line; reading a completed delegation returns its output, while reading a running delegation returns the state name. The subagent’s full transcript does not enter the parent session history; tool calls are appended after a reusable history prefix and do not rewrite earlier messages.

Installation and Activation

Prerequisites: pi-durable-subagents must be in the PATH (or an executable path configured via command). If not installed, every start will fail immediately with a prompt rather than blindly retrying.

The plugin is not yet published to npm and must be installed from GitHub; lib/ is committed to the repository, and pnpm blocks build scripts for git packages. Therefore, do not rely on the prepare script during installation. If you modify TypeScript locally, you must manually run npm run build to refresh lib/.

npm i -g pi-durable-subagents
dsh plugin --profile web add github:Tim-ReJet/dsh-plugin-durable-subagent

Once published, a shorter form will be available (README notes that the bundle patch inserts a durable-subagent line):

dsh plugin --profile web add dsh-plugin-durable-subagent

package.json requires Node >=22.19, license is MIT, current version 0.1.0.

Configuration Essentials

Field Default Meaning
provider durable Registration name on ctx.subagents
command pi-durable-subagents Executable file (argv[0] only)
commandArgs [] Arguments preceding the subcommand
home — DSA_HOME set for each call
agent worker Default pi agent definition
cwd Harness process working directory cwd for each call; participates in CLI content hash
idempotency unique Provider minting request id: unique or content
attempts 3 Number of submission attempts before start fails
settleTimeoutMs 600000 Duration to wait for durable ruling on run handle
pollIntervalMs 1000 Polling interval while waiting
timeoutMs 120000 Deadline for a single CLI call
enableTool true Whether to register the model tool
tool durable_subagent Model tool name

Typical Usage (Model Tool)

The model-facing call form is driven by the action of durable_subagent, for example:

  1. action: run with task (and optional agent) to initiate delegation; decide the next step based on the returned request and status.
  2. If status is running or pending, use action: status with the request address to read again, rather than assuming the subagent has finished.
  3. If status is asking, use the returned qid and rev to call action: answer; use actions like steer, notify, stop when intervention is needed (see README for parameter descriptions).

The README does not provide complete JSON tool call examples; actual fields should conform to the tool schema exposed by Harness and the action list above.

Scenarios and Notes

Who it is for: Developers who need to delegate subtasks to pi-family subagents within DSH workflows and are concerned about the same delegation being executed twice due to Harness crashes or checkpoint replays; categorized as Workflow, suitable for integration with DSH’s “everything is a plugin” orchestration approach.

Runtime and Permissions: The plugin loads with the current DSH profile and calls pi-durable-subagents and subagents with the user and permissions of that process. Before installation, review the source code and MIT license on the GitHub repository and ensure the local orchestrator and agent definitions are trusted.

Known Limitations (Excerpts from README):

  • When installed via dsh plugin add link, the plugin resolves @deepseek-ai/* from its own directory, requiring a complete dependency closure locally; using npm install --legacy-peer-deps may cause profile startup failure (missing @deepseek-ai/dsh-scope, etc.). Formal npm release installation does not have this issue.
  • cwd participates in the submission summary; retrying from a different working directory will result in request-conflict rather than returning the first result.
  • The Provider path cannot be replay-stable based on call identity like the tool path; exact-once requires Harness to provide a durable run identity in the request.
  • Does not support continuable sub-sessions or Agent Teams membership; no extensions for tool filtering, persona, or delegation depth; the plugin does not manage the orchestrator’s process lifecycle.
  • The Workflow layer may show status: "done" overall while internal calls fail; details must be checked in the output/error of each call.

The community plugin directory SkillHub Entry has no official affiliation with DeepSeek or High-Flyer and is for community indexing only.

Conclusion

dsh-plugin-durable-subagent connects DSH’s durable execution intent and exec.callId idempotency keys to pi-durable-subagents, allowing subagent delegations after a crash to read back the first result instead of repeating execution. To install, first install the orchestrator globally, then enable it using the dsh plugin --profile web add command from the README; for long tasks, follow up as needed using actions like status/answer.

  • Directory Page: https://www.skillhub.cn/plugins/Tim-ReJet/dsh-plugin-durable-subagent
  • GitHub: https://github.com/Tim-ReJet/dsh-plugin-durable-subagent
羽毛球分组比赛记分
小程序二维码

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

Xiaoye