skip to content

In OpenClaw, what does each agent on a multi-agent Gateway own separately, and what does it still share?

level: juniorimportance: should knowfreq 11%

answer

  1. three per-agent pieces
  2. persona files live in the workspace
  3. agentDir holds auth and models
  4. one SQLite session store each
  5. workspace is a cwd, not a jail

basics

~20 s

Each OpenClaw agent owns a workspace (AGENTS.md, SOUL.md, notes), an agentDir with its auth profiles and model registry, and its own session store. It still shares the Gateway process, channel access policy and, by default, session-tool reach.

solid answer

~30 s

An OpenClaw agent is one isolated "brain" inside the single Gateway. It owns a **workspace** (`AGENTS.md`, `SOUL.md`, `USER.md`, notes and persona rules), a **state directory** `agentDir` (by default `~/.openclaw/agents/<agentId>/agent`) with its auth profiles and model registry, and its own session history in `<agentDir>/openclaw-agent.sqlite`. With nothing configured you get one agent, `main`, working in `~/.openclaw/workspace`. What is not split per agent: the Gateway process, DM access rules (pairing and allowlists sit on the channel account), and session tools, because `tools.sessions.visibility` defaults to `all`, so an unsandboxed agent can read other agents' sessions. The workspace is the default working directory, not a sandbox.

go deeper

for a junior

Recall the three per-agent pieces: workspace, agentDir and session store, plus the default agent id main and its workspace path.

for a middle

Explain where each piece lives by default, how auth read-through to the default agent works, and why agentDir must never be shared between agents.

for a senior

Show where isolation stops: the workspace is only a working directory, and session tools reach every agent until tools.sessions.visibility or tools.agentToAgent is narrowed.

for a principal

Frame agents as state separation inside one trust boundary, and say when that is enough and when personas with different trust levels need narrowed session tools or a separate Gateway.

