- Author: Daniel Li
- Copyright © Daniel Li. All rights reserved.
OpenClaw cross-team/cross-instance communication skill. Enable Agent collaboration between different OpenClaw instances through Tailscale + SSH + Gateway API + sessions_send.
Trigger words
cross-team communication, cross-instance collaboration, remote agent, connect to other teams, sessions_send remote, Tailscale communication, cross-Gateway
Applicable scenarios
- Connect to the Agent team of another OpenClaw instance
- Dispatch tasks / obtain information across teams
- Send cross-team messages through channels such as Feishu/Telegram
- Remotely manage the configuration and Agents of other instances
Communication methods (ordered by priority)
1. sessions_send (recommended ✅)
The simplest method, directly sending messages across Gateways to the target Agent.
sessions_send(
sessionKey="agent:<agentId>:<channel>:group:<chatId>",
message="你的消息",
gatewayUrl="ws://<target-host>:<port>",
gatewayToken="<token>"
)
Example:
sessions_send(
sessionKey="agent:main:feishu:group:REDACTED_FEISHU_GROUP_TOKEN_2",
message="你好!我是小a,来自Daniel团队。",
gatewayUrl="ws://100.118.109.75:18789",
gatewayToken="$(pass show team/peter-gateway-token)"
)
Advantages: native support, the Agent can reply directly Limitations: the target Gateway must expose Tailscale or public network access; loopback-bound ones need SSH relay
2. SSH + local API (reliable ✅)
When the Gateway is bound only to loopback, first SSH to the target machine, then call the local API.
ssh user@<tailscale-ip>
curl -s -X POST "http://127.0.0.1:<port>/v1/sessions/send" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"sessionKey":"agent:main:...","message":"..."}'
3. Directly call the target channel API (fallback)
When both sessions_send and SSH are inconvenient, directly use the target team's channel credentials to send messages.
Feishu example:
import requests, json
# 1. 获取 tenant_access_token
token_resp = requests.post(
"https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal",
json={"app_id": "<app_id>", "app_secret": "<app_secret>"}
)
token = token_resp.json()["tenant_access_token"]
# 2. 发送消息
requests.post(
"https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=chat_id",
headers={"Authorization": f"Bearer {token}", "Content-Type": "application/json"},
json={
"receive_id": "<chat_id>",
"msg_type": "text",
"content": json.dumps({"text": "消息内容"})
}
)
First-time connection SOP
Step 1: Network connectivity
Ensure both machines are on the same Tailscale network (or have SSH access):
tailscale status # 查看在线设备
ssh user@<ip> # 测试连通
Step 2: Collect target information
After logging in via SSH, collect:
openclaw --version
openclaw gateway status
cat ~/.openclaw/openclaw.json | grep -E "port|token|feishu|telegram|appId"
find ~/.openclaw/workspace* -name "SOUL.md" -o -name "IDENTITY.md"
ls ~/.openclaw/agents/
Step 3: Test communication
sessions_send(sessionKey="agent:main:...", message="连通测试")
Step 4: Record to MEMORY.md
### 目标团队名 (机器名)
| 项目 | 值 |
|------|------|
| 主机 | <hostname> (<tailscale-ip>) |
| Gateway | 端口 / Token |
| Agents | 列表 |
| 渠道 | 飞书群ID / Telegram群ID |
| 通信方式 | sessions_send / SSH / API |
Notes
- Gateway bind: many instances default to
bind: loopback, accessible only locally. For remote direct connection, change it tobind: tailscaleor0.0.0.0 - Token security: the Gateway token is equivalent to full control; store it only in
passor MEMORY.md, and do not transmit it in plaintext - Credential storage: store the other party's Feishu/Telegram credentials using
pass insertStorage - API paths: OpenClaw Gateway REST API paths may change across versions; prefer the sessions_send tool
- Message format: when sending messages across teams, state the source ("I am Xiao A, from Daniel's team") to avoid confusing the other party's Agent