Skip to content

fix(whatsapp): include quoted reply context - #44614

Closed
mgonto wants to merge 1 commit into
NousResearch:mainfrom
mgonto:fix/whatsapp-reply-context
Closed

fix(whatsapp): include quoted reply context#44614
mgonto wants to merge 1 commit into
NousResearch:mainfrom
mgonto:fix/whatsapp-reply-context

Conversation

@mgonto

@mgonto mgonto commented Jun 12, 2026

Copy link
Copy Markdown

Summary

  • Extract quoted WhatsApp message text in the bridge and forward it with inbound events
  • Populate MessageEvent.reply_to_text / reply_to_message_id in the WhatsApp adapter
  • Add regression coverage for bridge extraction, sanitization, adapter mapping, and agent-visible reply context

Test plan

  • node --test scripts/whatsapp-bridge/*.test.mjs
  • node --check scripts/whatsapp-bridge/bridge.js && node --check scripts/whatsapp-bridge/message-utils.js
  • python3 -m py_compile gateway/platforms/whatsapp.py
  • scripts/run_tests.sh tests/gateway/test_whatsapp_reply_context.py
  • scripts/run_tests.sh tests/gateway/test_whatsapp_*.py

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/whatsapp WhatsApp Business adapter duplicate This issue or pull request already exists labels Jun 12, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #16552 (earliest open PR for the same fix) — extract the quoted WhatsApp message text in the bridge and populate MessageEvent.reply_to_text/reply_to_message_id in the adapter. Same quoted-reply gap as #38382/#28823 (merged #25489 surfaced bridge metadata).

@liuhao1024

Copy link
Copy Markdown
Contributor

✅ Verified — WhatsApp quoted reply context

Reviewed the diff for _sanitize_reply_context_text and the reply context integration in _build_message_event.

  • _sanitize_reply_context_text correctly strips control characters (\x00-\x1f, \x7f), collapses whitespace, and bounds output to 1000 chars with ellipsis truncation. This prevents quoted text from corrupting the synthetic [Replying to: "..."] prefix.
  • quotedMessageId fallback (f"quoted:{messageId}") ensures reply context remains usable when the backend only provides quoted text without a stanza ID.
  • Bridge.js refactors getMessageContent, getContextInfo, and extractQuotedMessageText into message-utils.js — clean extraction, no logic changes to existing message parsing.
  • Reply context fields (reply_to_message_id, reply_to_text) correctly set to None when empty, matching the MessageEvent constructor expectations.

No issues found.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the quoted-reply context work. This is already implemented on current main, so closing as superseded. This is an automated hermes-sweeper review.

  • scripts/whatsapp-bridge/bridge_helpers.js:310-317 extracts quotedMessageId, quotedText, and reply metadata from the Baileys context.
  • plugins/platforms/whatsapp/adapter.py:1438-1455,1504-1517 maps that data to MessageEvent.reply_to_message_id and reply_to_text.
  • gateway/run.py:10592-10606 renders the agent-visible reply-context prefix.
  • The regression coverage is in scripts/whatsapp-bridge/bridge.native.test.mjs:64-101.
  • The implementation landed in 11627fdcb92a0ad57c9b637538f8fbea39142272 and is contained in v2026.7.7. This also supersedes the duplicate gap noted in the prior discussion.

@teknium1 teknium1 closed this Jul 14, 2026
@teknium1 teknium1 added sweeper:implemented-on-main Sweeper: behavior already present on current main sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists platform/whatsapp WhatsApp Business adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:implemented-on-main Sweeper: behavior already present on current main sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants