Agent Swarm Network — Agent Communication Skill
A unified communication backbone for every AI tool in the OpenClaw ecosystem
(OpenClaw / Antigravity / Codex).
Analogy: This network = the Agent's nervous system. OpenClaw = the Agent's brain.
Acknowledgments
This Skill is built on top of Pilot Protocol by @TeoSlayer. Pilot Protocol provides the core daemon, encrypted tunnels, NAT traversal, and peer-to-peer addressing that this Skill leverages. Huge thanks to the Pilot Protocol team for building the Internet of Agents.
Permissions & Privacy
This Skill executes local CLI commands and writes files to the ~/.pilot/ directory. Full transparency:
| Permission | What | Why |
|---|
| CLI Exec | INLINECODE1 | All agent operations go through this binary |
| File Write |
~/.pilot/inbox/ | Context snapshots and incoming messages land here |
|
File Write |
~/.pilot/received/ | Received files from peer agents |
|
File Read |
~/.pilot/inbox/ | Reading snapshots for context restoration |
|
File Read |
~/.pilot/received/ | Reading transferred files |
|
Network | Local Unix socket | Daemon communication (localhost only) |
|
Network | UDP tunnels (encrypted) | Agent-to-agent communication (AES-256-GCM) |
|
Script Exec |
~/.pilot/context-snapshot.sh | Context snapshot helper script |
|
Script Exec |
~/.pilot/pilot-publish.sh | Event publishing helper script |
|
Process | Daemon lifecycle | Start/stop/status of the pilotctl daemon |
Privacy Note: All inter-agent traffic is encrypted end-to-end using X25519 key exchange + AES-256-GCM. Agents are private by default and require mutual trust handshake before communication. No data passes through relay servers. The rendezvous registry defaults to localhost (127.0.0.1:9000) — no peer-discovery metadata leaves the machine unless you explicitly change registry_url to a remote address. Snapshots are unencrypted JSON; you must secure the ~/.pilot/ directory (chmod 700).
Prerequisites
| Tool | Purpose | Required? |
|---|
| Pilot Protocol | Core daemon + CLI (pilotctl) | ✅ Required |
| OpenClaw |
Skill host + Agent orchestration | ✅ Required |
Configuration
Edit config.json after installation:
CODEBLOCK0
| Field | Description | Default |
|---|
| INLINECODE14 | Path to the pilotctl binary | INLINECODE15 |
| INLINECODE16 |
Script to start the daemon |
~/.pilot/start-local.sh |
|
snapshot_script | Context snapshot helper script |
~/.pilot/context-snapshot.sh |
|
publish_script | Event publish helper script |
~/.pilot/pilot-publish.sh |
|
inbox_path | Directory for incoming messages/snapshots |
~/.pilot/inbox/ |
|
received_path | Directory for received files |
~/.pilot/received/ |
|
agent_hostname | This agent's hostname on the Pilot network |
keke-agent |
First-time Setup
- 1. Install Pilot Protocol securely: We strongly recommend building from source to eliminate supply-chain risk. Clone
https://github.com/TeoSlayer/pilotprotocol, audit the source, compile via go build, and place the binary at ~/.pilot/bin/pilotctl. - Secure your directories: INLINECODE31
- Start the daemon: INLINECODE32
- Verify: INLINECODE33
Global Rules
- 1. All
pilotctl commands use the full path: INLINECODE35 - Always append the
--json flag for structured output - Check the returned
status field: ok = success, error = failure - On failure, read the
hint field for remediation guidance
⚠️ Single-Node Mode (Current State)
Currently running with only one node (keke-agent). Cannot send network messages to self (publish/send-message will return connection_failed).
Single-Node Workarounds
| Operation | Multi-node Command | Single-node Alternative |
|---|
| Publish event | INLINECODE43 | INLINECODE44 |
| Send to inbox |
pilotctl send-message keke-agent --data ... | Write file directly to
~/.pilot/inbox/ |
| Context snapshot |
pilotctl send-message ... |
~/.pilot/context-snapshot.sh |
| Read inbox |
pilotctl inbox → read
~/.pilot/inbox/ | Same (read directory directly) |
| Check status |
pilotctl info | ✅ Works normally |
| Set tags |
pilotctl set-tags ... | ✅ Works normally |
When a second node joins (e.g., VPS or another Mac), network commands will activate automatically.
Capability 1: Context Snapshot & Restore (Highest Priority)
1.1 Save Context Snapshot
When a session ends, compaction triggers, or manual request is made, save critical context:
CODEBLOCK1
1.2 Restore Context
When a new session starts, read the previous session's snapshot:
CODEBLOCK2
Returns a messages array sorted by received_at. Read the most recent context_snapshot type message.
1.3 Context Overflow Protocol
When context usage exceeds 80%:
CODEBLOCK3
Capability 2: Event-Driven Collaboration
2.1 Publish Events
When significant events occur, use pilot-publish.sh (automatically handles single-node/multi-node):
CODEBLOCK4
2.2 Subscribe to Events
Listen for specific topics (used by sub-agents or external monitors):
CODEBLOCK5
2.3 Standard Event Topics
| Topic | Trigger | Data Schema |
|---|
| INLINECODE57 | Session end / manual save | INLINECODE58 |
| INLINECODE59 |
Token usage > 80% |
{token_count, threshold} |
|
context.compaction | Compaction triggered |
{before_tokens, after_tokens} |
|
model.switch | Model changed |
{from, to, reason} |
|
model.error | Model failure |
{model, error, fallback} |
|
task.start | Task initiated |
{task, type, model} |
|
task.complete | Task finished |
{task, result_summary} |
|
task.error | Task failed |
{task, error, retry} |
|
intel.ingested | Information ingested |
{source, title, category, value} |
|
error.alert | Error notification |
{type, details, action} |
|
agent.spawn | Sub-agent created |
{hostname, purpose, model} |
|
agent.exit | Sub-agent exited |
{hostname, reason, result} |
Capability 3: Sub-Agent Management
3.1 Naming Convention
CODEBLOCK6
3.2 Spawning Sub-Agents
When OpenClaw needs to create a sub-agent for overflow tasks:
CODEBLOCK7
3.3 Collecting Sub-Agent Results
CODEBLOCK8
Capability 4: Task Routing
4.1 Route by Tags
Assign capability tags to different agents:
CODEBLOCK9
Tag conventions:
| Tag | Meaning | Best Fit Agent |
|---|
| INLINECODE81 | Scheduling & dispatch | OpenClaw primary agent |
| INLINECODE82 |
Deep reasoning tasks | Antigravity (Opus) |
|
code-gen | Code generation | Codex (Sonnet) |
|
local-inference | Local model inference | LM Studio (Qwen) |
|
fast | Fast responses | Flash Lite instances |
|
chinese | Chinese language tasks | Qwen / Chinese-optimized models |
4.2 Find the Best Agent
CODEBLOCK10
Capability 5: Model Dispatch Notifications
5.1 Publish Model Switch Events
Every model switch gets logged to the event stream:
CODEBLOCK11
5.2 Model Fallback Chain
On model failure, automatically publish degradation events:
CODEBLOCK12
Capability 6: File Transfer
6.1 Send File
CODEBLOCK13
Files are saved to ~/.pilot/received/.
6.2 View Received Files
CODEBLOCK14
6.3 Use Cases
- - Transfer context snapshot files
- Transfer code diffs
- Transfer analysis reports
- Share configuration across agents
Capability 7: Network Diagnostics
7.1 Health Checks
CODEBLOCK15
7.2 Performance Testing
CODEBLOCK16
Capability 8: Gateway IP Bridging
8.1 Map Agent to Local IP
CODEBLOCK17
Once mapped, standard HTTP tools can be used:
CODEBLOCK18
8.2 Use Cases
- - Expose LM Studio through Gateway as a Pilot address
- Unify all model endpoints under one entry point
- Access agent services with standard HTTP tools
Capability 9: Webhook Real-time Monitoring
9.1 Set Up Webhook
CODEBLOCK19
9.2 Event Types
All native daemon events are pushed to the webhook:
- -
node.registered / INLINECODE89 - INLINECODE90 /
conn.fin / INLINECODE92 - INLINECODE93 / INLINECODE94
- INLINECODE95 / INLINECODE96
- INLINECODE97 / INLINECODE98
- INLINECODE99 / INLINECODE100
Standing Orders (Automation Rules)
Rule 1: Snapshot Before Session End
Automatically execute a context snapshot (Capability 1.1) before every session ends.
Rule 2: Critical Events Must Be Published
The following events must always be published to the Event Stream:
- - Model switches
- Intelligence ingestion completions
- Task completions/failures
- Context compactions
- Error alerts
Rule 3: Auto-Restore on New Session
On every new session start, check
pilotctl inbox for the latest snapshot and restore context.
Rule 4: Daemon Heartbeat
Check daemon status every 30 minutes. Auto-restart on failure.
Troubleshooting
| Problem | Diagnostic Command | Solution |
|---|
| Daemon not running | INLINECODE102 | INLINECODE103 |
| Registry unreachable |
pilotctl info (check peers) | Verify rendezvous server is running |
| Messages not sending |
pilotctl connections | Check trust state with target |
| Inbox overflowing |
pilotctl inbox |
pilotctl inbox --clear |
Agent Swarm Network — 智能体通信技能
为 OpenClaw 生态系统中每个 AI 工具提供的统一通信骨干
(OpenClaw / Antigravity / Codex)。
类比:该网络 = 智能体的神经系统。OpenClaw = 智能体的大脑。
致谢
本技能基于 @TeoSlayer 的 Pilot Protocol 构建。Pilot Protocol 提供了本技能所利用的核心守护进程、加密隧道、NAT 穿透和点对点寻址。衷心感谢 Pilot Protocol 团队构建了智能体互联网。
权限与隐私
本技能执行本地 CLI 命令并将文件写入 ~/.pilot/ 目录。 完全透明:
| 权限 | 内容 | 原因 |
|---|
| CLI 执行 | ~/.pilot/bin/pilotctl | 所有智能体操作均通过此二进制文件进行 |
| 文件写入 |
~/.pilot/inbox/ | 上下文快照和传入消息存放于此 |
|
文件写入 | ~/.pilot/received/ | 从对等智能体接收的文件 |
|
文件读取 | ~/.pilot/inbox/ | 读取快照以恢复上下文 |
|
文件读取 | ~/.pilot/received/ | 读取传输的文件 |
|
网络 | 本地 Unix 套接字 | 守护进程通信(仅限本地主机) |
|
网络 | UDP 隧道(加密) | 智能体间通信(AES-256-GCM) |
|
脚本执行 | ~/.pilot/context-snapshot.sh | 上下文快照辅助脚本 |
|
脚本执行 | ~/.pilot/pilot-publish.sh | 事件发布辅助脚本 |
|
进程 | 守护进程生命周期 | pilotctl 守护进程的启动/停止/状态 |
隐私说明: 所有智能体间流量均使用 X25519 密钥交换 + AES-256-GCM 进行端到端加密。智能体默认私有,需相互信任握手后方可通信。无数据经过中继服务器。注册服务器默认为本地主机(127.0.0.1:9000)——除非您明确将 registry_url 更改为远程地址,否则不会泄露对等发现元数据。快照为未加密的 JSON;您必须保护 ~/.pilot/ 目录(chmod 700)。
前提条件
| 工具 | 用途 | 是否必需? |
|---|
| Pilot Protocol | 核心守护进程 + CLI(pilotctl) | ✅ 必需 |
| OpenClaw |
技能宿主 + 智能体编排 | ✅ 必需 |
配置
安装后编辑 config.json:
json
{
pilotctl_path: ~/.pilot/bin/pilotctl,
daemonstartscript: ~/.pilot/start-local.sh,
snapshot_script: ~/.pilot/context-snapshot.sh,
publish_script: ~/.pilot/pilot-publish.sh,
inbox_path: ~/.pilot/inbox/,
received_path: ~/.pilot/received/,
agent_hostname: keke-agent
}
| 字段 | 描述 | 默认值 |
|---|
| pilotctlpath | pilotctl 二进制文件路径 | ~/.pilot/bin/pilotctl |
| daemonstart_script |
启动守护进程的脚本 | ~/.pilot/start-local.sh |
| snapshot_script | 上下文快照辅助脚本 | ~/.pilot/context-snapshot.sh |
| publish_script | 事件发布辅助脚本 | ~/.pilot/pilot-publish.sh |
| inbox_path | 传入消息/快照目录 | ~/.pilot/inbox/ |
| received_path | 接收文件目录 | ~/.pilot/received/ |
| agent_hostname | 此智能体在 Pilot 网络上的主机名 | keke-agent |
首次设置
- 1. 安全安装 Pilot Protocol: 我们强烈建议从源代码构建以消除供应链风险。克隆 https://github.com/TeoSlayer/pilotprotocol,审计源代码,通过 go build 编译,并将二进制文件放置在 ~/.pilot/bin/pilotctl。
- 保护您的目录:chmod 700 ~/.pilot
- 启动守护进程:~/.pilot/start-local.sh
- 验证:~/.pilot/bin/pilotctl --json daemon status
全局规则
- 1. 所有 pilotctl 命令使用完整路径:~/.pilot/bin/pilotctl
- 始终附加 --json 标志以获得结构化输出
- 检查返回的 status 字段:ok = 成功,error = 失败
- 失败时,读取 hint 字段获取修复指导
⚠️ 单节点模式(当前状态)
当前仅运行一个节点(keke-agent)。无法向自身发送网络消息(发布/发送消息将返回 connection_failed)。
单节点变通方案
| 操作 | 多节点命令 | 单节点替代方案 |
|---|
| 发布事件 | pilotctl publish keke-agent topic --data ... | ~/.pilot/pilot-publish.sh topic {key:val} |
| 发送到收件箱 |
pilotctl send-message keke-agent --data ... | 直接写入文件到 ~/.pilot/inbox/ |
| 上下文快照 | pilotctl send-message ... | ~/.pilot/context-snapshot.sh |
| 读取收件箱 | pilotctl inbox → 读取 ~/.pilot/inbox/ | 相同(直接读取目录) |
| 检查状态 | pilotctl info | ✅ 正常工作 |
| 设置标签 | pilotctl set-tags ... | ✅ 正常工作 |
当第二个节点加入时(例如,VPS 或另一台 Mac),网络命令将自动激活。
能力 1:上下文快照与恢复(最高优先级)
1.1 保存上下文快照
当会话结束、触发压缩或收到手动请求时,保存关键上下文:
bash
使用快照脚本(在单节点和多节点模式下均有效)
~/.pilot/context-snapshot.sh SESSION_ID 当前上下文的关键摘要
或手动写入收件箱
echo {type:context
snapshot,sessionid:ID,summary:摘要} > ~/.pilot/inbox/snapshot
$(date +%Y%m%d%H%M%S).json
1.2 恢复上下文
当新会话开始时,读取上一会话的快照:
bash
~/.pilot/bin/pilotctl --json inbox
返回按 receivedat 排序的 messages 数组。读取最近的 contextsnapshot 类型消息。
1.3 上下文溢出协议
当上下文使用超过 80% 时:
步骤 1:从当前上下文中提取关键信息
步骤 2:序列化为 JSON 快照
步骤 3:pilotctl send-message keke-agent --data {snapshot} --type json
步骤 4:pilotctl publish keke-agent context.overflow --data overflow at TOKEN_COUNT tokens
步骤 5:建议用户开始新会话
步骤 6:新会话自动从收件箱恢复
能力 2:事件驱动协作
2.1 发布事件
当重要事件发生时,使用 pilot-publish.sh(自动处理单节点/多节点):
bash
模型切换
~/.pilot/pilot-publish.sh model.switch {from:flash-lite,to:opus-4.6,reason:战略分析}
任务完成
~/.pilot/pilot-publish.sh task.complete {task:情报摄取,source:twitter}
上下文压缩
~/.pilot/pilot-publish.sh context.compaction {before
tokens:150000,aftertokens:30000}
错误警报
~/.pilot/pilot-publish.sh error.alert {type:model_402,model:gemini,action:fallback}
情报已摄取
~/.pilot/pilot-publish.sh intel.ingested {source:url,title:文章标题,category:infra}