fix(whatsapp): carry forward message_id from latest event in text merge paths - #60409
Closed
kyssta-exe wants to merge 1 commit into
Closed
fix(whatsapp): carry forward message_id from latest event in text merge paths#60409kyssta-exe wants to merge 1 commit into
kyssta-exe wants to merge 1 commit into
Conversation
…ge paths Root cause: when rapid-fire text messages are merged (via merge_pending_message_event in base.py or _enqueue_text_event in the Baileys bridge adapter), the merged event retains the FIRST message's message_id and reply_to_message_id. The agent's reply quotes the wrong (older) message because _reply_anchor_for_event returns the stale first message's ID. Fix: after appending text from the incoming event, also update message_id and reply_to_message_id on the existing merged event to reflect the latest inbound message. This matches the pattern already used by _queue_text_debounce. Fixes NousResearch#59582
Collaborator
Contributor
Author
|
Stale — 6-7 days without merge activity. Can resubmit if still needed. |
1 task
10 tasks
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
When rapid-fire text messages arrive while the agent is busy (or within the Baileys bridge text-batch window), the merged pending event retains the FIRST message's
message_idandreply_to_message_id. The agent's reply quotes the wrong (older) message because_reply_anchor_for_event()returns the stale first message's ID.Root Cause
Two code paths have the same gap:
merge_pending_message_eventingateway/platforms/base.py(line ~2114): whenmerge_text=Trueand two TEXT events are merged, text is appended butmessage_id/reply_to_message_idare never updated from the latest event._enqueue_text_eventinplugins/platforms/whatsapp/adapter.py(line ~1295): the Baileys bridge adapter's own text batching mechanism has the identical gap — it appends text and media but never carries forward the latest event's identity fields.Compare
_queue_text_debounce(base.py ~line 4272) which DOES correctly updatemessage_idfrom the latest event — that was the reference implementation for this fix.Fix
After appending text from the incoming event in both merge paths, also update
message_idandreply_to_message_idon the existing merged event to reflect the latest inbound message. This ensures_reply_anchor_for_event()returns the correct (latest) message ID when the agent processes the merged event.Testing
_queue_text_debounceFixes #59582