Populate reply_to_text for Discord message replies#5348
Open
luinbytes wants to merge 1 commit into
Open
Conversation
Contributor
|
Nice approach — the three-tier lookup (resolved → cache → API fetch) is exactly right, and the author attribution makes it much more useful than a raw quote. @teknium1 this is a genuinely missing feature for Discord interactions — replies to cron notifications and similar messages lose all context. Happy to help rebase if there are conflicts, or test anything further. Would be great to get this moving. |
messages to avoid redundant API calls - Include author display_name in reply_to_text so the agent knows who wrote the original message - Fall back to message caption for replies to media-only messages - Guard against message_id being None on partial references
51520ea to
cfa1f91
Compare
Author
|
bump — rebased onto latest upstream, all conflicts resolved. @teknium1 |
7 tasks
Gerkinfeltser
pushed a commit
to Gerkinfeltser/hermes-agent
that referenced
this pull request
Apr 16, 2026
…e is absent When a thread is created via 'Create Thread' (right-click), messages inside the thread have no message.reference field. Fall back to message.channel.message_id (the thread's origin message ID) to fetch the OP content and populate reply_to_text. Fixes: NousResearch#5348
This was referenced May 23, 2026
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
Discord replies pass
reply_to_message_idbut never populatereply_to_text. Other platforms (Telegram, Feishu, WeCom) already set this field, andrun.py(line 2750) injects it as[Replying to: "..."]context when the quoted message isn't in session history. Discord just skips this entirely.What it does
On incoming Discord messages with
message.reference:reference.resolved(cached by discord.py, no API call)channel.fetch_message()for older messagesIn-memory reply cache
Repeated replies to the same message no longer trigger separate API calls. The cache stores
(author_name, text, timestamp)per message ID, with a 5-minute TTL and 500-entry cap. Pruning follows the same pattern as the existing_seen_messagesdedup cache.Author attribution
reply_to_textincludes the author's display name (e.g."Lu: can you see that i replied?") so the agent knows who wrote the original message. This is baked into the text field rather than requiring changes toMessageEventorrun.py.Edge cases
message_idisNoneon partial references (deleted messages) — guarded,reply_to_textstaysNoneresolved_referenceisNonefor older messages — fetched from API and cachedreply_to_textstaysNonecontentis empty, filtered toNone