Zum Hauptinhalt springen
A

dsh-subagent-dispatcher

ayowait/dsh-subagent-dispatcher

Registers a `dispatch_task` tool that hands scoped or routine work to an isolated subagent, waits for it to finish, then checks the expected files and runs an optional verification command before returning a short report to the main conversation.

Installation

dsh plugin --profile web add github:ayowait/dsh-subagent-dispatcher

README

dsh-subagent-dispatcher

License: MIT DSH-Plugin Version

🚀 DeepSeek Harness (DSH) plugin for smart subagent task delegation and automated acceptance verification. Offload low-complexity, scoped, or repetitive tasks to lightweight subagents to prevent context bloating and save 70% ~ 90% tokens and reasoning costs!

English | 中文说明


📌 Table of Contents


💡 Why You Need This Plugin

In DeepSeek Harness (DSH), the primary conversation typically employs a high-intelligence, high-reasoning model (such as DeepSeek-R1, DeepSeek-Reasoner, gpt-5, or max/high reasoning effort).

When handling routine, scoped, or low-complexity tasks (such as writing unit tests, fixing typos, formatting data, or running build commands):

  • 🔴 Context Window Explosion: Direct exploration, voluminous grep/file dumps, and command outputs quickly inflate the main session to 30k ~ 100k+ tokens.
  • 🔴 Wasted Reasoning Tokens: High reasoning effort models waste thousands of chain-of-thought (CoT) tokens even on straightforward changes.
  • 🔴 Compounded Ongoing Costs: Once the primary context expands, every subsequent user turn incurs high prompt cache/input token fees and slower response latency.

🌟 Solution

dsh-subagent-dispatcher establishes a clean delegation & acceptance loop:

  1. Task Dispatching: Main Agent delegates routine subtasks to a Worker subagent via dispatch_task.
  2. Context Isolation: The Worker runs within a completely isolated temporary session sandbox. Raw exploratory traces and bash logs never leak into the parent conversation.
  3. Reasoning Effort Downgrade: Subagent runs with low reasoning effort (low or off), or utilizes a fast and cost-effective model (such as deepseek-chat / V3, gpt-4.1-mini).
  4. Automated Acceptance & Verification: Upon confirming subagent completion via waitForChildren, the plugin automatically inspects file presence, runs deterministic verification commands (e.g. npm test), and validates acceptance criteria.
  5. Condensed Delivery: Only structured, high-signal results return to the primary agent.

🔄 How It Works

flowchart TD
    A[Main Agent Receives Request] --> B{Evaluate Task Complexity}
    B -- Routine / Scoped / Test / Format --> C["Call dispatch_task tool"]
    B -- Core Architecture / Strategic Planning --> D[Main Agent Solves Directly]

    C --> E["Spawn Lightweight Worker Subagent<br/>· Isolated Session Sandbox<br/>· Low Reasoning Effort (low / off)"]
    E --> F[Worker executes edits & actions in workspace]
    F --> W["Await Worker Completion (waitForChildren)"]
    W --> G["Automated Acceptance Phase"]

    G --> H1{"Expected files exist & non-empty?"}
    H1 -- No --> O["⚠️ Acceptance Unmet (Flag Missing)"]
    H1 -- Yes --> H2{"Verification command passes?<br/>(e.g., npm test, python test.py)"}
    H2 -- Fail --> O
    H2 -- Pass --> H3{"Acceptance criteria satisfied?"}
    H3 -- No --> O
    H3 -- Yes --> L["✅ Acceptance Passed (Accepted)"]

    O --> P[Report to Main Agent for Review]
    L --> P["Deliver condensed report to Main Agent<br/>(A few hundred tokens vs tens of thousands!)"]

🚀 Quick Start & Installation

Install from the plugin catalog / npm: dsh plugin add dsh-subagent-dispatcher Install directly from GitHub: dsh plugin add github:Ayowait/dsh-subagent-dispatcher

Open a PowerShell terminal in this plugin directory:

powershell -ExecutionPolicy Bypass -File .\install.ps1

Automated Operations:

  1. Injects dsh-subagent-dispatcher as a link: dependency and bundle into ~/.dsh/profiles/desktop/package.json.
  2. Appends configuration into cordis.patch.yml.
  3. Creates automated timestamped backups (.bak).

