Bug Description
When session.dmScope is changed from default to per-channel-peer, the old session agent:main:main persists in the session store and is not cleaned up. This causes duplicate message delivery to the same Telegram chat, because both sessions have active deliveryContext pointing to the same target.
Environment
- OS: Windows 11 25H2 (x64)
- OpenClaw: v2026.2.26
- Node: v22.16.0
- Channel: Telegram (single bot, single chat)
Steps to Reproduce
- Start with default dmScope (no explicit setting).
- Session
agent:main:main is created and actively used.
- Change config to
session.dmScope: "per-channel-peer".
- Restart gateway.
- New session
agent:main:telegram:direct:<chatId> is created.
- Old session
agent:main:main survives in the session store with its deliveryContext still pointing to the same Telegram chat.
Actual Behavior
Both sessions are active simultaneously:
agent:main:telegram:direct:6101296751 (per-channel-peer, correct)
agent:main:main (legacy, should have been removed or deactivated)
When a subagent completes (auto-announce) or a cron job delivers results, both sessions receive and forward the message, resulting in the user getting every notification twice.
Evidence from openclaw sessions --all-agents --json:
{
"key": "agent:main:telegram:direct:6101296751",
"updatedAt": 1772402601476,
"model": "claude-opus-4-6-thinking"
},
{
"key": "agent:main:main",
"updatedAt": 1772402601461,
"model": "gemini-3-flash"
}
Both updated at the exact same second, both delivering to the same telegram:6101296751 target.
Expected Behavior
When dmScope changes to per-channel-peer, the gateway should either:
- Migrate the old
agent:<id>:main session to the new agent:<id>:telegram:direct:<chatId> key, OR
- Deactivate/remove the old session so it no longer receives or delivers messages.
Workaround
Manually delete the agent:main:main entry from agents/main/sessions/sessions.json and restart the gateway.
Additional Context
This issue is particularly disruptive because:
- Users may not realize they have duplicate sessions until they notice repeated messages.
- The old session continues to consume tokens (it had 111k tokens accumulated).
openclaw sessions cleanup does not remove the stale session.
Bug Description
When
session.dmScopeis changed from default toper-channel-peer, the old sessionagent:main:mainpersists in the session store and is not cleaned up. This causes duplicate message delivery to the same Telegram chat, because both sessions have activedeliveryContextpointing to the same target.Environment
Steps to Reproduce
agent:main:mainis created and actively used.session.dmScope: "per-channel-peer".agent:main:telegram:direct:<chatId>is created.agent:main:mainsurvives in the session store with itsdeliveryContextstill pointing to the same Telegram chat.Actual Behavior
Both sessions are active simultaneously:
agent:main:telegram:direct:6101296751(per-channel-peer, correct)agent:main:main(legacy, should have been removed or deactivated)When a subagent completes (auto-announce) or a cron job delivers results, both sessions receive and forward the message, resulting in the user getting every notification twice.
Evidence from
openclaw sessions --all-agents --json:{ "key": "agent:main:telegram:direct:6101296751", "updatedAt": 1772402601476, "model": "claude-opus-4-6-thinking" }, { "key": "agent:main:main", "updatedAt": 1772402601461, "model": "gemini-3-flash" }Both updated at the exact same second, both delivering to the same
telegram:6101296751target.Expected Behavior
When
dmScopechanges toper-channel-peer, the gateway should either:agent:<id>:mainsession to the newagent:<id>:telegram:direct:<chatId>key, ORWorkaround
Manually delete the
agent:main:mainentry fromagents/main/sessions/sessions.jsonand restart the gateway.Additional Context
This issue is particularly disruptive because:
openclaw sessions cleanupdoes not remove the stale session.