Sessions & Multi-Agent Routing
Understand how OpenClaw manages sessions and routes messages
Understand how OpenClaw manages sessions and routes messages
Sessions are the core unit of conversation management in OpenClaw. They maintain context, state, and isolation between different conversations. Understanding sessions is key to configuring multi-agent routing and managing complex workflows.
The main session is the default session for direct messages (DMs). By default:
main sessionEach group chat gets its own isolated session:
You can create isolated sessions for:
See Multi-Agent Team and Example Setups & Model Routing for patterns.
Control when the agent responds in a session:
How the session handles concurrent requests:
Sessions automatically:
You can run multiple OpenClaw agents as a team: one Gateway, many sessions. Each session is one “agent” with its own identity, memory, and (optionally) role. Builders use this for “agent squads”—a coordinator plus specialists (researcher, writer, analyst) that wake on a schedule, share a task list, and hand off work. For a full walkthrough, see Multi-Agent Team use case.
OpenClaw supports routing messages to different agents based on various criteria:
Route different channels to different agents:
{
"agents": {
"whatsapp-agent": {
"workspace": "~/clawd-whatsapp",
"channels": ["whatsapp"]
},
"telegram-agent": {
"workspace": "~/clawd-telegram",
"channels": ["telegram"]
}
}
}
Route specific contacts to dedicated agents:
{
"agents": {
"work-agent": {
"workspace": "~/clawd-work",
"peers": ["+1234567890", "+0987654321"]
}
}
}
Each group can have its own agent workspace:
Session isolation provides security and context separation:
OpenClaw provides tools for session management:
sessions_list - List all active sessionssessions_history - View session conversation historysessions_send - Send messages to specific sessionssessions_spawn - Create new isolated sessionsThese tools allow agents to manage and communicate with other sessions.
Sub-agents are short-lived sessions created by your main agent (via sessions_spawn) to run a single task and report back. You can also send messages to an existing session from the CLI with openclaw agent --message "..." --to <sessionKey>. For a step-by-step setup—spawning, sending, Discord thread-bound subagents, and troubleshooting—see Set up a sub-agent.
Configure session behavior in your ~/.clawdbot/moltbot.json (file name maintained for backward compatibility):
{
"agents": {
"defaults": {
"session": {
"activation": "mention",
"queue": "sequential",
"sandbox": {
"mode": "non-main"
}
}
}
}
}
Sessions automatically compact context to manage token usage:
This ensures sessions remain efficient while maintaining important context.