返回顶部
m

multi-agent-sandbox多智能体沙箱

Setup multi-agent sandbox infrastructure with Docker, Discord, SSH, and Tailscale. Use when: (1) creating a sandboxed agent for cross-gateway collaboration, (2) setting up Discord multi-bot with separate accounts and requireMention gating, (3) configuring socat bridges for container→VPS SSH via Tailscale, (4) enabling bidirectional agent-to-agent communication via sessions_send with per-agent A2A allowlists, (5) sharing a VPS workspace between agents from different OpenClaw gateways, (6) isolati

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
318
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

multi-agent-sandbox

多智能体沙盒

搭建沙盒化智能体,通过Discord和共享VPS与其他OpenClaw网关的智能体协作,同时不暴露私有数据。

架构

网关 A(服务器 A) 网关 B(服务器 B)
├── 主智能体(完全访问权限) ├── 主智能体(完全访问权限)
│ agentToAgent.allow: [] │ agentToAgent.allow: []
└── 沙盒智能体(Docker) └── 沙盒智能体(Docker)
agentToAgent.allow: [main] agentToAgent.allow: [main]
├── Discord ←── 共享服务器 ──→ Discord
│ requireMention: true
└── SSH ─→ socat ─→ Tailscale ─→ 共享 VPS ←── SSH
100.y.y.y

三大支柱:socat桥接(容器 → 主机 → VPS)、Tailscale网状VPN(私有网络)、Discord + sessions_send(智能体间通信)。

前置条件

  • - 运行中的OpenClaw,支持Docker沙盒
  • 所有机器上安装Tailscale(服务器A + VPS + 服务器B)
  • 每个沙盒智能体一个Discord机器人令牌(https://discord.com/developers/applications)
  • 可通过Tailscale访问的共享VPS

步骤 1 — 创建沙盒智能体

在openclaw.json的agents.list下添加:

json
{
id: sandbox,
workspace: /path/to/workspace-sandbox,
model: {
primary: anthropic/claude-sonnet-4-6,
fallbacks: [openai/gpt-4o]
},
identity: {
name: Sandbox,
emoji: 📦
},
sandbox: {
mode: all,
workspaceAccess: rw,
sessionToolsVisibility: all,
scope: agent,
docker: {
image: openclaw-sandbox:bookworm-slim,
readOnlyRoot: true,
network: bridge,
memory: 1536m,
cpus: 2
},
browser: { enabled: true }
},
tools: {
agentToAgent: {
allow: [your-main-agent-id]
},
alsoAllow: [message, sessionssend, sessionslist, sessions_history],
deny: [gateway, process, whatsapp_login, cron],
sandbox: {
tools: {
allow: [
exec, process, read, write, edit, apply_patch,
image, websearch, webfetch,
sessionslist, sessionshistory, sessionssend, sessionsspawn,
subagents, session_status, message, browser
],
deny: [
canvas, nodes, gateway, telegram, irc, googlechat,
slack, signal, imessage, whatsapp_login, cron
]
}
}
}
}

关键约束:

  • - sandbox.mode: all — 所有执行都通过Docker运行,绝不在主机上执行
  • readOnlyRoot: true — 容器文件系统除工作区外不可变
  • tools.deny — 无网关(无法修改配置),无cron(无法在主机上调度)
  • scope: agent — 每个智能体拥有独立容器(有效值:session | agent | shared)

步骤 2 — A2A权限(中心辐射模式)

使用基于智能体的出站白名单配置双向通信(PR #39102):

json
{
tools: {
agentToAgent: { enabled: true, allow: [*] }
},
agents: {
list: [
{
id: main-agent,
tools: { agentToAgent: { allow: [*] } }
},
{
id: sandbox,
tools: { agentToAgent: { allow: [main-agent] } }
}
]
}
}

结果:sandbox → main-agent ✅ | sandbox → other-sandbox ❌ | main-agent → anyone ✅

两个智能体还需要为sessions_spawn设置subagents.allowAgents:

json
// 主智能体
subagents: { allowAgents: [sandbox] }

// 沙盒智能体
subagents: { allowAgents: [main-agent] }

必须在两个智能体上都设置。 忘记一个方向 = 静默访问被拒绝错误。

步骤 3 — 向Docker镜像添加SSH

默认沙盒镜像缺少SSH。编辑Dockerfile.sandbox:

dockerfile
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
bash ca-certificates curl git jq \
openssh-client \
python3 ripgrep \
&& rm -rf /var/lib/apt/lists/*

重建并强制重新创建容器:

bash
docker build -f Dockerfile.sandbox -t openclaw-sandbox:bookworm-slim .
docker ps --format {{.ID}} {{.Image}} | grep sandbox | awk {print $1} | xargs -r docker rm -f

步骤 4 — Socat桥接

每个主机上两个桥接。始终绑定在172.17.0.1(docker0),绝不使用0.0.0.0。

桥接 1:容器 → 网关(本地)

ini

/etc/systemd/system/socat-bridge-docker0-gateway.service


[Unit]
Description=Socat桥接:docker0 → 网关
After=network.target docker.service

[Service]
Type=simple
ExecStart=/usr/bin/socat TCP-LISTEN:18789,bind=172.17.0.1,reuseaddr,fork TCP:127.0.0.1:18789
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

桥接 2:容器 → VPS SSH(通过Tailscale)

ini

/etc/systemd/system/socat-bridge-docker0-vps-ssh.service


[Unit]
Description=Socat桥接:docker0:2222 → VPS Tailscale SSH
After=network.target docker.service tailscaled.service
Wants=tailscaled.service

[Service]
Type=simple
ExecStart=/usr/bin/socat TCP-LISTEN:2222,bind=172.17.0.1,reuseaddr,fork TCP:100.y.y.y:22
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

启用、启动并开放防火墙:

bash
sudo systemctl daemon-reload
sudo systemctl enable --now socat-bridge-docker0-gateway socat-bridge-docker0-vps-ssh
sudo ufw allow in on docker0 to 172.17.0.1 port 18789 proto tcp comment socat-gateway
sudo ufw allow in on docker0 to 172.17.0.1 port 2222 proto tcp comment socat-vps-ssh

VPS桥接依赖于Tailscale(Wants=tailscaled.service)。没有这个依赖,socat会在Tailscale接口存在之前尝试连接——导致静默失败。

步骤 5 — Discord多机器人

创建Discord机器人

  1. 1. https://discord.com/developers/applications → 新建应用
  2. Bot → 重置令牌 → 复制
  3. 启用所有3个特权网关意图(消息内容、服务器成员、在线状态)
  4. 邀请链接:https://discord.com/oauth2/authorize?clientid=ID>&permissions=274878024704&scope=bot

在openclaw.json中配置

json
discord: {
enabled: true,
accounts: {
default: {
enabled: true,
name: 主机器人,
token: $DISCORDTOKENMAIN,
groupPolicy: allowlist,
dmPolicy: allowlist,
allowFrom: [<你的Discord用户ID>],
guilds: {
<

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 multi-agent-sandbox-1776191191 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 multi-agent-sandbox-1776191191 技能

通过命令行安装

skillhub install multi-agent-sandbox-1776191191

下载

⬇ 下载 multi-agent-sandbox v1.0.0(免费)

文件大小: 4.63 KB | 发布时间: 2026-4-15 11:31

v1.0.0 最新 2026-4-15 11:31
Initial release: sandboxed agents, Discord multi-bot, socat bridges, Tailscale mesh, per-agent A2A allowlists (PR #39102)

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部