멀티 에이전트 샌드박스 & 도구 설정

개요

멀티 에이전트 환경에서 각 에이전트는 고유한 설정을 가질 수 있습니다:

  • 샌드박스 설정 (agents.list[].sandboxagents.defaults.sandbox를 재정의)
  • 도구 제한 (tools.allow / tools.deny + agents.list[].tools)

이를 통해 서로 다른 보안 프로파일로 여러 에이전트를 운영할 수 있습니다:

  • 전체 접근 권한을 가진 개인 어시스턴트
  • 제한된 도구를 가진 가족/업무 에이전트
  • 샌드박스에서 실행되는 공개용 에이전트

setupCommandsandbox.docker(전역 또는 에이전트별) 아래에 위치하며 컨테이너 생성 시 한 번 실행됩니다.

인증은 에이전트별입니다: 각 에이전트는 자신의 agentDir 인증 저장소에서 읽습니다:

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

인증 정보는 에이전트 간에 공유되지 않습니다. agentDir을 에이전트 간에 재사용하지 마세요. 인증 정보를 공유하려면 auth-profiles.json을 다른 에이전트의 agentDir에 복사하세요.

런타임에서의 샌드박스 동작은 샌드박스를 참고하세요. “왜 차단되나?”를 디버깅하려면 샌드박스 vs 도구 정책 vs 관리자 모드openclaw sandbox explain을 참고하세요.


설정 예시

예시 1: 개인 + 제한된 가족 에이전트

{
  "agents": {
    "list": [
      {
        "id": "main",
        "default": true,
        "name": "Personal Assistant",
        "workspace": "~/.openclaw/workspace",
        "sandbox": { "mode": "off" }
      },
      {
        "id": "family",
        "name": "Family Bot",
        "workspace": "~/.openclaw/workspace-family",
        "sandbox": {
          "mode": "all",
          "scope": "agent"
        },
        "tools": {
          "allow": ["read"],
          "deny": ["exec", "write", "edit", "apply_patch", "process", "browser"]
        }
      }
    ]
  },
  "bindings": [
    {
      "agentId": "family",
      "match": {
        "provider": "whatsapp",
        "accountId": "*",
        "peer": {
          "kind": "group",
          "id": "[email protected]"
        }
      }
    }
  ]
}

결과:

  • main 에이전트: 호스트에서 실행, 전체 도구 접근
  • family 에이전트: Docker에서 실행 (에이전트당 하나의 컨테이너), read 도구만 사용

예시 2: 공유 샌드박스를 사용하는 업무 에이전트

{
  "agents": {
    "list": [
      {
        "id": "personal",
        "workspace": "~/.openclaw/workspace-personal",
        "sandbox": { "mode": "off" }
      },
      {
        "id": "work",
        "workspace": "~/.openclaw/workspace-work",
        "sandbox": {
          "mode": "all",
          "scope": "shared",
          "workspaceRoot": "/tmp/work-sandboxes"
        },
        "tools": {
          "allow": ["read", "write", "apply_patch", "exec"],
          "deny": ["browser", "gateway", "discord"]
        }
      }
    ]
  }
}

예시 2b: 전역 코딩 프로파일 + 메시징 전용 에이전트

{
  "tools": { "profile": "coding" },
  "agents": {
    "list": [
      {
        "id": "support",
        "tools": { "profile": "messaging", "allow": ["slack"] }
      }
    ]
  }
}

결과:

  • 기본 에이전트는 코딩 도구를 사용
  • support 에이전트는 메시징 전용 (+ Slack 도구)

예시 3: 에이전트별 다른 샌드박스 모드

{
  "agents": {
    "defaults": {
      "sandbox": {
        "mode": "non-main", // Global default
        "scope": "session"
      }
    },
    "list": [
      {
        "id": "main",
        "workspace": "~/.openclaw/workspace",
        "sandbox": {
          "mode": "off" // Override: main never sandboxed
        }
      },
      {
        "id": "public",
        "workspace": "~/.openclaw/workspace-public",
        "sandbox": {
          "mode": "all", // Override: public always sandboxed
          "scope": "agent"
        },
        "tools": {
          "allow": ["read"],
          "deny": ["exec", "write", "edit", "apply_patch"]
        }
      }
    ]
  }
}

설정 우선순위

전역(agents.defaults.*)과 에이전트별(agents.list[].*) 설정이 모두 있는 경우:

샌드박스 설정

에이전트별 설정이 전역을 재정의합니다:

agents.list[].sandbox.mode > agents.defaults.sandbox.mode
agents.list[].sandbox.scope > agents.defaults.sandbox.scope
agents.list[].sandbox.workspaceRoot > agents.defaults.sandbox.workspaceRoot
agents.list[].sandbox.workspaceAccess > agents.defaults.sandbox.workspaceAccess
agents.list[].sandbox.docker.* > agents.defaults.sandbox.docker.*
agents.list[].sandbox.browser.* > agents.defaults.sandbox.browser.*
agents.list[].sandbox.prune.* > agents.defaults.sandbox.prune.*

참고:

  • agents.list[].sandbox.{docker,browser,prune}.*는 해당 에이전트의 agents.defaults.sandbox.{docker,browser,prune}.*를 재정의합니다(샌드박스 범위가 "shared"로 해석되면 무시됨).

도구 제한

