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.mdKey Concepts
Workspace vs. State Directory
| Concept | Path | Contains | Scope |
|---|---|---|---|
| Workspace | Custom per agent | AGENTS.md, SOUL.md, skills/, user files | Defines agent persona and capabilities |
State dir (agentDir) | ~/.openclaw/agents/<id>/agent | Auth profiles, model registry | Stores runtime state and credentials |
| Session store | ~/.openclaw/agents/<id>/sessions | Chat history, routing state | Per-agent conversation memory |
| Global config | ~/.openclaw/openclaw.json | Agent list, channels, bindings | Shared across all agents |
Workspace Files
| File | Purpose | Required? |
|---|---|---|
AGENTS.md | Core instructions, behavior rules, goals | Recommended |
SOUL.md | Personality, tone, communication style | Optional |
IDENTITY.md | Name, emoji, avatar for Control UI | Optional |
USER.md | Information about the owner/user | Optional |
skills/ | Agent-specific skill folders | Optional |
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.jsonSkill Discovery
Skills are discovered from two locations:
- Global skills (
~/.openclaw/skills/) - available to ALL agents - 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 agentPros: 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
| Variable | Default | Purpose |
|---|---|---|
OPENCLAW_STATE_DIR | ~/.openclaw | Override state directory |
OPENCLAW_CONFIG_PATH | ~/.openclaw/openclaw.json | Override config path |
Use these to run completely separate OpenClaw instances:
OPENCLAW_STATE_DIR=~/.openclaw-dev \
OPENCLAW_CONFIG_PATH=~/.openclaw-dev/openclaw.json \
openclaw gateway startSandbox 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
- Managed Agents - Core Concepts (shared) (Anthropic skills)
- Managed Agents - Scheduled Deployments
- OpenClaw Skills Guide - Install & Use Agent Skills (2026)
- Architecture
- Managed Agents - Overview (shared) (Claude Code templates (davila7))
- Managed Agents - Core Concepts (shared) (Claude Code templates (davila7))
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.