Fix Telegram DM session binding key mismatch and stale binding cleanup#109
Fix Telegram DM session binding key mismatch and stale binding cleanup#109jdm0830 wants to merge 9 commits into
Conversation
…g cleanup - Set parentConversationId=undefined for Telegram DMs (no topic) so the inbound conversation key matches what was stored at bind time. Prior code passed event.parentConversationId through unconditionally, producing a key with a trailing user-ID component that never matched stored bindings. - In handleInboundClaim, when resolvedBinding is null, check OpenClaw's session binding service for an active binding on the same conversation. If found, unbind it and notify the user (session expired, run /cas_resume) instead of silently falling through to the LLM agent. Fixes pwrdrvr#108 Related: openclaw/openclaw#70288
|
Thank you for your contribution! Unfortunately there are still changes needed to support such an ambitious plugin in OpenClaw. Some of this functionality is now being included directly in OpenClaw. I have made a new project, https://github.com/pwrdrvr/PwrAgent, that gives you a Codex Desktop replacement app (uses Codex) but also integrates with messaging with openclaw-codex-app-server-like functionality. Bindings can be viewed within the PwrAgent desktop thread. You can see them right on the threads you have bound and you can click on the chip for the binding to unbind it right from PwrAgent. When a thread is archived the bindings are removed automatically and the messaging platform receives a notice of this. I think you'll like it. Please give it a try! |
Fixes #108
Related: openclaw/openclaw#70288
Summary
Telegram DM
parentConversationIdkey mismatch:toConversationTargetFromInboundwas passingevent.parentConversationIdthrough for all Telegram channels, including DMs. For DMs (no topic), this produced an inbound key with a trailing user-ID component that never matched bindings stored at bind time. Fix: setparentConversationId = undefinedwhenchannel === "telegram"and no thread/topic exists.Stale OpenClaw binding cleanup: When the plugin's internal thread state is cleared without properly detaching from OpenClaw's session binding registry, subsequent inbound messages find
resolvedBinding === nullbut OpenClaw still routes them to this plugin. Previously the plugin returned{ handled: false }, silently falling through to the LLM. Fix: check OpenClaw's session binding service for an active binding, unbind it, and notify the user (⚠️ Codex session expired. Run /cas_resume to start a new thread.), then return{ handled: true }.Context
The
parentConversationIdregression was introduced by the PR-96 Telegram topic support merge, which added Telegram-specific handling but left the DM path passing the raw event value through.The stale binding issue surfaces most visibly once the key mismatch is fixed — previously DM messages never claimed the binding at all, so the stale path was unreachable.
Both fixes are needed alongside the OpenClaw core fix in openclaw/openclaw#70288, which ensures that when a plugin returns
{ handled: true }frominbound_claim, the channel handler does not fire a silentNO_REPLYfallback before the plugin's async response arrives.Validation