Restart DeepSeek Harness and it is ready to use!


Option 2: Manual Installation

  1. Open your DSH Desktop profile's package.json (typically ~/.dsh/profiles/desktop/package.json):
    {
      "dependencies": {
        "dsh-subagent-dispatcher": "link:/absolute/path/to/dsh-subagent-dispatcher"
      },
      "dsh": {
        "profile": {
          "bundles": [
            "dsh-subagent-dispatcher"
          ]
        }
      }
    }
    
  2. Append into the profile's cordis.patch.yml (~/.dsh/profiles/desktop/cordis.patch.yml):
    - id: dsh-subagent-dispatcher
      name: dsh-subagent-dispatcher
      config:
        toolName: dispatch_task
        defaultReasoningEffort: low
        maxRounds: 3
        autoVerifyFiles: true
    
  3. Restart DeepSeek Harness.

⚙️ Configuration

Customizable options in cordis.patch.yml:

FieldDefaultDescription
toolNamedispatch_taskThe name of the delegation tool exposed to the model
defaultReasoningEffortlowDefault reasoning effort for subagents (off, minimal, low, medium)
defaultModel""Optional model ID for subagents (defaults to route inheritance)
defaultProvider""Optional provider route
maxRounds3Maximum automatic correction rounds within the sandbox
autoVerifyFilestrueWhether to automatically verify expected file presence and size
verificationTimeoutMs30000Timeout for automated verification commands (ms)

🛠️ Tool Parameters (dispatch_task)

ParameterTypeRequiredDescription
taskstringYesDetailed description of the delegated task and objective.
acceptance_criteriastringNoAcceptance criteria checklist (e.g., "Must handle null inputs; all unit tests pass").
verification_commandstringNoAutomated test/verification command (e.g. npm test, node test.js). Exit code 0 indicates success.
expected_filesarrayNoList of relative file paths expected to be created or modified (e.g. ["src/util.js"]).
modelstringNoOptional lightweight model for the worker (e.g. deepseek-chat, gpt-4.1-mini).
reasoning_effortstringNoReasoning effort level (default low, can be off).
max_retriesnumberNoMaximum retry rounds if acceptance fails (defaults to the maxRounds config, i.e. 3).

💻 Use Cases & Examples

Example: Writing Unit Tests with Verification

{
  "tool": "dispatch_task",
  "arguments": {
    "task": "Write comprehensive unit tests for parseJwtToken in src/auth.js covering valid token, expired token, forged signature, and invalid syntax.",
    "expected_files": [
      "tests/auth.test.js"
    ],
    "verification_command": "npm test -- tests/auth.test.js",
    "acceptance_criteria": "1. Covers all 4 edge cases; 2. Verification command exits with code 0.",
    "reasoning_effort": "low"
  }
}

Condensed report received by the Main Agent:

### ✅ Subagent Task Delivery Report
- **Status**: **Accepted**
- **Rounds**: 1 round
- **Deliverables**: Implemented comprehensive unit tests in `tests/auth.test.js`.
- **Files Modified**: `tests/auth.test.js`
- **Verification**: `npm test -- tests/auth.test.js` passed (Exit code 0).
- **Token Savings**: 💡 Prevented ~12,000+ context and reasoning tokens from flooding the main session.

📊 Token Savings Comparison

MetricTraditional (Main Agent in Parent Turn)This Plugin (Subagent Dispatch + Acceptance)Gain
Parent Context Bloating20,000 ~ 60,000+ tokens from raw tools & logs0 bloating, receives only concise summary95%+ Context Saved
Reasoning Tokens (CoT)Thousands of expensive reasoning tokens per stepForced low or off reasoning effort80%+ Reasoning Cost Saved
Subsequent Turn CostEscalating input token fees per turnMain session stays lean, responsive, and cheapSignificantly Lower Latency
Deliverable ReliabilityRisk of unverified code with runtime errorsDeterministic command acceptance (npm test)Higher Quality & Confidence

🗑️ Uninstallation

To restore the original profile state, simply run:

powershell -ExecutionPolicy Bypass -File .\install.ps1 -Uninstall

The script will restore previous configuration backups cleanly.

Ähnliche Plugins