OpenClawSkills
GitHub
コア概念 • 5分で読める

マルチエージェントルーティング

マルチエージェントルーティング:分離されたエージェント、チャネルアカウント、バインディング。

目標:複数の_分離された_エージェント(個別のワークスペース + ''agentDir'' + セッション)、および単一の実行中のゲートウェイ内の複数のチャネルアカウント(例:2 つの WhatsApp)。インバウンドはバインディングを介してエージェントにルーティングされます。

Tutorial.step

"単一エージェント"とは何ですか?

エージェントは、独自のものを持つフルスコープの「脳」です:

- ワークスペース(ファイル、AGENTS.md/SOUL.md/USER.md、ローカルノート、ペルソナルール)。

- 認証プロファイル、モデルレジストリ、およびエージェントごとの設定用の''状態ディレクトリ'' (''agentDir'')。

- ''~/.openclaw/agents/<agentId>/sessions'' にある''セッションストレージ''(チャット履歴 + ルーティング状態)。

認証プロファイルはエージェントごとです。各エージェントは独自の内容を読み取ります:

Terminal
~/.openclaw/agents/<agentId>/agent/auth-profiles.json

プライマリエージェントの認証情報は''自動的に共有されません''。エージェント間で ''agentDir'' を

copy ''auth-profiles.json'' into the other agent's ''agentDir''.

''skills/'' を他のエージェントの ''~/.openclaw/skills'' にコピーします。

The Gateway can host one agent (default) or many agents side-by-side.

''Workspace note:'' each agent's workspace is the ''default cwd'', not a hard sandbox. Relative paths resolve inside the workspace, but absolute paths can reach other host locations unless sandboxing is enabled. See ''Sandboxing''.

ゲートウェイは1 つのエージェント(デフォルト)または複数のエージェントを並列でホストできます。

ワークスペースの注意:各エージェントのワークスペースはデフォルトの cwdであり、ハードな

サンドボックスではありません。相対パスはワークスペース内で解決されますが、絶対パスは

サンドボックスが有効になっていない限り、他のホストの場所にアクセスできます。

''サンドボックス''を参照してください。

Tutorial.step

パス(クイックマップ)

- 設定:''~/.openclaw/openclaw.json''(または ''OPENCLAW_CONFIG_PATH'')

- 状態ディレクトリ:''~/.openclaw''(または ''OPENCLAW_STATE_DIR'')

- ワークスペース:''~/.openclaw/workspace''(または ''~/.openclaw/workspace-<agentId>'')

- エージェントディレクトリ:''~/.openclaw/agents/<agentId>/agent''(または ''agents.list[].agentDir'')

- セッション:''~/.openclaw/agents/<agentId>/sessions''

#

Tutorial.step

単一エージェントモード(デフォルト)

何もしない場合、OpenClaw は 1 つのエージェントを実行します:

- ''agentId'' はデフォルトで ''''main'''' です。

- セッションキーは ''agent:main:<mainKey>'' です。

- ワークスペースはデフォルトで ''~/.openclaw/workspace''(または ''OPENCLAW_PROFILE'' が設定されている場合は ''OPENCLAW_PROFILE'')です。

Tutorial.step

エージェントウィザード

エージェントウィザードを使用して、新しい分離されたエージェントを追加します:

Bash
openclaw agents add work

次に、''bindings'' を追加します(またはウィザードに実行させます)して、インバウンドメッセージをルーティングします。

Verify with:

Bash
openclaw agents list --bindings
Tutorial.step

複数のエージェント = 複数の人、複数のペルソナ

''複数のエージェント''を使用すると、各 ''agentId'' が''完全に分離されたペルソナ''になります:

- ''異なる電話番号/アカウント''(チャネルごとの ''accountId'')。

- ''異なるペルソナ''(エージェントごとのワークスペースファイル、例:''AGENTS.md'' および ''SOUL.md'')。

- 個別の認証 + セッション(明示的に有効にしない限り、クロストークは発生しません)。

これにより、複数の人がゲートウェイサーバーを共有しながら、AI の「脳」とデータを分離したままにすることができます。

Tutorial.step

1 つの WhatsApp 番号、複数の人(DM 分割)

''異なる WhatsApp DM''を''1 つの WhatsApp アカウント''に残しながら、異なるサポートエージェントにルーティングできます。送信者の E.164(例:''+15551234567'')を ''peer.kind: "dm"'' と一致させます。返信は引き続き同じ WhatsApp 番号から送信されます(エージェントごとの送信者 ID はありません)。