## What an agent is in OpenClaw OpenClaw runs one **Gateway** process that owns every channel connection. Inside it, an **agent** is the unit of persona and state; the docs call it one "brain". A Gateway with nothing configured runs a single agent whose id is `main`. Adding entries under `agents.entries` in `~/.openclaw/openclaw.json` gives you several, and **bindings** then decide which agent answers each inbound message. This question is only about what each of those agents owns and where that ownership ends. ## The three pieces every agent owns | Piece | Default location | What lives there | |---|---|---| | **Workspace** | `~/.openclaw/workspace` for the default agent, `~/.openclaw/workspace-<agentId>` for others | `AGENTS.md`, `SOUL.md`, `USER.md`, local notes, persona rules | | **State directory** (`agentDir`) | `~/.openclaw/agents/<agentId>/agent` | auth profiles, model registry, per-agent config | | **Session store** | `<agentDir>/openclaw-agent.sqlite` | chat history and routing state | Each of these can be moved per agent with `agents.entries.<id>.workspace` and `agents.entries.<id>.agentDir`. What that separation buys you: - **Persona.** Because `SOUL.md` and `AGENTS.md` are read from the agent's own workspace, a terse coding agent and a friendly household agent can behave completely differently on the same machine. - **Credentials.** Each agent reads auth profiles from its own store. When a secondary agent has no local profile, or its OAuth credential has expired, OpenClaw reads through to the default agent's credential for the same profile id, without copying the refresh token into the secondary store. Sign in from that agent if it needs a fully independent account. - **History.** By default, direct chats collapse to the agent's own main session key, `agent:<agentId>:main`, and each agent's history is kept in its own store. - **Model and skills.** An entry can set its own `model`, and `agents.entries.<id>.skills` replaces the shared `agents.defaults.skills` list rather than merging with it. ## The default single-agent layout If you configure nothing, the defaults are: - agent id `main`, with main session key `agent:main:main`; - workspace `~/.openclaw/workspace` (or `~/.openclaw-<profile>/workspace` under a named profile); - state directory `~/.openclaw/agents/main/agent`; - sessions in that directory's `openclaw-agent.sqlite`. Older installs kept transcripts and a `sessions.json` file under `~/.openclaw/agents/<agentId>/sessions/`. In 2026.9.9 that layout is legacy: the Gateway refuses readiness when it finds one, and `openclaw doctor --fix`, run with the Gateway stopped, imports it into SQLite. ## Where the isolation stops Separate agents are separate state, not separate security domains. Several things stay shared: - **One process.** All agents run inside the same Gateway, under the same OS user, reading the same `openclaw.json`. - **The workspace is not a jail.** It is the agent's default working directory: relative paths resolve inside it, but absolute paths can reach other host locations unless sandboxing is enabled for that agent. - **Session tools reach across agents by default.** `tools.sessions.visibility` defaults to `all` and `tools.agentToAgent.enabled` defaults to `true`, so an unsandboxed, tool-enabled agent can list, read and message every agent's sessions. Narrow it with `tools.sessions.visibility` set to `agent` or `self`, or restrict pairs with `tools.agentToAgent.allow`. - **Access control is per channel account.** Pairing and allowlists decide who may message a channel account at all; a binding only picks which admitted message goes to which agent. - **Plugin storage follows the plugin.** For example, Memory Wiki keeps one global vault unless its `vault.scope` is set to `agent`. ## Creating a second agent 1. Run `openclaw agents add work`; flags such as `--workspace`, `--agent-dir`, `--model` and `--bind <channel[:accountId]>` select the non-interactive path. 2. Let the wizard add bindings, or add them under `bindings` yourself. 3. Confirm the roster and routing with `openclaw agents list --bindings`. ## Identity and removal - **Identity.** `openclaw agents set-identity` writes `name`, `theme`, `emoji` and `avatar` into `agents.entries.<id>.identity`; any field not set in config falls back to `IDENTITY.md` in that agent's workspace. - **Removal.** `openclaw agents delete <id>` moves the agent's workspace, state and transcripts to the Trash rather than hard-deleting them, and the only configured agent cannot be deleted. ## Mistakes to avoid - **Reusing an `agentDir` for two agents.** The docs warn against it: auth and session state collide because both agents write the same database. - **Treating separate agents as private from each other.** Without narrowing session visibility, another agent's tools can still read the transcripts. - **Expecting a per-agent sender identity.** Several agents bound to one WhatsApp number all reply from that number.

  • What goes wrong if two OpenClaw agents are given the same `agentDir`?
    Both agents then read and write one auth store and one `openclaw-agent.sqlite`, so their credentials and session state collide; the docs say never to reuse an `agentDir`. In 2026.9.9, `openclaw agents list` reports an agent whose database belongs to another agent as degraded with repair guidance, while the Gateway keeps serving the healthy agents.
  • Does a newly added OpenClaw agent need its own model-provider login?
    Not necessarily. When a secondary agent has no local profile, or its OAuth credential has expired, OpenClaw reads through to the default agent's credential for the same profile id without copying the refresh token. Interactive `openclaw agents add` can copy portable static `api_key` and `token` profiles. For an independent OAuth account, sign in from that agent.

Agents on one Gateway are like several desks in one office: each desk has its own drawers, notebooks and keys, but everyone works under one roof, and unless you lock the filing room, anyone at any desk can walk over and read another desk's files.

  • Each OpenClaw agent runs as its own separate Gateway process.
  • An agent's workspace folder is a sandbox its tools cannot leave.
  • All agents share one session history and differ only in SOUL.md.
  • Pointing two agents at one agentDir is a safe way to share logins.
  • A separate agent's transcripts are hidden from other agents by default.

Assumes OpenClaw 2026.9.9, where each agent's sessions live in <agentDir>/openclaw-agent.sqlite; older installs kept JSONL transcripts and sessions.json under the agent's sessions folder.