dsh-pilot: Using Contracts to Delegate Main and Sub-Agent Execution to Code for Arbitration

Introduction

In multi-step development within DeepSeek Harness (DSH), a common practice is for the main session to handle requirement understanding while dispatching sub-agents to modify code or run commands. Cheap models execute quickly and cost less, but are prone to hallucination; if models evaluate each other on “correctness,” costs and uncertainty increase. Nwflower’s dsh-pilot takes a different path: the main agent only drafts a contract, sub-agents execute according to the contract, and a plugin adjudicates using deterministic rules (acceptance command exit codes, git diffs against whitelists, receipt cross-verification). The main agent ultimately reads only a compact verdict JSON. The README summarizes the comparison in one sentence: agent-teams gives you a team, dsh-pilot gives you a contract.

What is this

  • Name: dsh-pilot (Repository Nwflower/dsh-pilot)
  • Maintainer: Nwflower
  • Category: Workflow (Community Directory: SkillHub Plugin Page)
  • License: MIT (Consistent in README and package.json)
  • Current Package Version: 0.2.0 (Per package.json)
  • Status (README): M1.6 completed, full pipeline available; see DESIGN.md in the repository for design details.

The plugin targets the DSH Host plugin form: Contract Dispatch → Whitelist Guard → Gate Execution → Verdict Return. The README claims 62/62 automated tests pass, and it has passed acceptance testing via real sub-agent dispatch sessions (PASS).

Core Mechanism

The following describes what the main agent, the plugin, and the sub-agent each do.

 Main Agent (Flagship Model)             dsh-pilot Plugin (Host, Pure Code Adjudication)
 ─────────────────                      ──────────────────────────────
 Understand needs · Grasp project status  ① Assemble sub-agent prompt = Contract + Inline context
 Draft contract · No hands-on coding ──Contract──▶ ② subagents.start(outputSchema, toolFilter)
                                      ③ File whitelist guard (tools.guard)
        ▲                             ④ Gate: shell runs acceptance_cmd → Real exit code
        └────── verdict ◀──────────   ⑤ Verification: git diff vs whitelist & receipt authenticity
        (Compact JSON, <200 tokens)       ⑥ Failure: Deterministic feedback retry (≤max_retries)

Key points of “Hallucination Defense” emphasized in the README include:

  1. The contract schema deliberately has no code field; the main agent physically cannot inject code via the contract.
  2. The gate exit code is obtained by the plugin personally executing the acceptance command; it does not trust self-reported receipts.
  3. Cross-verification of the git status snapshot difference before and after the task against the receipt’s files_changed; false reporting results in FAIL, and the real diff is fed back for retry.
  4. Whitelist Guard: Writes by the sub-agent to paths outside allowed_files are rejected (tools.guard, synchronous, fail-open behavior as described in README).
  5. Failed retries are fed only deterministic content (e.g., stderr tail, out-of-bounds list); if exhausted, the verdict becomes ESCALATED, handing over to the human.

verdict values: PASS, FAIL, BLOCKED, ESCALATED. The README explains that non-PASS results will include workspace_delta and other site information to facilitate acceptance or rollback before dispatching a new contract.

Contract and Verdict Examples

The main agent submits the contract via the tool pilot_dispatch (schema strictly validated). Typical input parameters are as follows:

{
  "goal": "One-sentence goal",
  "detail": "Requirement details, interface signature conventions, boundary conditions",
  "context": [
    { "path": "src/auth.ts", "note": "TokenService is here; signing signature sign(uid: string): string" }
  ],
  "allowed_files": ["src/auth.ts", "tests/auth.test.ts"],
  "acceptance_cmd": "pnpm vitest run tests/auth.test.ts",
  "tier": "standard",
  "max_retries": 2
}

Example verdict returned by the plugin to the main agent (The main agent only looks at this):

{
  "verdict": "PASS",
  "files_changed": ["src/auth.ts", "tests/auth.test.ts"],
  "gate": { "cmd": "pnpm vitest run tests/auth.test.ts", "exit_code": 0 },
  "attempts": 1,
  "child": { "model": "deepseek-v4.1-flash", "tokens": 12345 }
}

Installation and Activation

The README states: Not yet published to npm. During development, it can be mounted locally; the second command can be used after release.

dsh plugin --profile web add -w link:D:\Build\dsh-pilot   # Local development
dsh plugin --profile web add dsh-pilot                    # After npm release

The local development example path comes from the README (Windows path); Linux / macOS users need to point link: to their local clone or the downloaded plugin directory, while the command form remains subject to the README.

In the cordis.patch.yml composition line, the following configuration can be inserted (Field names consistent with README):

- insert:
    - id: dsh-pilot
      name: dsh-pilot
      config:
        provider: spawn              # Sub-agent provider (subagents.list() available)
        model: deepseek-v4.1-flash   # Pin sub-agent model
        exposure: pointer            # pointer=one-line persona pointer; silent=zero context footprint
        guard: true
        maxRetries: 2
        gateTimeoutMs: 300000
        feedbackMaxChars: 2000

The README also mentions context discipline: P0 registers only the pilot_dispatch tool; the detailed manual is loaded on demand in the pilot-playbook skill; when exposure: silent, the persona section is not injected, and the skill is only invoked explicitly by the user. See DESIGN.md §2.3 in the repository for design details.

Runtime Environment: package.json requires Node >= 18.

Typical Usage Flow

  1. The main agent grasps the project status in the session and writes the goal, details, and relevant file descriptions into the contract’s goal, detail, and context.
  2. Use allowed_files to limit the sub-agent’s writable paths, and use acceptance_cmd to write repeatable acceptance commands (e.g., a single command for unit tests).
  3. Call pilot_dispatch; wait for the plugin to dispatch the sub-agent, run the guard and gate.
  4. Based on the returned verdict, decide whether to continue planning, modify the contract and re-dispatch, or intervene manually if ESCALATED.

The sub-agent model and provider are fixed by the plugin config (example is spawn + deepseek-v4.1-flash), consistent with the division of labor of “expensive model plans, cheap model executes.”

Applicable Scenarios and Notes

Who it is for

  • Already using sub-agents in DSH, hoping to change the judgment of “whether it is done, which files were changed, whether tests passed” from LLM self-evaluation to scriptable, reproducible adjudication.
  • Willing to use contracts to constrain scope: Whitelist files + Explicit acceptance commands + Limited retries.

Must Note

  • DSH plugins run under the current dsh process permissions; please read the source code and MIT license yourself before installation to ensure acceptance commands and whitelists meet your security expectations.
  • acceptance_cmd will be executed by the plugin in the workspace; you should use commands you trust and that are repeatable, avoiding destructive operations.
  • The community directory SkillHub and DeepSeek / High-Flyer (Hunyuan) have no official affiliation implied by the README; the DSH ecosystem philosophy is “everything is a plugin,” and the facts in this article come from the aforementioned repository README and package.json.

Other DSH plugins by the same author (README Ecosystem section): dsh-chat-import, dsh-file-claim, dsh-perf-lens, dsh-claude-style. They can be used in combination with this plugin; specific capabilities are subject to the documentation of each repository.

Conclusion

dsh-pilot condenses multi-agent collaboration into “Contract + Code Adjudication”: the main agent reads fewer long logs, and sub-agent boundary crossings and false reporting are intercepted by the plugin. For further details on contract/receipt/verdict specifications and ecosystem comparison, please read the repository DESIGN.md.

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

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

Xiaoye