When a WhatsApp DM user sends a new message while the agent is still processing a previous one, the interrupt mechanism silently fails. The message is swallowed and never processed.
Root cause: _quick_key in gateway/run.py (line 640) builds the key without chat_id for all DMs:
_quick_key = (
f"agent:main:{source.platform.value}:{source.chat_type}:{source.chat_id}"
if source.chat_type != "dm"
else f"agent:main:{source.platform.value}:dm"
)
But _generate_session_key() in gateway/session.py includes chat_id for WhatsApp DMs:
if platform == "whatsapp" and source.chat_id:
return f"agent:main:{platform}:dm:{source.chat_id}"
The running agent is stored under the full session key (with chat_id) at line 2096, but looked up with the shorter _quick_key (without chat_id) at line 645. The lookup always misses.
Impact:
- WhatsApp DM users cannot interrupt a running agent
- The interrupt message is stored in
_pending_messages under the wrong key, so it is never picked up
- The same mismatch affects the approval flow
session_key_preview for non WhatsApp DMs (those also omit chat_id but the approval code at line 720 already has a WhatsApp specific branch, confirming the intent)
Reproduction:
- Send a message to the bot via WhatsApp DM
- While the agent is processing, send another message (e.g. "stop")
- Expected: agent is interrupted
- Actual: second message is silently lost, agent continues uninterrupted
When a WhatsApp DM user sends a new message while the agent is still processing a previous one, the interrupt mechanism silently fails. The message is swallowed and never processed.
Root cause:
_quick_keyingateway/run.py(line 640) builds the key withoutchat_idfor all DMs:But
_generate_session_key()ingateway/session.pyincludeschat_idfor WhatsApp DMs:The running agent is stored under the full session key (with
chat_id) at line 2096, but looked up with the shorter_quick_key(withoutchat_id) at line 645. The lookup always misses.Impact:
_pending_messagesunder the wrong key, so it is never picked upsession_key_previewfor non WhatsApp DMs (those also omitchat_idbut the approval code at line 720 already has a WhatsApp specific branch, confirming the intent)Reproduction: