openclaw - 💡(How to fix) Fix WhatsApp: Own outbound messages echoed back as inbound when queued [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#54371Fetched 2026-04-08 01:28:28
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Timeline (top)
closed ×1commented ×1cross-referenced ×1locked ×1

When multiple messages are sent in quick succession (e.g., during a long multi-part response), the outbound messages are sometimes echoed back to the agent as inbound messages, causing a cascade of unnecessary responses.

Root Cause

When multiple messages are sent in quick succession (e.g., during a long multi-part response), the outbound messages are sometimes echoed back to the agent as inbound messages, causing a cascade of unnecessary responses.

Fix Action

Workaround

Agent-level filtering by checking if message content matches recent outbound content. Not ideal as it burns tokens.

RAW_BUFFERClick to expand / collapse

Description

When multiple messages are sent in quick succession (e.g., during a long multi-part response), the outbound messages are sometimes echoed back to the agent as inbound messages, causing a cascade of unnecessary responses.

Environment

  • OpenClaw version: 2026.3.23-2
  • Channel: WhatsApp (Baileys)
  • Config: selfChatMode: false, dedicated number setup

Steps to Reproduce

  1. Agent sends a long response that gets chunked into multiple WhatsApp messages
  2. Messages are queued and sent rapidly
  3. Some/all outbound messages return as inbound messages with sender_id matching the owner's number
  4. Agent responds to its own messages, creating an echo chain

Expected Behavior

Outbound messages (fromMe: true) should never be processed as inbound messages, regardless of queue timing.

Actual Behavior

Outbound messages are echoed back and processed as new inbound messages. The selfChatMode: false setting does not prevent this when messages come through the queue.

Workaround

Agent-level filtering by checking if message content matches recent outbound content. Not ideal as it burns tokens.

Suggested Fix

Gateway-level deduplication based on message ID or content hash, or stricter fromMe filtering in the WhatsApp channel handler before messages reach the agent.

extent analysis

Fix Plan

To address the issue of outbound messages being echoed back as inbound messages, we will implement a gateway-level deduplication mechanism based on message content hash. Here are the steps:

  • Modify the WhatsApp channel handler to calculate a hash of the message content for each outbound message and store it in a cache with a TTL (time to live) of 1 minute.
  • Before processing an inbound message, check if a hash of its content exists in the cache. If it does, discard the message.
  • Implement a cache using a library like Redis to store message content hashes.

Example code snippet in JavaScript:

const redis = require('redis');

// Initialize Redis client
const client = redis.createClient();

// Function to calculate message content hash
function calculateHash(message) {
  return crypto.createHash('sha256').update(message).digest('hex');
}

// WhatsApp channel handler
function handleOutboundMessage(message) {
  const hash = calculateHash(message.content);
  client.set(hash, 'outbound', 'EX', 60); // Set TTL to 1 minute
  // Send message
}

function handleInboundMessage(message) {
  const hash = calculateHash(message.content);
  client.get(hash, (err, reply) => {
    if (reply === 'outbound') {
      // Discard message
      return;
    }
    // Process message
  });
}

Verification

To verify that the fix worked, test the scenario described in the issue:

  1. Send a long response that gets chunked into multiple WhatsApp messages.
  2. Verify that the outbound messages are not echoed back as inbound messages.
  3. Check the Redis cache to ensure that the message content hashes are being stored and expired correctly.

Extra Tips

  • Use a suitable cache library like Redis to store message content hashes.
  • Adjust the TTL value based on the expected delay between sending and receiving messages.
  • Consider implementing a more robust deduplication mechanism, such as using a message ID or a combination of message content and metadata.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix WhatsApp: Own outbound messages echoed back as inbound when queued [1 comments, 2 participants]