Multi-Agent Routing
Goal: multiple isolated agents (separate workspace +agentDir + sessions), plus multiple provider accounts (e.g. two WhatsApps) in one running Gateway. Inbound is routed to an agent via bindings.
What is “one agent”?
An agent is a fully scoped brain with its own:- Workspace (files, AGENTS.md/SOUL.md/USER.md, local notes, persona rules).
- State directory (
agentDir) for auth profiles, model registry, and per-agent config. - Session store (chat history + routing state) under
~/.clawdbot/agents/<agentId>/sessions.
Paths (quick map)
- Config:
~/.clawdbot/clawdbot.json(orCLAWDBOT_CONFIG_PATH) - State dir:
~/.clawdbot(orCLAWDBOT_STATE_DIR) - Workspace:
~/clawd(or~/clawd-<agentId>) - Agent dir:
~/.clawdbot/agents/<agentId>/agent(orrouting.agents.<agentId>.agentDir) - Sessions:
~/.clawdbot/agents/<agentId>/sessions
Single-agent mode (default)
If you do nothing, Clawdbot runs a single agent:agentIddefaults tomain.- Sessions are keyed as
agent:main:<mainKey>. - Workspace defaults to
~/clawd(or~/clawd-<profile>whenCLAWDBOT_PROFILEis set). - State defaults to
~/.clawdbot/agents/main/agent.
Agent helper
Use the agent wizard to add a new isolated agent:routing.bindings (or let the wizard do it) to route inbound messages.
Verify with:
Multiple agents = multiple people, multiple personalities
With multiple agents, eachagentId becomes a fully isolated persona:
- Different phone numbers/accounts (per provider
accountId). - Different personalities (per-agent workspace files like
AGENTS.mdandSOUL.md). - Separate auth + sessions (no cross-talk unless explicitly enabled).
Routing rules (how messages pick an agent)
Bindings are deterministic and most-specific wins:peermatch (exact DM/group/channel id)guildId(Discord)teamId(Slack)accountIdmatch for a provider- provider-level match (
accountId: "*") - fallback to
routing.defaultAgentId(default:main)
Multiple accounts / phone numbers
Providers that support multiple accounts (e.g. WhatsApp) useaccountId to identify
each login. Each accountId can be routed to a different agent, so one server can host
multiple phone numbers without mixing sessions.
Concepts
agentId: one “brain” (workspace, per-agent auth, per-agent session store).accountId: one provider account instance (e.g. WhatsApp account"personal"vs"biz").binding: routes inbound messages to anagentIdby(provider, accountId, peer)and optionally guild/team ids.- Direct chats collapse to
agent:<agentId>:<mainKey>(per-agent “main”;session.mainKey).
Example: two WhatsApps → two agents
~/.clawdbot/clawdbot.json (JSON5):
Per-Agent Sandbox and Tool Configuration
Starting with v2026.1.6, each agent can have its own sandbox and tool restrictions:- Security isolation: Restrict tools for untrusted agents
- Resource control: Sandbox specific agents while keeping others on host
- Flexible policies: Different permissions per agent
agent.elevated is global and sender-based; it is not configurable per agent.
If you need per-agent boundaries, use routing.agents[id].tools to deny bash.
For group targeting, you can set routing.agents[id].mentionPatterns so @mentions map cleanly to the intended agent.
See Multi-Agent Sandbox & Tools for detailed examples.