Understand how OpenClaw (formerly Clawdbot and Moltbot) 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:
Control when the agent responds in a session:
How the session handles concurrent requests:
Sessions automatically:
Moltbot 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:
Moltbot 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.
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.