OpenClaw v2026.2 対応 | 本稿はチーム利用やコンテキスト分離が必要なユーザーに適しています。
TL;DR: マルチ Agent 設定:"agents": {"instances": {"personal": {...}, "work": {...}}}。ルーティングルール:"routing": {"rules": [{"match": {"channel": "telegram"}, "agent": "personal"}]}。セッション分離:"sessions": {"isolation": "user"}。サンドボックスモード:"sandbox": {"mode": "non-main"}。マルチユーザー、マルチプロジェクト、マルチ用途のシナリオに適しています。
なぜマルチ Agent が必要か?
単一 Agent の限界
| シナリオ | 単一 Agent の問題 | マルチ Agent の解決策 |
|---|---|---|
| マルチユーザー | コンテキストの混乱、プライバシー問題 | ユーザーごとに独立した Agent |
| マルチプロジェクト | プロジェクト情報が混在 | プロジェクトごとに独立した Agent |
| マルチ用途 | 1つの Agent が複数の役割 | 専門化された Agent |
| マルチチーム | 権限の制御が困難 | チーム別に Agent を分離 |
| コスト管理 | 使用量の区別ができない | モデルごとに個別計費 |
マルチ Agent の使用シナリオ
flowchart TB
subgraph Users["ユーザー"]
U1[ユーザーA]
U2[ユーザーB]
U3[チームX]
U4[チームY]
end
subgraph Router["メッセージルーティング"]
R[ルーティングルール]
end
subgraph Agents["Agent インスタンス"]
A1[個人Agent A]
A2[個人Agent B]
A3[チームAgent X]
A4[チームAgent Y]
end
subgraph Models["モデル"]
M1[Claude Opus]
M2[Claude Sonnet]
M3[GPT-4o]
M4[Haiku]
end
U1 --> R
U2 --> R
U3 --> R
U4 --> R
R --> A1
R --> A2
R --> A3
R --> A4
A1 --> M1
A2 --> M2
A3 --> M3
A4 --> M4
マルチ Agent 設定
基本構造
{
"agents": {
"defaults": {
"model": "anthropic/claude-sonnet-4",
"workspace": "~/.openclaw/workspace"
},
"instances": {
"personal": {
"model": "anthropic/claude-opus-4-6",
"workspace": "~/.openclaw/workspaces/personal",
"thinkingLevel": "high"
},
"work": {
"model": "anthropic/claude-sonnet-4",
"workspace": "~/.openclaw/workspaces/work",
"skills": ["github", "jira", "confluence"]
},
"assistant": {
"model": "anthropic/claude-haiku-3.5",
"workspace": "~/.openclaw/workspaces/assistant"
}
}
}
}
Agent 設定項目
| 設定項目 | 説明 | 例 |
|---|---|---|
model |
使用するモデル | anthropic/claude-opus-4-6 |
workspace |
作業ディレクトリ | ~/.openclaw/workspaces/personal |
thinkingLevel |
思考レベル | high, medium, low |
skills |
有効なスキル | ["gmail", "calendar"] |
sandbox |
サンドボックス設定 | { "mode": "non-main" } |
contextWindow |
コンテキストウィンドウ | 200000 |
Workspace 構造
~/.openclaw/
├── workspace/ # デフォルト workspace
│ ├── AGENTS.md
│ ├── SOUL.md
│ └── skills/
├── workspaces/
│ ├── personal/ # 個人 Agent
│ │ ├── AGENTS.md
│ │ ├── SOUL.md
│ │ └── USER.md
│ ├── work/ # 仕事用 Agent
│ │ ├── AGENTS.md
│ │ └── skills/
│ └── assistant/ # アシスタント Agent
│ └── AGENTS.md
└── openclaw.json # メイン設定
メッセージルーティングルール
ルーティング設定
{
"routing": {
"rules": [
{
"match": {
"channel": "telegram",
"sender": "123456789"
},
"agent": "personal"
},
{
"match": {
"channel": "discord",
"guild": "987654321"
},
"agent": "work"
},
{
"match": {
"session": "main"
},
"agent": "personal"
}
],
"default": "personal"
}
}
ルーティングルールの詳細
| マッチフィールド | 説明 | 例 |
|---|---|---|
channel |
チャネルタイプ | telegram, discord, slack |
sender |
送信者 ID | 123456789 |
guild |
Discord サーバー ID | 987654321 |
group |
グループ ID | -100123456789 |
session |
セッション ID | main, telegram:user:123 |
pattern |
正規表現マッチ | ^work- |
複雑なルーティング例
{
"routing": {
"rules": [
{
"name": "個人 Telegram",
"match": {
"channel": "telegram",
"sender": ["123456789", "987654321"]
},
"agent": "personal"
},
{
"name": "仕事用 Discord",
"match": {
"channel": "discord",
"guild": "111222333"
},
"agent": "work"
},
{
"name": "仕事用グループ",
"match": {
"channel": "telegram",
"group": "-100111222333"
},
"agent": "work"
},
{
"name": "テスト環境",
"match": {
"pattern": "^test-"
},
"agent": "assistant",
"config": {
"sandbox": { "mode": "always" }
}
}
],
"default": "personal"
}
}
ルーティング優先度
flowchart TB
MSG[メッセージ到着] --> R1{ルール 1 にマッチ?}
R1 -->|はい| A1[Agent 1]
R1 -->|いいえ| R2{ルール 2 にマッチ?}
R2 -->|はい| A2[Agent 2]
R2 -->|いいえ| R3{ルール 3 にマッチ?}
R3 -->|はい| A3[Agent 3]
R3 -->|いいえ| D[デフォルト Agent]
ルーティングは順番にマッチし、最初にマッチしたルールが適用されます。
セッション分離
分離レベル
| レベル | 説明 | 使用シナリオ |
|---|---|---|
| 分離なし | コンテキストを共有 | 単一ユーザー、単一用途 |
| チャネル分離 | チャネルごとに独立コンテキスト | マルチチャネル接続 |
| ユーザー分離 | ユーザーごとに独立コンテキスト | マルチユーザー共有 |
| セッション分離 | 各セッションが独立 | 完全分離 |
| Agent 分離 | 各 Agent が独立 | マルチ Agent デプロイ |
セッション分離の設定
{
"sessions": {
"isolation": "user",
"persistence": true,
"retention": {
"maxAge": 604800000,
"maxSessions": 100
}
}
}
分離設定の詳細
{
"sessions": {
"isolation": "user",
"storage": {
"type": "file",
"path": "~/.openclaw/sessions"
},
"encryption": {
"enabled": true,
"algorithm": "aes-256-gcm"
},
"retention": {
"maxAge": 604800000,
"maxSessions": 100,
"cleanupInterval": 86400000
}
}
}
| 設定項目 | 説明 | デフォルト値 |
|---|---|---|
isolation |
分離レベル | user |
storage.type |
ストレージタイプ | file |
encryption.enabled |
暗号化を有効化 | true |
retention.maxAge |
最大保持期間 | 7日 |
retention.maxSessions |
最大セッション数 | 100 |
チームコラボレーションシナリオ
シナリオ1:小規模チーム共有
{
"agents": {
"instances": {
"team": {
"model": "anthropic/claude-sonnet-4",
"workspace": "~/.openclaw/workspaces/team",
"skills": ["github", "jira", "slack"]
}
}
},
"routing": {
"rules": [
{
"match": { "channel": "slack" },
"agent": "team"
},
{
"match": { "channel": "discord" },
"agent": "team"
}
],
"default": "team"
}
}
シナリオ2:部門分離
{
"agents": {
"instances": {
"engineering": {
"model": "anthropic/claude-opus-4-6",
"workspace": "~/.openclaw/workspaces/engineering",
"skills": ["github", "jira", "pagerduty"],
"sandbox": { "mode": "off" }
},
"marketing": {
"model": "anthropic/claude-sonnet-4",
"workspace": "~/.openclaw/workspaces/marketing",
"skills": ["mailchimp", "analytics"],
"sandbox": { "mode": "non-main" }
},
"support": {
"model": "anthropic/claude-haiku-3.5",
"workspace": "~/.openclaw/workspaces/support",
"skills": ["zendesk", "intercom"],
"sandbox": { "mode": "always" }
}
}
},
"routing": {
"rules": [
{
"name": "Engineering Discord",
"match": { "channel": "discord", "guild": "111111111" },
"agent": "engineering"
},
{
"name": "Marketing Slack",
"match": { "channel": "slack", "team": "T22222222" },
"agent": "marketing"
},
{
"name": "Support Telegram",
"match": { "channel": "telegram", "group": "-100333333333" },
"agent": "support"
}
],
"default": "support"
}
}
シナリオ3:マルチテナント SaaS
{
"agents": {
"dynamic": true,
"template": {
"model": "anthropic/claude-sonnet-4",
"workspace": "~/.openclaw/workspaces/tenants/{{tenantId}}",
"skills": ["base"],
"sandbox": { "mode": "always" }
},
"limits": {
"maxAgents": 100,
"maxSessionsPerAgent": 50,
"maxTokensPerMonth": 1000000
}
},
"routing": {
"rules": [
{
"name": "Tenant Routing",
"match": { "header": "X-Tenant-Id" },
"agent": "tenant_{{tenantId}}",
"createIfNotExists": true
}
]
}
}
権限とセキュリティ
Agent 権限制御
{
"agents": {
"instances": {
"trusted": {
"model": "anthropic/claude-opus-4-6",
"sandbox": { "mode": "off" },
"permissions": {
"filesystem": { "read": true, "write": true },
"network": { "outbound": true },
"process": { "execute": true }
}
},
"restricted": {
"model": "anthropic/claude-haiku-3.5",
"sandbox": { "mode": "always" },
"permissions": {
"filesystem": {
"read": ["~/allowed/"],
"write": ["~/allowed/"]
},
"network": {
"outbound": ["api.example.com"]
},
"process": { "execute": false }
}
}
}
}
}
サンドボックスモード
| モード | 説明 | 適用シナリオ |
|---|---|---|
off |
サンドボックスなし | 信頼できる Agent |
non-main |
メイン以外のセッションでサンドボックス | チーム共有 |
always |
常にサンドボックス | 信頼できない環境 |
サンドボックス設定
{
"sandbox": {
"mode": "non-main",
"container": {
"image": "openclaw/sandbox:latest",
"timeout": 30000,
"memory": "512m",
"cpu": "0.5"
},
"allowlist": ["read", "write", "edit", "bash"],
"denylist": ["browser", "canvas", "nodes"],
"networkPolicy": {
"allow": ["api.example.com"],
"deny": ["*"]
}
}
}
監視と管理
Agent 状態の監視
# すべての Agent インスタンスを一覧表示
openclaw agents list
# 出力例:
# Name Model Sessions Status Last Active
# personal claude-opus-4-6 3 active 2 min ago
# work claude-sonnet-4 5 active 5 min ago
# assistant claude-haiku-3.5 2 idle 1 hour ago
# Agent の詳細を確認
openclaw agents show personal
# ルーティングルールを確認
openclaw routing list
セッション管理
# すべてのセッションを一覧表示
openclaw sessions list --agent personal
# 出力例:
# Session ID Channel Sender Created Messages
# telegram:user:123 telegram 123456789 2026-02-26 42
# main cli - 2026-02-25 128
# セッションの詳細を確認
openclaw sessions show telegram:user:123
# セッションをエクスポート
openclaw sessions export telegram:user:123 --format json
# セッションを削除
openclaw sessions delete telegram:user:123
使用量統計
# Agent 別の使用量を確認
openclaw usage --by-agent
# 出力例:
# Agent Tokens In Tokens Out Cost Requests
# personal 125,000 45,000 $2.10 128
# work 89,000 32,000 $1.25 95
# assistant 15,000 8,000 $0.15 42
# 期間指定で統計
openclaw usage --by-agent --from 2026-02-01 --to 2026-02-28
ベストプラクティス
1. 適切な Agent の分割
| 分割軸 | 説明 | 例 |
|---|---|---|
| 用途 | 機能用途で分割 | coding, research, assistant |
| プロジェクト | プロジェクトで分割 | project-alpha, project-beta |
| チーム | チームで分割 | engineering, marketing |
| モデル | モデルで分割 | opus, sonnet, haiku |
2. 設定の継承
{
"agents": {
"defaults": {
"model": "anthropic/claude-sonnet-4",
"workspace": "~/.openclaw/workspace",
"thinkingLevel": "medium",
"sandbox": { "mode": "non-main" }
},
"instances": {
"opus": {
"model": "anthropic/claude-opus-4-6",
"thinkingLevel": "high"
// defaults の workspace と sandbox を継承
},
"haiku": {
"model": "anthropic/claude-haiku-3.5",
"thinkingLevel": "minimal"
// defaults のその他の設定を継承
}
}
}
}
3. 最小権限の原則
{
"agents": {
"instances": {
"restricted": {
"model": "anthropic/claude-haiku-3.5",
"sandbox": { "mode": "always" },
"permissions": {
"filesystem": {
"read": ["~/allowed/read"],
"write": ["~/allowed/write"]
},
"network": {
"outbound": []
},
"process": {
"execute": false
}
}
}
}
}
}
4. 監視とアラート
{
"monitoring": {
"alerts": [
{
"condition": "usage > 1000000",
"action": "notify"
},
{
"condition": "error_rate > 0.1",
"action": "notify"
},
{
"condition": "response_time > 10000",
"action": "notify"
}
],
"webhook": "https://your-monitoring.com/webhook"
}
}
トラブルシューティング
ルーティングが効かない
# 現在のルーティングルールを確認
openclaw routing list
# ルーティングをテスト
openclaw routing test --channel telegram --sender 123456789
# 出力例:
# Matched Rule: 個人 Telegram
# Target Agent: personal
# Route Path: default -> rule 1 -> personal
セッション分離の問題
# セッション分離設定を確認
openclaw config get sessions.isolation
# セッション一覧を確認
openclaw sessions list --all
# セッション分離をリセット
openclaw sessions reset --agent personal
権限の問題
# 権限設定を確認
openclaw agents permissions show personal
# 権限をテスト
openclaw agents test-permission personal --action filesystem.read --path ~/test
# 出力例:
# Permission: filesystem.read
# Path: ~/test
# Result: ALLOWED
まとめ
マルチ Agent アーキテクチャは OpenClaw の高度な機能で、チームやエンタープライズシナリオに強力なサポートを提供します:
- 柔軟なルーティング:チャネル、ユーザー、プロジェクトに応じて異なる Agent を割り当て
- セッション分離:プライバシーを保護し、コンテキストの混乱を回避
- 権限制御:きめ細かい権限管理
- コスト最適化:用途に応じて異なるモデルを選択
- 拡張性:動的な Agent の作成と管理をサポート
本稿のまとめ:
- マルチ Agent アーキテクチャの価値とシナリオを理解した
- Agent 設定とメッセージルーティングルールを習得した
- セッション分離の設定方法を学んだ
- チームコラボレーションシナリオのベストプラクティスを理解した
- 権限制御と監視管理を習得した
更新履歴:
- 2026-02-26:初版リリース、OpenClaw v2026.2 ベース
シリーズナビゲーション:
- ← 前の記事:Web Control UI と Canvas
- → 次の記事:セキュリティ設定ベストプラクティス