Kanadego/dsh-heartbeat
Kanadego/dsh-heartbeat心跳循环:默认每 20 分钟自己醒一次——维护一份关于你兴趣与偏好的本地画像,按你设的兴趣范围上网搜新东西并存下来。攒到值得分享的内容,就向你绑定的会话送一份简短的素材包。能不能开口由代码里的规则决定(静默时段、忙时窗口、每日上限、冷却),说不说由那个会话里的 agent 自己判断。仅支持 Windows。
把任务派给一个模型、把评审交给另一个模型,并带有资格证据、故障转移与持久日志。
English · 简体中文
中文读者:完整中文文档见 README.zh.md,其中包括使用指南与安全与限制。本插件为 DeepSeek Harness (DSH)/Cordis 宿主提供路由选择、有界子 agent 委派、并行只读批处理与结构化评审记录;它依据本会话的实时资格证据工作,不会自动节省 token,也不保证裁定正确。
Route tasks, run scoped agents, collect parallel findings, and record structured reviews—with explicit limits and durable history.
Adding a second agent is easy. Knowing which agent did what, with which tool, under which policy, and when it must stop is the hard part. Multi-agent gives your DSH harness that coordination layer as fifteen native tools, with no dependencies to install. v1.14 also adds an opt-in governance gate: a six-stage, human-authorized path from plan to reviewed candidate.
This is a native plugin for a compatible DeepSeek Harness (DSH)/Cordis host, not a standalone framework or hosted service. It selects routes from fresh session-scoped smoke evidence, runs bounded work, and records prompts, results, model identity and failure states. A reviewer declares whether work passed; the plugin follows that declaration, not its own judgment of the answer.
Multi-agent does not automatically save tokens. In the 27-trial benchmark, parallel workers plus integration consumed 92.2% more tokens than one agent. They were 23.5% faster than the same workers run sequentially, but slower than one agent. Use delegation for useful separation of work—not an assumed token discount.
Rod Trent's *Multi-Agent Systems and Orchestration: The Hard Problem Is Coordination* argues that orchestration is architecture, not a prompt. It lists seven things a coordination layer must specify on purpose. This plugin's answer to each:
Requirement · How Multi-agent handles it Endpoints and contracts · Each call carries a typed task object, an explicit prompt and a tool allowlist. Refusals return a named reason, such as MISSING_EXACT_QUALIFICATION. Topology · A star: the parent supervises and children have delegation depth one. No peer mesh, so every decision can be traced back through the parent. Authority · Reviewers *declare* verdicts; the plugin records them and doesn't judge the work. In the governance gate, only a human can authorize a plan, and model output can't. State · Durable per-owner journals for assignments, batches, qualifications and direct tasks, readable without calling a model. Chat history isn't the system of record. Aggregation · Explicit, not hidden: batches return findings in request order, and you add an integration step yourself and count its cost. Termination · max_rounds, at most three review/revise cycles, per-call deadlines, 24-hour qualification expiry, and three author attempts in the governance gate. Failure policy · Uncertain work is never replayed automatically. Failover is opt-in and only for pre-dispatch refusals. needs-clarification and contradictory verdicts stop the loop and hand back to you.
The article's practical advice is also built in: keep workers narrow, prefer deterministic scaffolding (a fixed stage order in the gate), record every handoff, and keep a human at the points that need judgment.
Feature · What it does · Important limit Task-based routing · Uses role, risk, complexity, data class and requested capabilities to select a qualified route; reports selection grounds · Deterministic policy, not a quality predictor or cheapest-price optimizer Live qualification · Probes one exact provider/model/effort for text and native tool round-trip; optional image/structured-output probes and operator attestations · A bounded smoke test does not certify competence on your task Scoped delegation · Runs a native child with an explicit prompt and tool allowlist; records its model and output per round · Prompt scopes are not path-level sandbox enforcement Read-only parallel batches · Accepts 2–8 independent tasks, runs up to two workers, and collects bounded findings in request order · Caller supplies scopes; no automatic decomposition, dependency graph, synthesis or semantic verification Provider-diverse review · Prefers a reviewer from another provider and records whether that preference was satisfied, including after failover · Different provider does not prove independent reasoning or correctness Bounded review/revise loops · Follows structured verdicts for up to three cycles; stops on clarification, incoherence, unreadable output or the cap · VERIFIED is the reviewer's declaration, not an independent test result Durable records · Stores assignment, batch, qualification and direct-task state; supports read/list/delete without model dispatch · Plaintext local state; single-process coordination, not distributed locking Conservative continuation · Can continue clean token-limit stops for eligible read-only work; does not automatically repeat write-capable work · Continuation creates another child and spends more tokens; uncertain work is not replayed Opt-in distribution and failover · Deterministically rotates eligible routes; can try an alternate after a recognized pre-dispatch refusal for read-only work · Not live load balancing, provider quota scheduling or general error retry Separate accounting signals · Direct tasks expose available per-round usage and missing-usage counts; native assignments expose commitments, returned children and timing · Native child results do not expose cumulative token usage to this plugin
Batch workers share two native execution slots with ordinary delegations and compactions. Remaining batch work can wait in an internal FIFO queue of at most eight pending reservations. Ordinary delegate/compact calls refuse when busy; there is at most one active batch per owner.
Workers use only read, glob and grep, with one delegated round each. They return a short summary, at most five findings with evidence, and up to three uncertainties. A delegated round may contain several model/tool steps. Batch workers have no automatic continuation, failover or compaction. The batch does not include an integration call; add one explicitly if you need a combined answer and count its cost.
Slots stay occupied until child results and disposal settle, even after cancellation. Saved batch IDs cannot be replayed; unfinished recovered batches report INTERRUPTED_UNKNOWN. Full batch behavior and limits →
Native orchestrator_delegate and orchestrator_iterate calls may now run for up to 2,500,000 ms (about 42 minutes), up from 15 minutes, so longer reviews can finish. This is a ceiling, not a typical duration: a short delegation usually returns in seconds.
The governance gate is a separate, opt-in entry for work that needs a person to sign off at each step. It turns one configured job into a fixed six-stage sequence, and each stage must be requested by a human:
open → plan-review → human authorization → author → seal → validate → review/gov-status, /gov-open, /gov-stage, /gov-authorize and the other commands directly into the DSH Web GUI. The input box shows a hint with each command's arguments. Model output, copied text or a nested model call can't authorize anything./gov-pause returns a one-time checkpoint; /gov-resume author consumes it exactly once./gov-read pages status, history, evidence and artifacts at no more than 16 KiB per reply. It isn't a file reader./gov-accept, /gov-qualify and /gov-export in the disposable qualification host produce receipts. Every receipt carries qualificationOnly:true, operationallyAccepted:false and gateActive:false.A walkthrough typed by hand in the receiver session. Each line is sent as its own message, and the digests are shortened here. Copy the real values from the reply to the step before; each reply names the next allowed step.
You type · What happens · Key field in the reply /gov-status · Reads the job before anything starts · gateActive:false /gov-open · Opens the one configured project and plan · headAuthenticity:"live-verified" /gov-stage plan-review · An independent reviewer checks the plan · phase:"AWAITING_HUMAN", resultId /gov-authorize authorize · You approve this exact plan · the plan-review result becomes a human decision /gov-stage author · The author writes a candidate (uses 1 of 3 attempts) · phase:"AUTHORING" /gov-stage seal · The candidate's exact bytes are frozen · candidateDigest:"1422…" /gov-stage validate · Pinned trusted tests run against the sealed bytes · outcome:"completed-pass" /gov-stage review · A separate reviewer judges the candidate · phase:"DIAGNOSTIC_READY" /gov-accept · Records an offline acceptance, with no activation · acceptanceRecorded:true /gov-qualify · Rechecks everything and issues a receipt · qualificationReceiptDigest:"4cce…" /gov-export · Copies the candidate once to the fixed destination · deliveryPhase:"completed" /gov-export … (same line again) · The replay is refused · reason:"DELIVERY_NOT_AUTHORIZED" /gov-stop · Revokes admission and shuts the owner down · —
Accept and qualify each add an event, so read the current headDigest with /gov-status before the next step. Every step can refuse with a named reason, and nothing moves forward on its own. The export folder then contains exactly payload/, descriptor.json, qualification-receipt.json and complete.json. The repository you're working in is never modified.
Two common mistakes:
M4_HUMAN_RECEIVER.What it is not: it doesn't activate itself in your everyday harness, apply candidates to your checkout, or survive a cold restart. After process loss, a store is read-only and marked RECONCILIATION_REQUIRED. A walkthrough typed by hand in the stock Web GUI has been exercised in a disposable qualification host; that is qualification evidence, not operational acceptance.
Every change delegated to agents follows these six stages, in order. No stage may be skipped, and the author never approves its own work.
Stage · Required output 1. Assess · Establish the actual failure, affected paths, existing behavior, and evidence. Separate confirmed defects from unknowns. 2. Plan · Specify exactly what files and behavior must change, how the fix will work, what must remain unchanged, risks, tests, acceptance criteria, and recovery steps. 3. Review the plan · An independent reviewer checks correctness, scope, safety, and whether the proposed tests can establish the intended result. Resolve blocking findings before implementation. 4. Implement · Delegate only the reviewed changes within the named file scope. No opportunistic fixes or expanding the assignment. 5. Validate and review · An independent validator executes the required tests; a separate reviewer checks the exact resulting changes. The author cannot approve its own work. 6. Accept or stop · Accept only the exact verified candidate. Allow at most two correction cycles against the same acceptance criteria; otherwise stop implementation and reassess. Never weaken tests to obtain a pass.
The governance gate turns stages 2–6 into checked steps. Stage 1 stays with you: the gate starts from a plan and cannot tell whether your assessment was right.
Stage · What the gate checks · Refusal when it's broken 2. Plan · The plan must list the files to change with their expected hashes, the non-goals, the protected tests, the acceptance criteria and the exact test commands. Unknown or missing fields are rejected. · plan validation error 3. Review the plan · /gov-stage plan-review runs a reviewer who is not the planner and uses a different provider. Nothing is written until you approve with /gov-authorize. · INDEPENDENCE_REQUIRED 4. Implement · The author works only in a disposable copy, and the protected test files cannot be among the files it changes. Acceptance rechecks that nothing outside the plan changed, and export refuses any file outside the admitted set. · PROTECTED_PATH, DELIVERY_EXTRA_FILE 5. Validate and review · The candidate's bytes are sealed first. The validator runs the hash-pinned tests on those sealed bytes, and a separate reviewer judges them. Neither may be the planner or an author, the validator and the reviewer must be different agents, and the reviewer must use a different provider from the author. · INDEPENDENCE_REQUIRED 6. Accept or stop · /gov-accept and /gov-qualify bind to one candidate digest. The correction limit is fixed at 2 (3 author attempts in total); after that the job moves to REASSESS_REQUIRED. Test files are pinned by hash, so they can't be weakened. · INVALID_BUDGET, REASSESS_REQUIRED
Without the gate, these stages are still the rule for how you use the orchestrator tools: plan, then orchestrator_delegate with the review role for the plan, one scoped implementation delegate, then separate validation and review delegates.
Check these before you install. If one isn't met, the tools either won't appear or will refuse work.
For the orchestrator (all users):
enabled: true, then restart DSH. Never edit the shipped presets.For the governance gate (additionally):
danger-full-access, missing services or changed pins block stage admission.Not in the measured workloads below. Keeping file contents in child sessions can reduce the main conversation's context, but those children still consume tokens. Repeated instructions, separate contexts, reviews and integration can cost more than one agent doing the work.
The benchmark used three bounded repository-inspection workloads, three repetitions, and the same Codex gpt-5.6-luna model at medium effort for all approaches. Both multi-agent approaches include a final integration call.
Approach · Accepted · Mean tokens per trial · Tokens per accepted result¹ · Mean elapsed time Single agent · 6/9 · 17,729 · 26,594 · 18.0 s Sequential workers + integration · 9/9 · 34,404 · 34,404 · 38.2 s Parallel workers + integration · 8/9 · 34,076 · 38,335 · 29.2 s
¹ All tokens consumed, including failed answers, divided by accepted results. This is not an estimate of retry cost.
Recommendation: use one agent by default for small inspections. Choose parallel specialists when independent scopes or latency relative to sequential specialists justify the overhead. These measurements do not establish a general token-saving claim or predict larger tasks.
Methodology, totals and limitations · All 27 trial measurements (CSV)
With Node.js 22 or newer and Git installed:
git clone https://github.com/WDahah/portable-dsh-multi-agent-plugin
cd portable-dsh-multi-agent-plugin
node demo.mjsThe demo runs the project's real routing and verdict parsing logic with synthetic qualification evidence. It makes no provider calls and does not prove that any route is available or that an answer is correct. It demonstrates selection, refusals, expiry, provider-diversity preference and declared verdict handling.
You can run a single scene: node demo.mjs routing. Other scenes are refusal, expiry, diversity, verdicts, objective and aliases.
For live work you need:
dsh-tools/lib/index.js module.This package uses Node built-ins and has no package dependencies; `npm install` is not required here. That does not remove the host requirement. Integration was developed against dsh-tools 0.1.5-rc.2 and Cordis ^4.0.2, not every host version.
Two ways in. If your host installs plugins with dsh plugin, add this package and skip the rest of this section:
dsh plugin --profile <name> add git+https://github.com/WDahah/portable-dsh-multi-agent-plugin.gitThe package declares a dsh.bundle patch, so the profile mounts it by itself and the state directory defaults to $DSH_HOME/portable-multi-agent-state; a stateRoot in the profile patch overrides that. The copy-and-merge steps below remain the path for hosts that install plugins by hand, and for keeping this package outside the host's own tree.
orchestrator_* registrations.The core commands, from the package root:
node scripts/manifest.mjs --check
node scripts/setup.mjs --harness-root <absolute installed DSH directory> --state-root <absolute state directory>
node scripts/doctor.mjsThen copy the insert entry from .local/host-patch.yml into your profile's cordis.patch.yml, set enabled: true, and restart DSH.
Setup generates .local/entry.mjs and .local/host-patch.yml; it does not install DSH, activate the plugin or authenticate accounts. Doctor checks the local integration offline. The plugin defaults disabled until deliberately enabled in the host configuration.
The integrity manifest detects missing or changed listed files; it is not an authenticity signature and the verifier does not reject unlisted extras. A hash mismatch can mean a changed file, corruption or line-ending conversion. Investigate it; do not regenerate the manifest to conceal an unexpected mismatch or run a destructive reset on valuable local work.
After activation and qualification, invoke orchestrator_delegate wi