← Back to home@Li3NGa

DHS-multi-agent-plugin

agent工厂 让多个agent协同 deepseek harness插件

Stars
2
Language
Python
Created
Aug 15, 2026
Updated
Sep 4, 2026
GitHub repo

Introduction

DHS Multi-Agent

DHS Multi-Agent Orchestration

CI Native Runtime npm License: MIT TypeScript Python DeepSeek

将 DeepSeek Harness 变成强大的多智能体编排引擎

快速开始 · 核心特性 · 架构概览 · 文档 · 示例


✨ 核心特性

🧠 智能规划与路由

  • Planner — 从自然语言意图生成结构化任务图
  • Validator — 严格的计划验证,拒绝不安全或格式错误的计划
  • AgentRouter — 基于能力的智能体路由,支持显式分配和自动匹配

⚡ DAG 并行调度

  • 真正的有向无环图执行,独立任务自动并发
  • 保留依赖关系的同时最大化并行度
  • 支持任意复杂的任务依赖拓扑

🛡️ 有界容错恢复

  • Retry — 超时失败在预算内自动重试
  • Repair — 不可用智能体自动从路由池中移除
  • Replan — 依赖失败触发确定性重规划
  • Abort — 取消操作永不触发恢复

📊 运行时可观测性

  • RuntimeDiagnostics — 运行时诊断指标
  • RunRegistry — 运行注册与状态追踪
  • Metrics 收集 + Observer 模式
  • 无需数据库的内存内诊断

🔒 企业级安全

  • RBAC 角色层次访问控制
  • HMAC 时序安全令牌认证
  • CSRF 防护与输入验证
  • 敏感信息自动脱敏

🎯 多种协作策略

  • Sequential — 顺序串行执行
  • Broadcast — 广播并行执行
  • Relay — 接力式传递
  • DAG — 任意依赖图直接执行

🏗️ 架构概览

用户意图 / 任务计划
        │
        ▼
     Planner  ◄─────────────────────────┐
        │                               │
        ▼                               │
    Validator                          │
        │                               │
        ▼                               │
      Router                           │
        │                               │
        ├─────────────┐                 │
        │             │                 │
        ▼             ▼                 │
   Supervisor    Direct DAG             │
        │             │                 │
        ▼             ▼                 │
    Strategy     Scheduler              │
        │             │                 │
        └──────┬──────┘                 │
               │                        │
               ▼                        │
          AgentRunner                   │
               │                        │
               ▼                        │
           Real DSH                     │
               │                        │
               ▼                        │
      Recovery / Diagnostics ───────────┘

🚀 快速开始

安装

npm install dhs-multi-agent

需要 Node.js >=22.14.0 和提供 DeepSeek Harness / Cordis 运行时的宿主环境。

最小示例

import { apply } from 'dhs-multi-agent'

// 注册插件
apply(ctx, {
  concurrency: 4,
  defaultTimeoutMs: 60_000,
})

// 运行 DAG 任务
const result = await ctx.multiAgent.runDag([
  {
    id: 'research',
    agentId: 'researcher',
    prompt: '收集相关事实。',
  },
  {
    id: 'review',
    agentId: 'critic',
    prompt: '审查研究结果。',
    dependsOn: ['research'],
  },
])

带恢复的编排

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 },
})

📦 公共 API

import {
  // 核心运行时
  AgentRunner,
  Scheduler,
  Task,
  TaskGraph,
  // 策略
  runSequential,
  runBroadcast,
  runRelay,
  runDag,
  // Supervisor
  Supervisor,
  createSupervisor,
  // 恢复
  createRecoveryManager,
  // 诊断
  RuntimeDiagnostics,
  RunRegistry,
  createRuntimeDiagnostics,
  // 插件入口
  apply,
} from 'dhs-multi-agent'

📚 文档

文档说明
使用指南详细使用说明和配置选项
API 参考完整的 API 文档
运行时 APINative 运行时 API
策略说明各协作策略的详细介绍
Supervisor 契约Supervisor 接口规范
部署指南生产环境部署
HTTP APIPython HTTP 服务接口
MCP 集成MCP 协议支持
架构决策记录重要设计决策的记录
真相来源代码库结构说明

💡 示例

Python 示例

# 演示全部 5 种协作策略(无需 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

更多示例请查看 examples/ 目录。


🧪 测试

# TypeScript 单元测试
pnpm --dir packages/dsh-multi-agent test

# 类型检查
pnpm --dir packages/dsh-multi-agent typecheck

# 构建
pnpm --dir packages/dsh-multi-agent build

# Smoke 测试
pnpm test:smoke

# Python 测试
pytest tests/ -q

测试覆盖:

  • TypeScript:164+ 单元测试
  • Python:386+ 测试用例
  • 包含集成测试、Smoke 测试、安全测试

🏛️ 仓库结构

DHS-multi-agent-plugin/
├── packages/dsh-multi-agent/    # Native 生产源代码(TypeScript)
│   ├── src/                      #   运行时核心
│   │   ├── planner/              #   规划器
│   │   ├── supervisor/           #   Supervisor
│   │   ├── recovery/             #   恢复机制
│   │   ├── strategies/           #   协作策略
│   │   └── ...
│   └── tests/                    #   测试套件
├── src/deepseek_multi_agent_plugin/  # Python 运行时
│   ├── runtime/                  #   核心运行时
│   ├── adapters/                 #   CLI/HTTP/MCP 适配器
│   └── ...
├── docs/                         # 文档
│   ├── adr/                      #   架构决策记录
│   └── ...
├── scripts/                      # 发布和验证脚本
├── examples/                     # 示例代码
├── cordis.patch.yml              # DSH Bundle Patch
└── ...

🤝 贡献

欢迎贡献!请查看以下资源:


📄 许可证

MIT License


如果这个项目对你有帮助,欢迎给个 ⭐ Star

Made with ❤️ for the DeepSeek ecosystem