Summary
Every Telegram slash command (e.g. /new, /reset, /help) creates a session entry with the key telegram:slash:<user_id> instead of agent:<agentId>:telegram:slash:<user_id>. This bare key coexists with the real session key (agent:main:telegram:direct:<user_id>), and the gateway resolves both to the same chat — resulting in duplicate message delivery.
Root Cause
In pi-embedded-DgYXShcG.js (and pi-embedded-CtM2Mrrj.js), the ctxPayload for the slash handler hardcodes:
SessionKey: `telegram:slash:${senderId || chatId}`,
This is missing the agent:<agentId>: prefix that all other session keys use. The key is then passed to recordInboundSessionMetaSafe via ctxPayload.SessionKey ?? route.sessionKey, writing the malformed key to sessions.json.
Impact
- Each slash command invocation writes a new bare
telegram:slash:<user_id> entry to sessions.json
- With multiple slash commands (e.g.
/new used regularly), stale entries accumulate
- Gateway routes delivery to both the real session and the bare session → duplicate Telegram messages
- Race condition possible (messages arrive out of order)
Fix
Change line to include the agent prefix (note: route.agentId is already in scope):
SessionKey: `agent:${route.agentId}:telegram:slash:${senderId || chatId}`,
Applied this patch locally — duplicate messages stopped immediately.
Environment
- OpenClaw (latest npm release as of 2026-03-07)
- Telegram channel, direct chat
- Slash commands used:
/new, /reset
- WSL2 / Ubuntu 22.04
Summary
Every Telegram slash command (e.g.
/new,/reset,/help) creates a session entry with the keytelegram:slash:<user_id>instead ofagent:<agentId>:telegram:slash:<user_id>. This bare key coexists with the real session key (agent:main:telegram:direct:<user_id>), and the gateway resolves both to the same chat — resulting in duplicate message delivery.Root Cause
In
pi-embedded-DgYXShcG.js(andpi-embedded-CtM2Mrrj.js), thectxPayloadfor the slash handler hardcodes:This is missing the
agent:<agentId>:prefix that all other session keys use. The key is then passed torecordInboundSessionMetaSafeviactxPayload.SessionKey ?? route.sessionKey, writing the malformed key tosessions.json.Impact
telegram:slash:<user_id>entry to sessions.json/newused regularly), stale entries accumulateFix
Change line to include the agent prefix (note:
route.agentIdis already in scope):Applied this patch locally — duplicate messages stopped immediately.
Environment
/new,/reset