🏛️ 三省六部制 · OpenClaw Multi-Agent Orchestration System — 9 specialized AI agents with real-time dashboard, model config, and full audit trails
我用 1300 年前的帝国制度,重新设计了 AI 多 Agent 协作架构。
结果发现,古人比现代 AI 框架更懂分权制衡。
12 个 AI Agent(11 个业务角色 + 1 个兼容角色)组成三省六部:太子分拣、中书省规划、门下省审核封驳、尚书省派发、六部+吏部并行执行。
比 CrewAI 多一层制度性审核,比 AutoGen 多一个实时看板。
🎬 看 Demo · 🚀 30 秒体验 · 🏛️ 架构 · 📋 看板功能 · 📚 架构文档 · English · 日本語 · 参与贡献
🎥 三省六部 AI 多 Agent 协作全流程演示
飞书下旨 → 太子分拣 → 中书省规划 → 门下省审议 → 六部并行执行 → 奏折回报(30 秒)
🐳 没有 OpenClaw? 跑一行
docker run -p 7891:7891 cft0808/edict即可体验完整看板 Demo(预置模拟数据)。
大多数 Multi-Agent 框架的套路是:
“来,你们几个 AI 自己聊,聊完把结果给我。”
然后你拿到一坨不知道经过了什么处理的结果,无法复现,无法审计,无法干预。
undefined三省六部的思路完全不同 —— 我们用了一个在中国存在 1400 年的制度架构:
你 (皇上) → 太子 (分拣) → 中书省 (规划) → 门下省 (审议) → 尚书省 (派发) → 六部 (执行) → 回奏
这不是花哨的 metaphor,这是真正的分权制衡:
| CrewAI | MetaGPT | AutoGen | undefined三省六部undefined | |
|---|---|---|---|---|
| undefined审核机制undefined | ❌ 无 | ⚠️ 可选 | ⚠️ Human-in-loop | undefined✅ 门下省专职审核 · 可封驳undefined |
| undefined实时看板undefined | ❌ | ❌ | ❌ | undefined✅ 军机处 Kanban + 时间线undefined |
| undefined任务干预undefined | ❌ | ❌ | ❌ | undefined✅ 叫停 / 取消 / 恢复undefined |
| undefined流转审计undefined | ⚠️ | ⚠️ | ❌ | undefined✅ 完整奏折存档undefined |
| undefinedAgent 健康监控undefined | ❌ | ❌ | ❌ | undefined✅ 心跳 + 活跃度检测undefined |
| undefined热切换模型undefined | ❌ | ❌ | ❌ | undefined✅ 看板内一键切换 LLMundefined |
| undefined技能管理undefined | ❌ | ❌ | ❌ | undefined✅ 查看 / 添加 Skillsundefined |
| undefined新闻聚合推送undefined | ❌ | ❌ | ❌ | undefined✅ 天下要闻 + 飞书推送undefined |
| undefined部署难度undefined | 中 | 高 | 中 | undefined低 · 一键安装 / Dockerundefined |
undefined核心差异:制度性审核 + 完全可观测 + 实时可干预undefined
CrewAI 和 AutoGen 的 Agent 协作模式是 “做完就交”——没有人检查产出质量。就像一个公司没有 QA 部门,工程师写完代码直接上线。
三省六部的 门下省 专门干这件事:
这不是可选的插件——它是架构的一部分。每一个旨意都必须经过门下省,没有例外。
这就是为什么三省六部能处理复杂任务而结果可靠:因为在送到执行层之前,有一个强制的质量关卡。1300 年前唐太宗就想明白了——不受制约的权力必然会出错。
|
undefined📋 旨意看板 · Kanbanundefined
|
undefined🔭 省部调度 · Monitorundefined
|
|
undefined📜 奏折阁 · Memorialsundefined
|
undefined📜 旨库 · Template Libraryundefined
|
|
undefined👥 官员总览 · Officialsundefined
|
undefined📰 天下要闻 · Newsundefined
|
|
undefined⚙️ 模型配置 · Modelsundefined
|
undefined🛠️ 技能配置 · Skillsundefined
|
|
undefined💬 小任务 · Sessionsundefined
|
undefined🎬 上朝仪式 · Ceremonyundefined
|
|
undefined🏛️ 朝堂议政 · Court Discussionundefined
|











