fix(whatsapp): forward reply context from bridge to agent - #44681
Closed
anand-agastya wants to merge 1 commit into
Closed
fix(whatsapp): forward reply context from bridge to agent#44681anand-agastya wants to merge 1 commit into
anand-agastya wants to merge 1 commit into
Conversation
The WhatsApp bridge already captures quotedMessageId, quotedMessageText, hasQuotedMessage, quotedParticipant, and quotedRemoteJid from Baileys contextInfo. However, _build_message_event() never forwarded these to the MessageEvent. The core MessageEvent class already defines reply_to_message_id and reply_to_text fields (gateway/platforms/base.py:1318-1319), and the message handler in gateway/run.py already injects reply context into the agent prompt when these fields are set (line 8286-8294). This is a 2-line change that wires up the existing bridge data to the existing infrastructure. When a user replies to a message on WhatsApp, the agent now sees: [Replying to: "the quoted text"]
Collaborator
|
Hey @alt-glitch and maintainers, can I be assigned on this issue? |
Author
|
Closing in favor of #16552 which already covers both bridge.js and whatsapp.py changes plus tests. We've confirmed the approach works in production. |
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.
Problem
When a user replies to a WhatsApp message (using WhatsApp's built-in reply feature), the agent receives only the new message text with no information about which prior message the user is referencing. The agent has to guess the context.
Solution
The WhatsApp bridge (bridge.js) already captures
quotedMessageId,quotedMessageText,hasQuotedMessage,quotedParticipant, andquotedRemoteJidfrom BaileyscontextInfoand includes them in every event. However,_build_message_event()inwhatsapp.pynever forwarded these to theMessageEvent.The core
MessageEventclass (base.pylines 1318-1319) already definesreply_to_message_idandreply_to_textfields, and the message handler inrun.py(lines 8286-8294) already injects reply context into the agent prompt when these fields are set.This PR adds the two missing lines to wire the bridge data into the existing infrastructure.
Changes
gateway/platforms/whatsapp.py— +2 lines in_build_message_event():reply_to_message_id=data.get("quotedMessageId")reply_to_text=data.get("quotedMessageText")Impact
When a user replies to a message on WhatsApp, the agent now sees:
[Replying to: "the quoted text"]prepended to their message. No other platform is affected — Telegram/Discord already populate these fields through their own adapters.