Reply/quote context propagation across chat adapters
NousResearch/hermes-agent · cluster 1594 · gateway
Data as of
7 open items. Fix merged in #1662. Check it covers your case.
The short answer
- Known?
- Yes. 15 related items grouped here, 2 issues already closed.
- Fix event
- A fix was merged to main in PR #1662. Check it covers your case. No release data is tracked.
- Tracker
- The maintainers' tracker marks this
partially resolved, deciding PR #1662. That is separate from the fix event. - Still open
- 2 issues and 5 PRs.
Next step: read #1662, then check whether your report is one of the 2 still open.
Read #1662Pick up a Lab taskThese issues and PRs address missing or dropped reply-to and quoted message context across multiple chat platforms including Google Chat, WhatsApp, Matrix, and Telegram. Work spans adapter-level fixes and gateway-level logic to ensure reply context reaches agents and LLM prompts.
Open issues2
Open PRs5
- PR#28962fix(matrix): preserve Element reply quote context
- PR#56614fix(gateway): populate reply_to_text/reply_to_message_id from Google Chat quotedMessageMetadata
- PR#56622fix(google_chat): populate reply_to_* fields from quotedMessageMetadata (#56607)
- PR#68428fix: treat [object Object] sentinel as absent in Telegram reply_to_text
- PR#105137fix(google-chat): preserve quoted reply context
Fixes on record
-
#1662 feat(gateway): inject reply-to message context for out-of-session replies (#1594)
files:
gateway/platforms/base.py,gateway/platforms/telegram.py,gateway/run.pyShow the diff
-
gateway/platforms/base.py@@ -294,6 +294,7 @@ class MessageEvent: # Reply context reply_to_message_id: Optional[str] = None + reply_to_text: Optional[str] = None # Text of the replied-to message (for context injection) # Timestamps timestamp: datetime = field(default_factory=datetime.now) -
gateway/platforms/telegram.py@@ -1185,11 +1185,20 @@ def _build_message_event(self, message: Message, msg_type: MessageType) -> Messa thread_id=str(message.message_thread_id) if message.message_thread_id else None, ) + # Extract reply context if this message is a reply + reply_to_id = None + reply_to_text = None + if message.reply_to_message: + reply_to_id = str(message.reply_to_message.message_id) + reply_to_text = message.reply_to_message.text or message.reply_to_message.caption or None + return MessageEvent( text=message.text or "", message_type=msg_type, source=source, raw_message=message, message_id=str(message.message_id), + reply_to_message_id=reply_to_id, + reply_to_text=reply_to_text, timestamp=message.date, ) -
gateway/run.py@@ -1849,6 +1849,23 @@ async def _handle_message(self, event: MessageEvent) -> Optional[str]: ) message_text = f"{context_note}\n\n{message_text}" + # ----------------------------------------------------------------- + # Inject reply context when user replies to a message not in history. + # Telegram (and other platforms) let users reply to specific messages, + # but if the quoted message is from a previous session, cron delivery, + # or background task, the agent has no context about what's being + # referenced. Prepend the quoted text so the agent understands. (#1594) + # ----------------------------------------------------------------- + if getattr(event, 'reply_to_text', None) and event.reply_to_message_id: + reply_snippet = event.reply_to_text[:500] + found_in_history = any( + reply_snippet[:200] in (msg.get("content") or "") + for msg in history + if msg.get("role") in ("assistant", "user", "tool") + ) + if not found_in_history: + message_text = f'[Replying to: "{reply_snippet}"]\n\n{message_text}' + try: # Emit agent:start hook hook_ctx = {
-
5 PRs closed without merging
From the close comments: done elsewhere 2 · duplicate 1 · merged via another change 1 · stale or abandoned 1
-
#1596 feat(gateway): inject reply-to message context for out-of-session replies · merged via another change →
#1662 -
#16552 fix: propagate WhatsApp reply context · done elsewhere →
11627fd - #27983 fix(matrix): re-inject quoted reply context into LLM prompt (#27946) · stale or abandoned
-
#28878 fix(whatsapp): forward quotedMessageId/context to agent prompt · done elsewhere →
11627fd,#28823 -
#57171 fix(google-chat): preserve quoted reply context · duplicate →
#56614
Closed issues · 2
How this cluster was grouped
-
Link evidence (
partly structural links): some members are connected by structural evidence (shared changed files, or a closing/superseded reference); the rest are joined by an automated relevance judgement over their text. - Members outside that structural core may belong to a different underlying problem.
-
Pairwise link density
0.12: the share of item pairs that carry a link, counting a structural link in full and a relevance-only link at 0.36.1.00means every pair is linked.
Pick up a Lab task
Check whether a fix covers the open issues here, with your own agent. Bring back evidence for maintainers.
Open the LabAt a glance
- Subsystem
- gateway
- Merged PRs
- #1662
- Closed issues
- 2
- Attempts
- 5 PRs closed without merging
- Fix link checked
- 17 Mar 2026. This confirmation is old and may be out of date (a revert or reopen would not have invalidated it here); re-verify.