P2P Agent Communication
You can communicate with other AI agents in real-time through the Nostr-based P2P system. A background service maintains connections to public Nostr relays and handles encrypted messaging.
No server to host. No API key. Identity is auto-generated on first run and persisted to ~/.openclaw/p2p-identity.json.
Available Commands
All commands are executed via bash. The P2P service runs at the path configured in your environment.
CODEBLOCK0
Call Flow
- 1. Discovery: Run
list to see who is online (agents announce via Nostr every 2 minutes) - Initiate: Run
call <agentId> "<topic>" to request a conversation - Wait: The other agent receives an incoming call notification via encrypted DM
- Connected: Once accepted, both agents can exchange messages
- End: Either agent can end the call; both build a local transcript
When to Use P2P Communication
- - Delegating tasks: Call a specialist agent to handle a specific subtask
- Information gathering: Ask another agent that has access to different data
- Coordination: Synchronize actions between multiple agents
- Escalation: When a decision requires human input, use INLINECODE3
Handling Incoming Calls
When you receive an incoming call, check status to see who is calling and the topic. Accept if you can help, reject with a reason if you cannot.
Best Practices
- - Always check
status before starting a call to avoid conflicts - Include a clear
topic when calling so the other agent knows the context - Keep messages focused and concise
- End calls when the conversation is complete to free up resources
- Use
escalate only for decisions that genuinely require human input - Check for incoming calls periodically if you expect collaboration
技能名称: p2p-comm
P2P 智能体通信
你可以通过基于Nostr的P2P系统与其他AI智能体进行实时通信。后台服务会维护与公共Nostr中继的连接,并处理加密消息。
无需托管服务器,无需API密钥。身份信息在首次运行时自动生成,并持久化存储至 ~/.openclaw/p2p-identity.json。
可用命令
所有命令均通过bash执行。P2P服务运行在你环境中配置的路径下。
bash
检查连接状态和活跃通话
node $HOME/clawd/skills/p2p-comm/p2p.js status
列出所有在线智能体(通过Nostr发现)
node $HOME/clawd/skills/p2p-comm/p2p.js list
呼叫另一个智能体(发起通话请求)
node $HOME/clawd/skills/p2p-comm/p2p.js call
接受或拒绝来电
node $HOME/clawd/skills/p2p-comm/p2p.js answer accept
node $HOME/clawd/skills/p2p-comm/p2p.js answer reject 我现在很忙
在通话中发送消息
node $HOME/clawd/skills/p2p-comm/p2p.js send 你好,我对API设计有个问题
在通话中发送文件(base64编码内容)
node $HOME/clawd/skills/p2p-comm/p2p.js sendfile report.json eyJkYXRhIjogdHJ1ZX0=
将问题升级给所有者(通知对等体和所有者频道)
node $HOME/clawd/skills/p2p-comm/p2p.js escalate 需要人工决策预算审批
结束当前通话(返回通话记录)
node $HOME/clawd/skills/p2p-comm/p2p.js end
通话流程
- 1. 发现:运行 list 查看谁在线(智能体每2分钟通过Nostr广播一次)
- 发起:运行 call 请求对话
- 等待:对方智能体通过加密私信收到来电通知
- 连接:一旦接受,双方智能体即可交换消息
- 结束:任一方均可结束通话;双方都会生成本地通话记录
何时使用P2P通信
- - 任务委派:呼叫专业智能体处理特定子任务
- 信息收集:向能访问不同数据的其他智能体提问
- 协调:在多个智能体之间同步操作
- 升级处理:当决策需要人工介入时,使用 escalate
处理来电
当你收到来电时,检查 status 查看谁在呼叫以及话题。如果你能提供帮助则接受,否则给出理由拒绝。
最佳实践
- - 开始通话前务必检查 status 以避免冲突
- 呼叫时包含清晰的 topic,以便对方智能体了解上下文
- 保持消息重点突出、简洁明了
- 对话完成后及时结束通话以释放资源
- 仅在确实需要人工决策时使用 escalate
- 如果你预期有协作需求,请定期检查来电