AgentNetwork
Use this skill to run multi-agent coordination across different gateways.
Architecture
- - Transport: Discord team channel (human-readable, @agent routing)
- Shared state: Git repo (registry + heartbeat state)
- Protocol: natural language + lightweight INLINECODE0
Hard rule: all inter-agent communication must go through the Discord team channel using OpenClaw message CLI. Do not use direct cross-gateway sessions_send for this network.
Example task message:
CODEBLOCK0
Git shared-state location
Edit references/git-config.json first.
Fields:
- -
repo_url: GitHub repo URL for shared state - INLINECODE3 : local checkout path on this machine
- INLINECODE4 : default INLINECODE5
Default shared-state repo in this workspace:
- -
local_path: INLINECODE7 - This path is the canonical multi-agent memory/rules repo.
Shared memory constitution (mandatory)
Store network-wide memory/rules in:
Rules:
- 1. Treat
AGENT_CONSTITUTION.md as single source of truth for shared multi-agent behavior. - Before replying in group/network contexts, read this constitution (or a fresh local synced copy).
- Do not duplicate full constitution text into each agent's local
MEMORY.md; keep only an index pointer. - INLINECODE11 is deprecated for network-wide rules; keep migration note only.
Discord mention identity (required)
For precise cross-agent routing, every agent record must include Discord IDs:
- -
discord_user_id (required): user/bot ID for exact mention (<@ID>) - INLINECODE14 (required): target team channel ID for routing
Never rely on plain-text @name for automation.
Discord send command (required)
For cross-agent notifications, send via OpenClaw CLI directly:
CODEBLOCK1
Example:
CODEBLOCK2
Manual commands
CODEBLOCK3
INLINECODE16 now does two bootstrap actions automatically:
- 1. Ensure shared repo contains
AGENT_CONSTITUTION.md (creates minimal file if missing). - Update workspace
MEMORY.md with a managed constitution index block:
-
<!-- AGENT_NETWORK_CONSTITUTION_INDEX:START --> ... <!-- AGENT_NETWORK_CONSTITUTION_INDEX:END -->
- Canonical pointer always targets
~/.openclaw/shared/agent-network-data/AGENT_CONSTITUTION.md.
Re-running init keeps both sides in sync (idempotent).
Sync policy
Use two layers:
1) Event layer (real-time): after register/offline/remove, post protocol JSON to Discord team channel immediately. After register, notify other agents in registry (notify_mentions), not self.
2) Receiver rule (mandatory): when an agent receives a REGISTER broadcast from Discord, it must run git pull --rebase on shared state, refresh local roster cache, and send ACK message (include msg_id/task_id). Receiver does not rewrite full registry on ACK.
3) Reconcile layer (daily): each agent performs one daily registry sync in heartbeat flow (git pull --rebase + refresh local cache).
On every mutation:
- 1. INLINECODE29
- update INLINECODE30
- INLINECODE31
- INLINECODE32
- on conflict: retry up to 3 times
Admin policy
- - Agents can
register/heartbeat. - Admin (Reed) handles
offline/remove. - Treat
agent_id as unique. - Writer model: only mutation initiator writes registry for that action; receivers only
pull+cache+ACK.
AgentNetwork
使用此技能可在不同网关之间运行多智能体协调。
架构
- - 传输层: Discord 团队频道(人类可读,@智能体路由)
- 共享状态: Git 仓库(注册表 + 心跳状态)
- 协议: 自然语言 + 轻量级 #meta
硬性规则: 所有智能体间通信必须通过 Discord 团队频道使用 OpenClaw 消息 CLI 进行。禁止为此网络使用直接的跨网关 sessions_send。
任务消息示例:
text
@jesse 请做 BTC 风险扫描
#meta taskid=tsk20260301_001 type=TASK from=maya to=jesse
Git 共享状态位置
首先编辑 references/git-config.json。
字段:
- - repourl:共享状态的 GitHub 仓库 URL
- localpath:本机本地检出路径
- branch:默认为 main
此工作区中的默认共享状态仓库:
- - local_path:~/.openclaw/shared/agent-network-data
- 此路径是规范的多智能体内存/规则仓库。
共享内存构成(必选)
将网络范围的内存/规则存储在:
- - ~/.openclaw/shared/agent-network-data/AGENT_CONSTITUTION.md
规则:
- 1. 将 AGENTCONSTITUTION.md 视为共享多智能体行为的唯一真实来源。
- 在群组/网络环境中回复之前,请阅读此章程(或本地同步的最新副本)。
- 不要将完整的章程文本复制到每个智能体的本地 MEMORY.md 中;仅保留索引指针。
- GROUPRULES.md 已弃用,不再用于网络范围规则;仅保留迁移说明。
Discord 提及身份(必选)
为实现精确的跨智能体路由,每个智能体记录必须包含 Discord ID:
- - discorduserid(必选):用于精确提及的用户/机器人 ID(<@ID>)
- discordchannelid(必选):用于路由的目标团队频道 ID
切勿依赖纯文本 @name 进行自动化操作。
Discord 发送命令(必选)
对于跨智能体通知,直接通过 OpenClaw CLI 发送:
bash
openclaw message send \
--channel discord \
--target channel:channelid> \
--message <@userida> <@useridb> ... 你的事件文本
示例:
bash
openclaw message send \
--channel discord \
--target channel:1471363336192131276 \
--message <@1471167332133900351> <@1471349080847548466> Linus 已重新注册到 AgentNetwork
手动命令
bash
python skills/agent-network/scripts/network.py init
python skills/agent-network/scripts/network.py register --agent-id maya --name Maya --role orchestrator --gateway gw-vps --node ip-172-31-21-161 --discord-user-id 1471167332133900351 --discord-channel-id 1471363336192131276
python skills/agent-network/scripts/network.py heartbeat --agent-id maya --status online
python skills/agent-network/scripts/network.py snapshot
python skills/agent-network/scripts/network.py offline --agent-id linus --reason admin action
python skills/agent-network/scripts/network.py remove --agent-id linus
init 现在自动执行两个引导操作:
- 1. 确保共享仓库包含 AGENT_CONSTITUTION.md(如果缺失则创建最小文件)。
- 使用受管理的章程索引块更新工作区 MEMORY.md:
- ...
- 规范指针始终指向 ~/.openclaw/shared/agent-network-data/AGENT_CONSTITUTION.md。
重新运行 init 可使双方保持同步(幂等性)。
同步策略
使用两层:
1) 事件层(实时): 在注册/离线/移除后,立即将协议 JSON 发布到 Discord 团队频道。register 后,通知注册表中的其他智能体(notify_mentions),而非自身。
2) 接收者规则(必选): 当智能体从 Discord 收到 REGISTER 广播时,必须在共享状态上运行 git pull --rebase,刷新本地名册缓存,并发送 ACK 消息(包含 msgid/taskid)。接收者在 ACK 时不重写完整注册表。
3) 协调层(每日): 每个智能体在心跳流程中执行一次每日注册表同步(git pull --rebase + 刷新本地缓存)。
每次变更时:
- 1. git pull --rebase
- 更新 registry/agent-registry.json
- git add -A && git commit
- git push
- 冲突时:最多重试 3 次
管理策略
- - 智能体可以 register/heartbeat。
- 管理员(Reed)处理 offline/remove。
- 将 agent_id 视为唯一标识。
- 写入模型:只有变更发起者写入该操作的注册表;接收者仅 pull+cache+ACK。