Skip to content

fix(gateway): match _quick_key to _generate_session_key for WhatsApp DMs#350

Merged
teknium1 merged 1 commit into
NousResearch:mainfrom
Farukest:fix/whatsapp-dm-session-key-mismatch
Mar 4, 2026
Merged

fix(gateway): match _quick_key to _generate_session_key for WhatsApp DMs#350
teknium1 merged 1 commit into
NousResearch:mainfrom
Farukest:fix/whatsapp-dm-session-key-mismatch

Conversation

@Farukest

@Farukest Farukest commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

The _quick_key used for interrupt lookup and _pending_messages in _handle_message() omitted chat_id for all DMs. But _generate_session_key() includes chat_id for WhatsApp DMs (since PR #75 added multi user session isolation). The running agent was stored under the full key but looked up with the shorter key, so the lookup always missed.

The same mismatch existed in _handle_usage_command().

Both sites now use the same three branch logic as _generate_session_key().

Tests

Added TestWhatsAppDMSessionKeyConsistency to tests/gateway/test_session.py with 4 tests:

  • WhatsApp DM _quick_key includes chat_id and matches _generate_session_key
  • WhatsApp DM /usage key includes chat_id and matches
  • Telegram DM key still omits chat_id (unchanged behavior)
  • Discord group key still includes chat_id (unchanged behavior)

Closes #349

@teknium1

teknium1 commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

Merged in bfd08d5 — thanks for the clean fix and thorough tests!

Added a follow-up refactor in 3db3d60 that extracts the key construction into a single build_session_key() function in session.py. All 3 inline copies in run.py now call it, so this kind of drift can't happen again.

angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
…e_session_key for WhatsApp DMs

Authored by Farukest. Fixes NousResearch#349.
olympus-terminal pushed a commit to olympus-terminal/hermes-agent that referenced this pull request May 16, 2026
…e_session_key for WhatsApp DMs

Authored by Farukest. Fixes NousResearch#349.
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
…e_session_key for WhatsApp DMs

Authored by Farukest. Fixes NousResearch#349.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WhatsApp DM interrupt silently fails due to session key mismatch in _quick_key

2 participants