openclaw - ✅(Solved) Fix [Bug]: DM self-chat echo loop on personal-number setup [1 pull requests, 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#55426Fetched 2026-04-08 01:39:38
View on GitHub
Comments
1
Participants
2
Timeline
15
Reactions
0
Participants
Timeline (top)
cross-referenced ×6referenced ×4labeled ×2closed ×1

● Summary: WhatsApp DM echo loop when using a personal number (same number for bot and owner). The bot's own outbound replies are received back as inbound messages via Baileys's messages.upsert event, causing the bot to process and reply to its own messages. Self-chat echo dedup exists for iMessage (#38440) and BlueBubbles (#38442), but is missing for WhatsApp DMs. The group echo
suppression added in #53624 (v2026.3.24) works correctly for groups but does not cover direct messag

Root Cause

● Summary: WhatsApp DM echo loop when using a personal number (same number for bot and owner). The bot's own outbound replies are received back as inbound messages via Baileys's messages.upsert event, causing the bot to process and reply to its own messages. Self-chat echo dedup exists for iMessage (#38440) and BlueBubbles (#38442), but is missing for WhatsApp DMs. The group echo
suppression added in #53624 (v2026.3.24) works correctly for groups but does not cover direct messag

Fix Action

Fixed

PR fix notes

PR #55447: fix(whatsapp): add DM self-echo dedup for personal-number setups (#55426)

Description (problem / solution / changelog)

Summary

WhatsApp DM messages create an echo loop when using a personal number (same number for bot and owner). Outbound replies are reflected back as inbound via Baileys messages.upsert with fromMe:true, causing the bot to re-process its own messages.

Root Cause

Self-chat echo dedup existed for iMessage (#38440) and BlueBubbles (#38442), and group echo suppression was added in #53624, but DM-specific dedup was missing for WhatsApp. The existing scoped dedup key (accountId:remoteJid:messageId) can miss DM reflections when the remoteJid shape differs between send and receive (e.g., JID/LID variance).

Changes

  • extensions/whatsapp/src/inbound/dedupe.ts: Added a second TTL dedup cache keyed by accountId:messageId (alongside existing scoped cache), wired into rememberRecentOutboundMessage and resetWebInboundDedupe, plus new isRecentOutboundMessageId lookup
  • extensions/whatsapp/src/inbound/monitor.ts: Updated messages.upsert fromMe echo drop to include DM fallback match using the id-only cache when !group

Test

  • LSP diagnostics clean on both changed files
  • pnpm test -- extensions/whatsapp/src/monitor-inbox.allows-messages-from-senders-allowfrom-list.test.ts passed
  • pnpm test -- extensions/whatsapp/src/monitor-inbox.streams-inbound-messages.test.ts passed

Closes #55426

Changed files

  • extensions/whatsapp/src/inbound/dedupe.ts (modified, +29/-0)
  • extensions/whatsapp/src/inbound/monitor.ts (modified, +10/-4)
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

● Summary: WhatsApp DM echo loop when using a personal number (same number for bot and owner). The bot's own outbound replies are received back as inbound messages via Baileys's messages.upsert event, causing the bot to process and reply to its own messages. Self-chat echo dedup exists for iMessage (#38440) and BlueBubbles (#38442), but is missing for WhatsApp DMs. The group echo
suppression added in #53624 (v2026.3.24) works correctly for groups but does not cover direct messag

Steps to reproduce

WhatsApp DM self-chat echo loop on personal-number setup

  2                                                                                                                         
  3 ## Summary                                                                                                                
  4                                                                                                                         
  5 WhatsApp DM echo loop when using a personal number (same number for bot and owner). The bot's own outbound replies        
    are received back as inbound messages via Baileys's `messages.upsert` event, causing the bot to process and reply t
    o its own messages.                                                                                                       
  6                                                     
  7 Self-chat echo dedup exists for **iMessage** (#38440) and **BlueBubbles** (#38442), but is missing for **WhatsApp D
    Ms**. The group echo suppression added in #53624 (v2026.3.24) works correctly for groups but does not cover direct
    messages.
  8
  9 ## Reproduction

Expected behavior

● Expected behavior: WhatsApp DM self-chat should have the same outbound dedup as iMessage (#38440) and BlueBubbles (#38442) —
track recently sent message IDs and drop reflected fromMe copies for DMs, not just groups.

Actual behavior

● Actual behavior: Bot sends a reply → Baileys fires messages.upsert with fromMe: true → gateway enqueues it as a new inbound
message (~100ms later) → bot processes its own reply and generates another response → echo loop. Setting selfChatMode to true or false makes no difference. Each echoed message costs an API call and the prompt-level echo guard in SOUL.md is unreliabl

OpenClaw version

Version: OpenClaw 2026.3.24 (cff6dc9)

Operating system

Ubuntu Linux (kernel 6.17.0-19-generic), x86_64

Install method

No response

Model

anthropic

Provider / routing chain

❯ provider routing chain ● Provider routing chain: Primary: anthropic/claude-sonnet-4-6 → Fallback 1: ollama-cloud/glm-4.7:cloud → Fallback 2: anthropic/claude-opus-4-

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

extent analysis

Fix Plan

To resolve the WhatsApp DM echo loop issue, we need to implement a deduplication mechanism for recently sent message IDs. Here are the steps:

  • Track recently sent message IDs in a data structure (e.g., a set or map) with a reasonable TTL (time to live).
  • When receiving an inbound message via Baileys's messages.upsert event, check if the message ID is in the tracked set.
  • If the message ID is found, drop the message to prevent the echo loop.

Example code snippet in JavaScript:

const sentMessageIds = new Set();
const ttl = 60 * 1000; // 1 minute TTL

// When sending a message
function sendMessage(message) {
  const messageId = message.id;
  sentMessageIds.add(messageId);
  setTimeout(() => sentMessageIds.delete(messageId), ttl);
}

// When receiving an inbound message
function handleInboundMessage(message) {
  if (sentMessageIds.has(message.id) && message.fromMe) {
    // Drop the message to prevent echo loop
    return;
  }
  // Process the message as usual
}

Verification

To verify that the fix worked, you can:

  • Test the WhatsApp DM self-chat functionality with the implemented deduplication mechanism.
  • Check the logs to ensure that echoed messages are being dropped correctly.
  • Monitor the API call count to verify that the echo loop is no longer occurring.

Extra Tips

  • Consider using a more robust data structure, such as a Redis set or a database, to store the sent message IDs, especially if you're handling a large volume of messages.
  • Adjust the TTL value according to your specific use case to balance between preventing echo loops and allowing for legitimate message resends.

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…

FAQ

Expected behavior

● Expected behavior: WhatsApp DM self-chat should have the same outbound dedup as iMessage (#38440) and BlueBubbles (#38442) —
track recently sent message IDs and drop reflected fromMe copies for DMs, not just groups.

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 - ✅(Solved) Fix [Bug]: DM self-chat echo loop on personal-number setup [1 pull requests, 1 comments, 2 participants]