Introduction¶
When building agents with DSH, a single Agent loop can cover most linear tasks. But once tasks multiply—first research, then review, and finally summarization—you need to handle task dependencies, parallel scheduling, and failure recovery yourself. This logic scattered in multiple places is hard to test and difficult to reuse.
The following introduces Li3NGa’s DHS-multi-agent-plugin, which turns this orchestration infrastructure into a standalone plugin.
What This Is¶
DHS-multi-agent-plugin is a DeepSeek Harness plugin. Its one-line positioning in the README is “turns DeepSeek Harness into a powerful multi-agent orchestration engine.” The repository is maintained by Li3NGa, uses the MIT license, the npm package name is dhs-multi-agent, and the current version is 0.2.0.
It solves the problem of letting multiple agents collaborate according to declared dependencies, automatically parallelizing independent tasks, recovering within a budget on failure, and maintaining observability throughout.
The repository provides two runtimes: a TypeScript Native runtime (production source code in packages/dsh-multi-agent) and a Python runtime (src/deepseek_multi_agent_plugin, with CLI/HTTP/MCP adapters). The docs/ directory includes documentation for usage, API reference, strategy explanations, deployment, HTTP API, MCP integration, and more.
Core Features¶
Planning and Routing¶
- Planner: generates a structured task graph from natural-language intent;
- Validator: strict plan validation that rejects unsafe or malformed plans;
- AgentRouter: capability-based agent routing, supporting explicit assignment and automatic matching.
Based on the architecture diagram in the README, the execution chain is Planner → Validator → Router, then branches to Supervisor (strategy-based collaboration) or direct DAG scheduling, and finally AgentRunner invokes the actual DSH, with Recovery and Diagnostics modules running throughout.
DAG Parallel Scheduling¶
The scheduler executes tasks as a directed acyclic graph: independent tasks are automatically concurrent, dependencies are preserved, parallelism is maximized under dependency constraints, and arbitrarily complex task dependency topologies are supported.
Bounded Fault-Tolerant Recovery¶
The recovery mechanism is “bounded”; each of the four approaches has limits:
- Retry: failures caused by timeouts are automatically retried within budget;
- Repair: unavailable agents are automatically removed from the routing pool;
- Replan: dependency failures trigger deterministic replanning;
- Abort: cancellation operations never trigger recovery.
Runtime Observability¶
RuntimeDiagnostics: runtime diagnostic metrics;RunRegistry: run registration and state tracking;- Metrics collection + Observer pattern;
- Diagnostics are completed in memory and require no database.
Security¶
- RBAC role-hierarchy access control;
- HMAC timing-safe token authentication;
- CSRF protection and input validation;
- automatic redaction of sensitive information.
Collaboration Strategies¶
Four built-in collaboration strategies are directly callable:
- Sequential: execute in serial order;
- Broadcast: execute in parallel via broadcast;
- Relay: relay-style handoff;
- DAG: execute an arbitrary dependency graph directly.
Installation and Enablement¶
Install the package first:
npm install dhs-multi-agent
Requirements: Node.js >=22.14.0, and the host environment must provide a DeepSeek Harness / Cordis runtime. The plugin dependencies include @deepseek-ai/cordis ^4.0.1, as well as @deepseek-ai/dsh-agent, @deepseek-ai/dsh-llm, and @deepseek-ai/dsh-session (all 0.1.1-rc.2).
Then register the plugin in the host:
import { apply } from 'dhs-multi-agent'
apply(ctx, {
concurrency: 4,
defaultTimeoutMs: 60_000,
})
apply is the plugin entry point; in this configuration, concurrency is set to 4 and the default task timeout is 60 seconds. After registration, you can call the orchestration interface via ctx.multiAgent.
Typical Usage¶
Run a DAG Task¶
Pass an array of tasks to runDag and declare dependencies with dependsOn:
const result = await ctx.multiAgent.runDag([
{
id: 'research',
agentId: 'researcher',
prompt: '收集相关事实。',
},
{
id: 'review',
agentId: 'critic',
prompt: '审查研究结果。',
dependsOn: ['research'],
},
])
In this code, review depends on research, so it executes in dependency order; if you add another task with no dependencies, it will run concurrently with research.
Orchestration with Recovery¶
When fault tolerance is needed, use runWithRecovery instead, explicitly passing the agent capability table and recovery budget:
const result = await ctx.multiAgent.runWithRecovery(plan, {
runId: 'run-1',
input: '用户意图',
agents: [
{ id: 'researcher', capabilities: ['research'] },
{ id: 'writer', capabilities: ['writing'] },
],
recovery: { maxAttempts: 3, maxReplans: 2 },
})
maxAttempts: 3 sets the retry limit, and maxReplans: 2 sets the replanning limit.
Python Example¶
The examples/ directory in the repository provides directly executable scripts:
# 演示协作策略(无需 API Key)
python examples/demo_strategies.py
# 真实 DeepSeek 三人辩论
DEEPSEEK_API_KEY=sk-xxx python examples/demo_deepseek_team.py
# 启动 HTTP 服务
python examples/run_http_server.py
demo_strategies.py does not require an API key and can first validate the strategy logic; demo_deepseek_team.py demonstrates a real three-agent DeepSeek debate; if you want to call it over HTTP, use run_http_server.py to start the service—the API documentation is in docs/http_api.md.
Public API¶
Besides apply, the package also exports the core runtime (AgentRunner, Scheduler, Task, TaskGraph), four strategy functions (runSequential, runBroadcast, runRelay, runDag), Supervisor (Supervisor, createSupervisor), recovery (createRecoveryManager), and diagnostics (RuntimeDiagnostics, RunRegistry, createRuntimeDiagnostics). When finer control is needed, you can bypass the high-level wrappers and compose these modules directly.
Suitable Scenarios and Caveats¶
Suitable scenarios:
- Tasks have dependencies and require DAG scheduling rather than simple serial execution;
- Multiple agents collaborate by role (research, writing, review, etc.);
- Long-running processes need failure recovery and runtime metrics.
Caveats:
- The plugin runs with the permissions of the current dsh process; inspect the source code and license before installation. The repository uses the MIT license, the source code is public on GitHub, and you can review it yourself;
- The host environment must provide a DeepSeek Harness / Cordis runtime, and Node.js must be version 22.14.0 or higher;
- The current version is 0.2.0; refer to the repository
docs/directory for authoritative configuration options and interfaces.
For testing, the repository contains 164+ TypeScript unit tests and 386+ Python test cases, covering integration, smoke, and security tests. You can run them locally with pnpm --dir packages/dsh-multi-agent test and pytest tests/ -q.
Conclusion¶
In recap: DHS-multi-agent-plugin packages planning, routing, DAG scheduling, bounded recovery, and runtime diagnostics into a DSH plugin, so you don’t need to assemble the multi-agent orchestration infrastructure yourself. Following the steps above, you can run everything from a minimal runDag example to full orchestration with recovery.
- Community directory page: https://www.skillhub.cn/plugins/Li3NGa/DHS-multi-agent-plugin
- GitHub repository: https://github.com/Li3NGa/DHS-multi-agent-plugin