Comprehensive tutorial series for OpenClaw AI agent gateway
Session management is the most critical topic for transitioning from single-user to multi-user deployments. Get this wrong and users will see each other’s conversations.
main is unsafe for multi-user~45 minutes for all sections
Consider this scenario:
This happens because the default session.dmScope: "main" shares a single session across all DMs.
Every conversation has a session key that determines:
Session Key Format: agent:<agentId>:<channel>:<scope>:<identifier>
Examples:
agent:main:telegram:dm:123456789 # Telegram DM from user 123456789
agent:main:telegram:group:-1001234 # Telegram group -1001234
agent:coder:discord:dm:user#1234 # Discord DM to coder agent
dmScope{
session: {
// This ONE setting determines user isolation
dmScope: "per-channel-peer", // SAFE for multi-user
},
}
| Value | Behavior | Use Case |
|---|---|---|
main |
All DMs share one session | Single user ONLY |
per-peer |
Isolate by sender ID | Multi-user, single channel |
per-channel-peer |
Isolate by channel + sender | Multi-user (recommended) |
per-account-channel-peer |
Isolate by account + channel + sender | Multiple bot accounts |
# Check your current setting
grep -i "dmScope" ~/.openclaw/openclaw.json
# If it shows "main" or is missing, you're at risk!
# Add this immediately:
{
session: {
dmScope: "per-channel-peer",
},
}
dmScope worksIf you’re running a bot that multiple people might message:
// ~/.openclaw/openclaw.json
{
session: {
// CRITICAL: Isolate each user's conversation
dmScope: "per-channel-peer",
},
channels: {
telegram: {
enabled: true,
dmPolicy: "pairing", // Require explicit approval
},
},
}
Then restart:
openclaw gateway restart
Start with Session Basics to understand the full picture →