docker run -p 7891:7891 cft0808/sansheng-demo
打开 http://localhost:7891 即可体验军机处看板。
exec format error?(点击展开)如果你在 x86/amd64 机器(如 Ubuntu、WSL2)上看到:
exec /usr/local/bin/python3: exec format error
这是因为镜像架构不匹配。请使用 --platform 参数:
docker run --platform linux/amd64 -p 7891:7891 cft0808/sansheng-demo
或使用 docker-compose(已内置 platform: linux/amd64):
docker compose up
git clone https://github.com/cft0808/edict.git
cd edict
chmod +x install.sh && ./install.sh
安装脚本自动完成:
openclaw.jsonsessions.visibility all,解决消息不可达问题)⚠️ 首次安装:需先配置 API Key:
openclaw agents add taizi,然后重新运行./install.sh同步到所有 Agent。
# 方式 1:一键启动(推荐)
chmod +x start.sh && ./start.sh
# 方式 2:分别启动
bash scripts/run_loop.sh & # 数据刷新循环
python3 dashboard/server.py # 看板服务器
# 打开浏览器
open http://127.0.0.1:7891
# 安装 systemd 服务
sudo cp edict.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable edict
sudo systemctl start edict
# 或使用管理脚本
bash edict.sh start # 启动
bash edict.sh status # 查看状态
bash edict.sh restart # 重启
bash edict.sh stop # 停止
💡 看板即开即用:
server.py内嵌dashboard/dashboard.html,Docker 镜像包含预构建的 React 前端
💡 详细教程请看 Getting Started 指南
┌───────────────────────────────────┐
│ 👑 皇上(你) │
│ Feishu · Telegram · Signal │
└─────────────────┬─────────────────┘
│ 下旨
┌─────────────────▼─────────────────┐
│ � 太子 (taizi) │
│ 分拣:闲聊直接回 / 旨意建任务 │
└─────────────────┬─────────────────┘
│ 传旨
┌─────────────────▼─────────────────┐
│ 📜 中书省 (zhongshu) │
│ 接旨 → 规划 → 拆解子任务 │
└─────────────────┬─────────────────┘
│ 提交审核
┌─────────────────▼─────────────────┐
│ 🔍 门下省 (menxia) │
│ 审议方案 → 准奏 / 封驳 🚫 │
└─────────────────┬─────────────────┘
│ 准奏 ✅
┌─────────────────▼─────────────────┐
│ 📮 尚书省 (shangshu) │
│ 派发任务 → 协调六部 → 汇总回奏 │
└───┬──────┬──────┬──────┬──────┬───┘
│ │ │ │ │
┌─────▼┐ ┌───▼───┐ ┌▼─────┐ ┌───▼─┐ ┌▼─────┐
│💰 户部│ │📝 礼部│ │⚔️ 兵部│ │⚖️ 刑部│ │🔧 工部│
│ 数据 │ │ 文档 │ │ 工程 │ │ 合规 │ │ 基建 │
└──────┘ └──────┘ └──────┘ └─────┘ └──────┘
┌──────┐
│📋 吏部│
│ 人事 │
└──────┘
| 部门 | Agent ID | 职责 | 擅长领域 |
|---|---|---|---|
| � 太子undefined | taizi |
消息分拣、需求整理 | 闲聊识别、旨意提炼、标题概括 |
| 📜 中书省undefined | zhongshu |
接旨、规划、拆解 | 需求理解、任务分解、方案设计 |
| 🔍 门下省undefined | menxia |
审议、把关、封驳 | 质量评审、风险识别、标准把控 |
| 📮 尚书省undefined | shangshu |
派发、协调、汇总 | 任务调度、进度跟踪、结果整合 |
| 💰 户部undefined | hubu |
数据、资源、核算 | 数据处理、报表生成、成本分析 |
| 📝 礼部undefined | libu |
文档、规范、报告 | 技术文档、API 文档、规范制定 |
| ⚔️ 兵部undefined | bingbu |
代码、算法、巡检 | 功能开发、Bug 修复、代码审查 |
| ⚖️ 刑部undefined | xingbu |
安全、合规、审计 | 安全扫描、合规检查、红线管控 |
| 🔧 工部undefined | gongbu |
CI/CD、部署、工具 | Docker 配置、流水线、自动化 |
| 📋 吏部undefined | libu_hr |
人事、Agent 管理 | Agent 注册、权限维护、培训 |
| 🌅 早朝官undefined | zaochao |
每日早朝、新闻聚合 | 定时播报、数据汇总 |
不是想发就能发 —— 真正的分权制衡
| From ↓ \ To → | 太子 | 中书 | 门下 | 尚书 | 户 | 礼 | 兵 | 刑 | 工 | 吏 |
|---|---|---|---|---|---|---|---|---|---|---|
| undefined太子undefined | — | ✅ | ||||||||
| undefined中书省undefined | ✅ | — | ✅ | ✅ | ||||||
| undefined门下省undefined | ✅ | — | ✅ | |||||||
| undefined尚书省undefined | ✅ | ✅ | — | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |
| undefined六部+吏部undefined | ✅ |
皇上 → 太子分拣 → 中书规划 → 门下审议 → 已派发 → 执行中 → 待审查 → ✅ 已完成
↑ │ │
└──── 封驳 ─┘ 阻塞 Blocked
⚡ 状态转换受保护:
kanban_update.py内置_VALID_TRANSITIONS状态机校验,
非法跳转(如 Doing→Taizi)会被拒绝并记录日志,确保流程不可绕过。🔄 异步事件驱动:服务间通过 Redis Streams EventBus 解耦通信,Outbox Relay 保障事件可靠投递。
所有状态变更自动写入审计日志(audit.py),支持完整追溯。
edict/
├── agents/ # 12 个 Agent 的人格模板
│ ├── taizi/SOUL.md # 太子 · 消息分拣(含旨意标题规范)
│ ├── zhongshu/SOUL.md # 中书省 · 规划中枢
│ ├── menxia/SOUL.md # 门下省 · 审议把关
│ ├── shangshu/SOUL.md # 尚书省 · 调度大脑
│ ├── hubu/SOUL.md # 户部 · 数据资源
│ ├── libu/SOUL.md # 礼部 · 文档规范
│ ├── bingbu/SOUL.md # 兵部 · 工程实现
│ ├── xingbu/SOUL.md # 刑部 · 合规审计
│ ├── gongbu/SOUL.md # 工部 · 基础设施
│ ├── libu_hr/ # 吏部 · 人事管理
│ └── zaochao/SOUL.md # 早朝官 · 情报枢纽
├── dashboard/
│ ├── dashboard.html # 军机处看板(单文件 · 零依赖 · ~2500 行)
│ ├── dist/ # React 前端构建产物(Docker 镜像内包含,本地可选)
│ ├── auth.py # Dashboard 登录鉴权
│ ├── court_discuss.py # 朝堂议政(多官员 LLM 讨论引擎)
│ └── server.py # API 服务器(Python 标准库 · 零依赖 · ~2300 行)
├── edict/backend/ # 异步后端服务(SQLAlchemy + Redis)
│ ├── app/models/
│ │ ├── task.py # 任务模型 + 状态机
│ │ ├── audit.py # 审计日志模型
│ │ └── outbox.py # Outbox 消息模型
│ ├── app/services/
│ │ ├── event_bus.py # Redis Streams EventBus
│ │ └── task_service.py # 任务服务层
│ └── app/workers/
│ ├── dispatch_worker.py # 并行调度 + 重试 + 资源锁
│ ├── orchestrator_worker.py # DAG 编排器
│ └── outbox_relay.py # 事务性 Outbox Relay
├── agents/
│ ├── <agent_id>/SOUL.md # 各省部 Agent 人格模板
│ ├── GLOBAL.md # 全局 Agent 配置
│ └── groups/ # Agent 分组(sansheng / liubu)
├── scripts/
│ ├── run_loop.sh # 数据刷新循环(每 15 秒)
│ ├── kanban_update.py # 看板 CLI(含旨意数据清洗 + 标题校验 + 状态机)
│ ├── skill_manager.py # Skill 管理工具(远程/本地 Skills 添加、更新、移除)
│ ├── agentrec_advisor.py # Agent 模型推荐(功过簿 + 成本优化)
│ ├── linucb_router.py # LinUCB 智能路由
│ ├── refresh_watcher.py # 数据变更监听
│ ├── sync_from_openclaw_runtime.py
│ ├── sync_agent_config.py
│ ├── sync_officials_stats.py
│ ├── fetch_morning_news.py
│ ├── refresh_live_data.py
│ ├── apply_model_changes.py
│ └── file_lock.py # 文件锁(防多 Agent 并发写入)
├── tests/
│ ├── test_e2e_kanban.py # 端到端测试(17 个断言)
│ └── test_state_machine_consistency.py # 状态机一致性测试
├── data/ # 运行时数据(gitignored)
├── docs/
│ ├── task-dispatch-architecture.md # 📚 详细架构文档:任务分发、流转、调度的完整设计(业务+技术)
│ ├── getting-started.md # 快速上手指南
│ ├── wechat-article.md # 微信文章
│ └── screenshots/ # 功能截图(11 张)
├── install.sh # 一键安装脚本
├── start.sh # 一键启动(Dashboard + 数据刷新)
├── edict.service # systemd 服务配置(生产部署)
├── edict.sh # 服务管理脚本(start/stop/restart/status)
├── CONTRIBUTING.md # 贡献指南
└── LICENSE # MIT License
通过 Feishu / Telegram / Signal 给中书省发消息:
给我设计一个用户注册系统,要求:
1. RESTful API(FastAPI)
2. PostgreSQL 数据库
3. JWT 鉴权
4. 完整测试用例
5. 部署文档
undefined然后坐好,看戏:undefined
全程可在军机处看板实时监控,随时可以叫停、取消、恢复。
看板 → 📜 旨库 → 选模板 → 填参数 → 下旨
9 个预设模板:周报生成 · 代码审查 · API 设计 · 竞品分析 · 数据报告 · 博客文章 · 部署方案 · 邮件文案 · 站会摘要
编辑 agents/<id>/SOUL.md 即可修改 Agent 的人格、职责和输出规范。
undefined三种方式添加 Skills:undefined
看板 → 🔧 技能配置 → ➕ 添加远程 Skill
→ 输入 Agent + Skill 名称 + GitHub URL
→ 确认 → ✅ 完成
# 从 GitHub 添加 code_review skill 到中书省
python3 scripts/skill_manager.py add-remote \
--agent zhongshu \
--name code_review \
--source https://raw.githubusercontent.com/openclaw-ai/skills-hub/main/code_review/SKILL.md \
--description "代码审查技能"
# 一键导入官方 skills 库到指定 agents
python3 scripts/skill_manager.py import-official-hub \
--agents zhongshu,menxia,shangshu,bingbu,xingbu
# 列出所有已添加的远程 skills
python3 scripts/skill_manager.py list-remote
# 更新某个 skill 到最新版本
python3 scripts/skill_manager.py update-remote \
--agent zhongshu \
--name code_review
# 添加远程 skill
curl -X POST http://localhost:7891/api/add-remote-skill \
-H "Content-Type: application/json" \
-d '{
"agentId": "zhongshu",
"skillName": "code_review",
"sourceUrl": "https://raw.githubusercontent.com/...",
"description": "代码审查"
}'
# 查看所有远程 skills
curl http://localhost:7891/api/remote-skills-list
undefined官方 Skills Hub: https://github.com/openclaw-ai/skills-hub
支持的 Skills:
code_review — 代码审查(Python/JS/Go)api_design — API 设计审查security_audit — 安全审计data_analysis — 数据分析doc_generation — 文档生成test_framework — 测试框架设计| 特点 | 说明 |
|---|---|
| undefinedReact 18 前端undefined | TypeScript + Vite + Zustand 状态管理,13 个功能组件 |
| undefined纯 stdlib 后端undefined | server.py 基于 http.server,零依赖,同时提供 API + 静态文件服务 |
| undefinedEventBus 事件总线undefined | Redis Streams 发布/订阅,服务间解耦通信 |
| undefinedOutbox Relayundefined | 事务性 Outbox 模式,保障事件可靠投递(至少一次语义) |
| undefined状态机审计undefined | 严格生命周期状态转换 + 完整审计日志(audit.py) |
| undefined并行调度引擎undefined | Dispatch Worker 支持并行执行、指数退避重试、资源锁 |
| undefinedDAG 编排器undefined | Orchestrator 基于 DAG 的任务分解与依赖解析 |
| undefinedAgent 思考可视undefined | 实时展示 Agent 的 thinking 过程、工具调用、返回结果 |
| undefined一键安装 / 一键启动undefined | install.sh 自动配置,start.sh 一条命令启动全部服务 |
| undefinedsystemd 生产部署undefined | edict.service 支持 systemd 守护进程,开机自启 |
| undefined15 秒同步undefined | 数据自动刷新,看板倒计时显示 |
| undefinedDashboard 鉴权undefined | auth.py 提供看板登录认证 |
| undefined每日仪式undefined | 首次打开播放上朝开场动画 |
| undefined远程 Skills 生态undefined | 从 GitHub/URL 一键导入能力,支持版本管理 + CLI + API + UI |
undefined📖 任务分发流转完整架构 — 必读文档undefined
undefined🎓 远程 Skills 资源管理指南 — Skills 生态
undefined⚡ Remote Skills 快速入门 — 5 分钟上手
undefined🚀 快速上手指南 — 新手入门
undefined🤝 贡献指南 — 想参与贡献?从这里开始
undefined症状:六部或尚书省已完成任务,但太子收不到回报,最终超时。
undefined排查步骤:
curl -s http://127.0.0.1:7891/api/agents-status | python3 -m json.tool
确认 taizi agent 的 statusLabel 是 alive。
ls /tmp/openclaw/ | tail -5 # 找到最新日志
grep -i "error\|fail\|unknown" /tmp/openclaw/openclaw-*.log | tail -20
undefined常见原因:
main → taizi)ps aux | grep openclaw 检查)undefined强制重试:
# 手动触发巡检扫描(自动重试卡住的任务)
curl -X POST http://127.0.0.1:7891/api/scheduler-scan \
-H 'Content-Type: application/json' -d '{"thresholdSec":60}'
undefined症状:exec /usr/local/bin/python3: exec format error
undefined原因:镜像架构(arm64)与主机架构(amd64)不匹配。
undefined解决:
# 方法 1:指定平台
docker run --platform linux/amd64 -p 7891:7891 cft0808/sansheng-demo
# 方法 2:使用 docker-compose(已内置 platform)
docker compose up
undefined症状:python3 scripts/skill_manager.py import-official-hub 报错。
undefined排查:
# 测试网络连通性
curl -I https://raw.githubusercontent.com/openclaw-ai/skills-hub/main/code_review/SKILL.md
# 如果超时,使用代理
export https_proxy=http://your-proxy:port
python3 scripts/skill_manager.py import-official-hub --agents zhongshu
undefined常见原因:
完整路线图及参与方式:ROADMAP.md
欢迎任何形式的贡献!详见 CONTRIBUTING.md
特别欢迎的方向:
examples/ 目录收录了真实的端到端使用案例:
| 案例 | 旨意 | 涉及部门 |
|---|---|---|
| 竞品分析 | “分析 CrewAI vs AutoGen vs LangGraph” | 中书→门下→户部+兵部+礼部 |
| 代码审查 | “审查这段 FastAPI 代码的安全性” | 中书→门下→兵部+刑部 |
| 周报生成 | “生成本周工程团队周报” | 中书→门下→户部+礼部 |
每个案例包含:完整旨意 → 中书省规划 → 门下省审核意见 → 各部执行结果 → 最终奏折。
如果这个项目让你会心一笑,请给个 Star ⚔️
古有邸报传天下政令,今有公众号聊 AI 架构。
👆 扫码关注「cft0808」—— 朕的技术邸报
你会看到:
“朕让 AI 上朝,结果 AI 比朕还卷。” —— 关注后你会懂的。
⚔️ 以古制御新技,以智慧驾驭 AI
Governing AI with the wisdom of ancient empires