Fix WhatsApp same-session quote re-injection.

Strip @mention prefixes and widen history lookup so reply-to of the bot's own prior answer is not wrapped as [被引用消息] again.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-07-22 10:24:23 +08:00
parent 2446993b11
commit 10ae4abc1d
3 changed files with 153 additions and 19 deletions

View file

@ -1318,7 +1318,9 @@ def process_inbound_payload(payload: dict[str, Any]) -> dict[str, Any]:
quoted_info = extract_group_quoted_message(metadata=meta_for_group)
quoted_text = str(quoted_info.get("quoted_text") or "").strip()
if quoted_text:
recent_messages = store.get_messages(str(session_id), limit=6)
# Look back far enough to cover long tool loops; dedupe uses
# assistant bodies so same-session reply-to will not re-inject.
recent_messages = store.get_messages(str(session_id), limit=80)
if should_inject_quoted_context(
quoted_text=quoted_text,
recent_messages=recent_messages,