重要な詳細:直接チャットはエージェントのメインセッションキーに崩壊するため、真の分離には人ごとに 1 つのエージェントが必要です。

Example:

Json5
{
  agents: {
    list: [
      { id: "alex", workspace: "~/.openclaw/workspace-alex" },
      { id: "mia", workspace: "~/.openclaw/workspace-mia" },
    ],
  },
  bindings: [
    { agentId: "alex", match: { channel: "whatsapp", peer: { kind: "dm", id: "+15551230001" } } },
    { agentId: "mia", match: { channel: "whatsapp", peer: { kind: "dm", id: "+15551230002" } } },
  ],
  channels: {
    whatsapp: {
      dmPolicy: "allowlist",
      allowFrom: ["+15551230001", "+15551230002"],
    },
  },
}

Notes:

- DM アクセス制御はWhatsApp アカウントごと(ペアリング/許可リスト)であり、エージェントごとではありません。

- 共有グループの場合、グループを 1 つのエージェントにバインドするか、''ブロードキャストグループ''を使用します。

Tutorial.step

ルーティングルール(メッセージがエージェントを選択する方法)

バインディングは決定論的であり、最も具体的なものが勝ちます:

1. ''peer'' 一致(正確な DM/グループ/チャネル ID)

2. ''guildId''(Discord)

3. ''teamId''(Slack)

4. ''accountId'' がチャネルと一致

5. チャネルレベルの一致 (''accountId: "*"'')

Tutorial.step

複数のアカウント/電話番号

Channels that support ''multiple accounts'' (e.g. WhatsApp) use ''accountId'' to identify each login. Each ''accountId'' can be routed to a different agent, so one server can host multiple phone numbers without mixing sessions.

Each `accountId` can be routed to a different agent, so one server can

セッションを混ぜずに複数の電話番号をホストできます。

Tutorial.step

Concepts

- ''agentId'':「脳」(ワークスペース、エージェントごとの認証、エージェントごとのセッションストレージ)。

- ''accountId'':チャネルアカウントインスタンス(例:WhatsApp アカウント ''"personal"'' vs ''"biz"'')。

- ''binding'':''(channel, accountId, peer)'' およびオプションのギルド/チーム ID を介してインバウンドメッセージを ''(channel, accountId, peer)'' にルーティングします。

- 直接チャットは ''agent:<agentId>:<mainKey>'' に崩壊します(エージェントごとの「メイン」;''session.mainKey'')。

Tutorial.step

例:2 つの WhatsApp → 2 つのエージェント

''~/.openclaw/openclaw.json'' (JSON5):

Js
{
  agents: {
    list: [
      {
        id: "home",
        default: true,
        name: "Home",
        workspace: "~/.openclaw/workspace-home",
        agentDir: "~/.openclaw/agents/home/agent",
      },
      {
        id: "work",
        name: "Work",
        workspace: "~/.openclaw/workspace-work",
        agentDir: "~/.openclaw/agents/work/agent",
      },
    ],
  },

  // Deterministic routing: first match wins (most-specific first).
  bindings: [
    { agentId: "home", match: { channel: "whatsapp", accountId: "personal" } },
    { agentId: "work", match: { channel: "whatsapp", accountId: "biz" } },

    // Optional per-peer override (example: send a specific group to work agent).
    {
      agentId: "work",
      match: {
        channel: "whatsapp",
        accountId: "personal",
        peer: { kind: "group", id: "[email protected]" },
      },
    },
  ],

  // Off by default: agent-to-agent messaging must be explicitly enabled + allowlisted.
  tools: {
    agentToAgent: {
      enabled: false,
      allow: ["home", "work"],
    },
  },

  channels: {
    whatsapp: {
      accounts: {
        personal: {
          // Optional override. Default: ~/.openclaw/credentials/whatsapp/personal
          // authDir: "~/.openclaw/credentials/whatsapp/personal",
        },
        biz: {
          // Optional override. Default: ~/.openclaw/credentials/whatsapp/biz
          // authDir: "~/.openclaw/credentials/whatsapp/biz",
        },
      },
    },
  },
}
Tutorial.step

例:WhatsApp の日常チャット + Telegram のディープワーク