필터링 순서:

  1. 도구 프로파일 (tools.profile 또는 agents.list[].tools.profile)
  2. 프로바이더 도구 프로파일 (tools.byProvider[provider].profile 또는 agents.list[].tools.byProvider[provider].profile)
  3. 전역 도구 정책 (tools.allow / tools.deny)
  4. 프로바이더 도구 정책 (tools.byProvider[provider].allow/deny)
  5. 에이전트별 도구 정책 (agents.list[].tools.allow/deny)
  6. 에이전트 프로바이더 정책 (agents.list[].tools.byProvider[provider].allow/deny)
  7. 샌드박스 도구 정책 (tools.sandbox.tools 또는 agents.list[].tools.sandbox.tools)
  8. 서브에이전트 도구 정책 (tools.subagents.tools, 해당하는 경우)

각 레벨은 도구를 추가로 제한할 수만 있으며, 이전 레벨에서 거부된 도구를 다시 허용할 수 없습니다. agents.list[].tools.sandbox.tools가 설정되면 해당 에이전트의 tools.sandbox.tools를 대체합니다. agents.list[].tools.profile이 설정되면 해당 에이전트의 tools.profile을 재정의합니다. 프로바이더 도구 키는 provider(예: google-antigravity) 또는 provider/model(예: openai/gpt-5.2) 형식을 지원합니다.

도구 그룹 (단축 표현)

도구 정책(전역, 에이전트, 샌드박스)은 여러 구체적인 도구로 확장되는 group:* 항목을 지원합니다:

  • group:runtime: exec, bash, process
  • group:fs: read, write, edit, apply_patch
  • group:sessions: sessions_list, sessions_history, sessions_send, sessions_spawn, session_status
  • group:memory: memory_search, memory_get
  • group:ui: browser, canvas
  • group:automation: cron, gateway
  • group:messaging: message
  • group:nodes: nodes
  • group:openclaw: 모든 OpenClaw 내장 도구 (프로바이더 플러그인 제외)

관리자 모드

tools.elevated는 전역 기준선(발신자 기반 허용 목록)입니다. agents.list[].tools.elevated는 특정 에이전트에 대해 관리자 모드를 추가로 제한할 수 있습니다(둘 다 허용해야 함).

완화 패턴:

  • 신뢰할 수 없는 에이전트에 대해 exec 거부 (agents.list[].tools.deny: ["exec"])
  • 제한된 에이전트로 라우팅되는 발신자를 허용 목록에 넣지 마세요
  • 샌드박스 실행만 원하면 관리자 모드를 전역으로 비활성화 (tools.elevated.enabled: false)
  • 민감한 프로파일에는 에이전트별로 관리자 모드 비활성화 (agents.list[].tools.elevated.enabled: false)

단일 에이전트에서 마이그레이션

이전 (단일 에이전트):

{
  "agents": {
    "defaults": {
      "workspace": "~/.openclaw/workspace",
      "sandbox": {
        "mode": "non-main"
      }
    }
  },
  "tools": {
    "sandbox": {
      "tools": {
        "allow": ["read", "write", "apply_patch", "exec"],
        "deny": []
      }
    }
  }
}

이후 (다른 프로파일을 가진 멀티 에이전트):

{
  "agents": {
    "list": [
      {
        "id": "main",
        "default": true,
        "workspace": "~/.openclaw/workspace",
        "sandbox": { "mode": "off" }
      }
    ]
  }
}

레거시 agent.* 설정은 openclaw doctor가 마이그레이션합니다. 앞으로는 agents.defaults + agents.list를 사용하세요.


도구 제한 예시

읽기 전용 에이전트

{
  "tools": {
    "allow": ["read"],
    "deny": ["exec", "write", "edit", "apply_patch", "process"]
  }
}

안전한 실행 에이전트 (파일 수정 없음)

{
  "tools": {
    "allow": ["read", "exec", "process"],
    "deny": ["write", "edit", "apply_patch", "browser", "gateway"]
  }
}

통신 전용 에이전트

{
  "tools": {
    "sessions": { "visibility": "tree" },
    "allow": ["sessions_list", "sessions_send", "sessions_history", "session_status"],
    "deny": ["exec", "write", "edit", "apply_patch", "read", "browser"]
  }
}

흔한 함정: “non-main”

agents.defaults.sandbox.mode: "non-main"은 에이전트 ID가 아닌 session.mainKey(기본값 "main")를 기준으로 합니다. 그룹/채널 세션은 항상 고유한 키를 가지므로 non-main으로 처리되어 샌드박스됩니다. 에이전트가 절대 샌드박스되지 않도록 하려면 agents.list[].sandbox.mode: "off"를 설정하세요.


테스트

멀티 에이전트 샌드박스와 도구를 설정한 후:

  1. 에이전트 해석 확인:

    openclaw agents list --bindings
  2. 샌드박스 컨테이너 확인:

    docker ps --filter "name=openclaw-sbx-"
  3. 도구 제한 테스트:

    • 제한된 도구를 필요로 하는 메시지를 전송
    • 에이전트가 거부된 도구를 사용할 수 없는지 확인
  4. 로그 모니터링:

    tail -f "${OPENCLAW_STATE_DIR:-$HOME/.openclaw}/logs/gateway.log" | grep -E "routing|sandbox|tools"

문제 해결

mode: "all"인데도 에이전트가 샌드박스되지 않음

  • 이를 재정의하는 전역 agents.defaults.sandbox.mode가 있는지 확인
  • 에이전트별 설정이 우선하므로 agents.list[].sandbox.mode: "all"을 설정

deny 목록에도 도구 사용 가능

  • 도구 필터링 순서를 확인: 전역 → 에이전트 → 샌드박스 → 서브에이전트
  • 각 레벨은 추가 제한만 가능하며 다시 허용할 수 없음
  • 로그로 확인: [tools] filtering tools for agent:${agentId}

에이전트별 컨테이너 격리 안 됨

  • 에이전트별 샌드박스 설정에서 scope: "agent" 설정
  • 기본값은 "session"으로 세션당 하나의 컨테이너 생성

관련 문서