From 6f177adafeea3ae7209f0597bab5d16499886bc4 Mon Sep 17 00:00:00 2001 From: Peyton-Spencer Date: Mon, 16 Feb 2026 10:43:18 +0000 Subject: [PATCH] fix: skip empty WhatsApp protocol messages WhatsApp protocol messages (encryption key distribution, read receipts, ephemeral settings, senderKeyDistributionMessage) have a message envelope but no text content. These were being stored in messages.db and processed by the agent, causing: 1. Agent responds to empty messages, wasting API tokens 2. Container stays alive indefinitely (idle timer resets) 3. Scheduled tasks blocked (queue slot occupied) This fix skips messages with empty content before calling onMessage, preventing protocol messages from being stored and processed. Fixes #250 Co-Authored-By: Claude Sonnet 4.5 --- src/channels/whatsapp.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/channels/whatsapp.ts b/src/channels/whatsapp.ts index 3a4df46..9b05f96 100644 --- a/src/channels/whatsapp.ts +++ b/src/channels/whatsapp.ts @@ -170,6 +170,10 @@ export class WhatsAppChannel implements Channel { msg.message?.imageMessage?.caption || msg.message?.videoMessage?.caption || ''; + + // Skip protocol messages with no text content (encryption keys, read receipts, etc.) + if (!content) continue; + const sender = msg.key.participant || msg.key.remoteJid || ''; const senderName = msg.pushName || sender.split('@')[0];