GuideOpen

OpenClaw Multi-Agent Workspace Architecture

Understanding how workspaces, state directories, and sessions relate to each other in a multi-agent setup.

OpenClaw Multi-Agent Workspace Architecture

Understanding how workspaces, state directories, and sessions relate to each other in a multi-agent setup.

Directory Structure Overview

~/.openclaw/                              # State directory (OPENCLAW_STATE_DIR)
├── openclaw.json                         # Global config (agents, channels, bindings)
├── agents/
│   ├── main/                             # Default agent state
│   │   ├── agent/
│   │   │   └── auth-profiles.json        # Agent-specific credentials
│   │   └── sessions/                     # Chat history + routing state
│   │
│   ├── content/                          # Second agent state
│   │   ├── agent/
│   │   │   └── auth-profiles.json
│   │   └── sessions/
│   │
│   └── alerts/                           # Third agent state
│       ├── agent/
│       └── sessions/
│
├── skills/                               # GLOBAL skills (shared by ALL agents)
│   └── shared-skill/
│       └── SKILL.md
│
└── workspace/                            # Default workspace (main agent)
    ├── AGENTS.md
    ├── SOUL.md
    └── skills/                           # Main agent's local skills

~/.openclaw/workspace-content/            # Content agent workspace
├── AGENTS.md                             # Content agent instructions
├── SOUL.md                               # Content agent personality
├── IDENTITY.md                           # Content agent visual identity
├── USER.md                               # User context for content agent
└── skills/                               # Content agent's local skills
    └── video-scripts/
        └── SKILL.md

Key Concepts

Workspace vs. State Directory

ConceptPathContainsScope
WorkspaceCustom per agentAGENTS.md, SOUL.md, skills/, user filesDefines agent persona and capabilities
State dir (agentDir)~/.openclaw/agents/<id>/agentAuth profiles, model registryStores runtime state and credentials
Session store~/.openclaw/agents/<id>/sessionsChat history, routing statePer-agent conversation memory
Global config~/.openclaw/openclaw.jsonAgent list, channels, bindingsShared across all agents

Workspace Files

FilePurposeRequired?
AGENTS.mdCore instructions, behavior rules, goalsRecommended
SOUL.mdPersonality, tone, communication styleOptional
IDENTITY.mdName, emoji, avatar for Control UIOptional
USER.mdInformation about the owner/userOptional
skills/Agent-specific skill foldersOptional

Credential Isolation

Credentials are never shared automatically between agents. Each agent's auth-profiles.json is isolated in its own agentDir.

If you intentionally want to share credentials between agents, manually copy the auth profiles:

cp ~/.openclaw/agents/main/agent/auth-profiles.json \
   ~/.openclaw/agents/content/agent/auth-profiles.json

Skill Discovery

Skills are discovered from two locations:

  1. Global skills (~/.openclaw/skills/) - available to ALL agents
  2. Workspace skills (<workspace>/skills/) - only for that specific agent

Strategy:

  • Put general-purpose skills (GitHub, Apple Notes, etc.) in global
  • Put agent-specific skills (content creation, community management) in workspace

Session Isolation

Each agent has a completely separate session store. Sessions are keyed as agent:<agentId>:<mainKey>.

This means:

  • Chat history is per-agent
  • Context does not leak between agents
  • Each agent maintains its own conversation thread per peer

Common Workspace Patterns

Pattern 1: Separate Directories (Recommended)

Each agent gets its own workspace directory:

~/.openclaw/workspace/              # main agent
~/.openclaw/workspace-content/      # content agent
~/.openclaw/workspace-alerts/       # alerts agent

Pros: Clean isolation, no file conflicts Cons: Skills must be duplicated or use global

Pattern 2: Shared Workspace

Multiple agents share the same workspace:

{
  "agents": {
    "list": [
      { "id": "main", "workspace": "~/my-workspace" },
      { "id": "helper", "workspace": "~/my-workspace" }
    ]
  }
}

Pros: Shared AGENTS.md, skills, files Cons: No persona isolation, agents see each other's files

Pattern 3: Nested Agent Workspaces

Agent workspaces inside a parent directory:

~/agents/
├── shared/                    # Symlinked into each workspace
│   ├── MEMORY.md
│   └── memory/
├── content/
│   ├── AGENTS.md
│   ├── SOUL.md
│   ├── MEMORY.md -> ../shared/MEMORY.md
│   └── skills/
└── alerts/
    ├── AGENTS.md
    ├── SOUL.md
    ├── MEMORY.md -> ../shared/MEMORY.md
    └── skills/

Pros: Shared memory layer, isolated personas Cons: Symlinks add complexity

Environment Variable Overrides

VariableDefaultPurpose
OPENCLAW_STATE_DIR~/.openclawOverride state directory
OPENCLAW_CONFIG_PATH~/.openclaw/openclaw.jsonOverride config path

Use these to run completely separate OpenClaw instances:

OPENCLAW_STATE_DIR=~/.openclaw-dev \
OPENCLAW_CONFIG_PATH=~/.openclaw-dev/openclaw.json \
openclaw gateway start

Sandbox Configuration

For agents that need security isolation, enable per-agent sandboxing:

{
  "agents": {
    "list": [
      {
        "id": "untrusted",
        "sandbox": {
          "mode": "all",
          "scope": "agent",
          "docker": {
            "setupCommand": "apt-get update && apt-get install -y git"
          }
        },
        "tools": {
          "allow": ["read", "exec"],
          "deny": ["write", "edit", "browser"]
        }
      }
    ]
  }
}

Sandbox modes:

  • "off" - no sandboxing (default)
  • "non-main" - sandbox subagents only
  • "all" - sandbox everything

Scope:

  • "session" - one container per session
  • "agent" - one container per agent

Source: written by One Giant Leap.

Related entries

There are more like this in the members library

The Claude Code library holds 13,843 entries. Members can search all of them by meaning and read every one in full.