fix(whatsapp): propagate fromMe flag through DM message pipeline#21890
Open
mactsk wants to merge 1 commit intoopenclaw:mainfrom
Open
fix(whatsapp): propagate fromMe flag through DM message pipeline#21890mactsk wants to merge 1 commit intoopenclaw:mainfrom
mactsk wants to merge 1 commit intoopenclaw:mainfrom
Conversation
In WhatsApp DMs, the agent cannot distinguish between messages sent by the gateway owner and messages from the contact. This makes it impossible for the agent to follow the conversation correctly. - Add `fromMe` field to `WebInboundMessage` type - Propagate `Boolean(msg.key?.fromMe)` from the Baileys message - Pass `fromMe` through `buildInboundLine` to `formatInboundEnvelope` - In DM envelopes, append "(you)" to the from field when fromMe is true so the agent sees `[WhatsApp +1555 (you)] message` for owner messages Closes openclaw#12482 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
This pull request has been automatically marked as stale due to inactivity. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #12482
In WhatsApp DMs, the agent cannot distinguish between messages sent by the gateway owner and messages from the contact. This makes it impossible for the agent to follow a two-way conversation correctly.
Changes
fromMe?: booleanfield toWebInboundMessagetypeBoolean(msg.key?.fromMe)from the Baileys message into the inbound messagefromMethroughbuildInboundLine()toformatInboundEnvelope()(you)to thefromfield whenfromMeis true, producing[WhatsApp +1555 (you)] messagefor owner messagesSecurity
Boolean(msg.key?.fromMe)safely defaults tofalsefor null/undefined(you)marker passes throughsanitizeEnvelopeHeaderPart(no injection risk)fromMefield is optional throughout — fully backward-compatibleTest plan
fromMe: true→ envelope contains(you)fromMe: false→ no(you)markerfromMe: true→ no(you)marker (groups unaffected)fromMeomitted → no(you)marker (backward compat)🤖 Generated with Claude Code
Greptile Summary
Adds a
fromMeflag to the WhatsApp inbound message pipeline so the agent can distinguish between messages sent by the gateway owner and messages from the contact in DMs. The flag flows from Baileys'msg.key.fromMethroughWebInboundMessage→buildInboundLine()→formatInboundEnvelope(), where DM messages withfromMe: trueget a(you)suffix appended to thefromfield in the envelope header (e.g.,[WhatsApp +1555 (you)] message).fromMe?: booleanfield added toWebInboundMessagetype, ensuring backward compatibilityBoolean(msg.key?.fromMe)safely coerces null/undefined tofalse(you)marker only applies to DM messages (not groups), and passes throughsanitizeEnvelopeHeaderPartsafelyConfidence Score: 5/5
Last reviewed commit: 7fc1a3b
(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!