チャネルで分割:WhatsApp を高速な日常エージェントに、Telegram を Opus エージェントにルーティングします。

Json5
{
  agents: {
    list: [
      {
        id: "chat",
        name: "Everyday",
        workspace: "~/.openclaw/workspace-chat",
        model: "anthropic/claude-sonnet-4-5",
      },
      {
        id: "opus",
        name: "Deep Work",
        workspace: "~/.openclaw/workspace-opus",
        model: "anthropic/claude-opus-4-5",
      },
    ],
  },
  bindings: [
    { agentId: "chat", match: { channel: "whatsapp" } },
    { agentId: "opus", match: { channel: "telegram" } },
  ],
}

Notes:

- チャネルに複数のアカウントがある場合は、バインディングに accountId を追加します(例:'{ channel: "whatsapp", accountId: "personal" }')。

- チャットの残りを維持しながら、単一の DM/グループを Opus にルーティングするには、そのピアの ''match.peer'' バインディングを追加します。ピア一致は常にチャネル全体のルールより優先されます。

Tutorial.step

例:同じチャネル、Opus への 1 つのピア

WhatsApp を高速エージェントに残しながら、1 つの DM を Opus にルーティングします:

Json5
{
  agents: {
    list: [
      {
        id: "chat",
        name: "Everyday",
        workspace: "~/.openclaw/workspace-chat",
        model: "anthropic/claude-sonnet-4-5",
      },
      {
        id: "opus",
        name: "Deep Work",
        workspace: "~/.openclaw/workspace-opus",
        model: "anthropic/claude-opus-4-5",
      },
    ],
  },
  bindings: [
    { agentId: "opus", match: { channel: "whatsapp", peer: { kind: "dm", id: "+15551234567" } } },
    { agentId: "chat", match: { channel: "whatsapp" } },
  ],
}

ピアバインディングは常に勝つため、チャネル全体のルールの上に配置します。

Tutorial.step

WhatsApp グループにバインドされたファミリーエージェント

専用のファミリーエージェントを単一の WhatsApp グループにバインドし、メンションゲート

およびより厳格なツールポリシーを設定します:

Json5
{
  agents: {
    list: [
      {
        id: "family",
        name: "Family",
        workspace: "~/.openclaw/workspace-family",
        identity: { name: "Family Bot" },
        groupChat: {
          mentionPatterns: ["@family", "@familybot", "@Family Bot"],
        },
        sandbox: {
          mode: "all",
          scope: "agent",
        },
        tools: {
          allow: [
            "exec",
            "read",
            "sessions_list",
            "sessions_history",
            "sessions_send",
            "sessions_spawn",
            "session_status",
          ],
          deny: ["write", "edit", "apply_patch", "browser", "canvas", "nodes", "cron"],
        },
      },
    ],
  },
  bindings: [
    {
      agentId: "family",
      match: {
        channel: "whatsapp",
        peer: { kind: "group", id: "[email protected]" },
      },
    },
  ],
}

- Tool allow/deny lists are ''tools'', not skills. If a skill needs to run a binary, ensure ''exec'' is allowed and the binary exists in the sandbox.

- For stricter gating, set ''agents.list[].groupChat.mentionPatterns'' and keep group allowlists enabled for the channel.

Ensure binary exists, `exec` is allowed, and binary is present in sandbox.

- For stricter gates, set `agents.list[].groupChat.mentionPatterns` and

Tutorial.step

エージェントごとのサンドボックスとツール設定

v2026.1.6 以降、各エージェントは独自のサンドボックスとツール制限を持つことができます:

Js
{
  agents: {
    list: [
      {
        id: "personal",
        workspace: "~/.openclaw/workspace-personal",
        sandbox: {
          mode: "off",  // No sandbox for personal agent
        },
        // No tool restrictions - all tools available
      },
      {
        id: "family",
        workspace: "~/.openclaw/workspace-family",
        sandbox: {
          mode: "all",     // Always sandboxed
          scope: "agent",  // One container per agent
          docker: {
            // Optional one-time setup after container creation
            setupCommand: "apt-get update && apt-get install -y git curl",
          },
        },
        tools: {
          allow: ["read"],                    // Only read tool
          deny: ["exec", "write", "edit", "apply_patch"],    // Deny others
        },
      },
    ],
  },
}

注意:''setupCommand'' は ''sandbox.docker'' の下にあり、コンテナの作成時に 1 回実行されます。