Skip to content

fix(discord): fetch and inject reply context for incoming messages#30950

Closed
alaamohanad169-ship-it wants to merge 2 commits into
NousResearch:mainfrom
alaamohanad169-ship-it:fix/discord-reply-context-v2
Closed

fix(discord): fetch and inject reply context for incoming messages#30950
alaamohanad169-ship-it wants to merge 2 commits into
NousResearch:mainfrom
alaamohanad169-ship-it:fix/discord-reply-context-v2

Conversation

@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor

Summary

When a user replies to a message in Discord, Hermes now fetches the referenced message content via API when Discord does not provide it inline (common for older/high-traffic messages), and prepends reply context to the message text so the agent understands what the user is responding to.

Changes

  • Fetch reply-to message from Discord API when resolved is None
  • Prepend [Replying to: "..."] context to the message text (truncated to 200 chars)
  • Graceful error handling — logs debug and continues if fetch fails

Fixes #30049

@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/discord Discord bot adapter duplicate This issue or pull request already exists labels May 23, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #30085 — same fix (Discord reply context fetch+inject), same author. Also related to #5348 (similar approach with TTL cache + author attribution).

@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor Author

Note: This is a clean rebase of the previously closed PR #30085. The old PR was closed due to upstream divergence. This version is rebased on latest main with only the reply-context changes.

The related PR #5348 (luinbytes) takes a similar approach but adds TTL caching and author attribution. My approach is simpler — just fetch and inject the reply context. If maintainers prefer the caching approach, happy to collaborate or close this in favor of #5348.

@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor Author

Note to maintainers: The alt-glitch bot flagged this as a duplicate. This is incorrect. The original PRs were closed because they were stale (far behind upstream main). This is the clean rebased version cherry-picked onto latest main. The old PRs referenced by the bot no longer exist.

@alaamohanad169-ship-it alaamohanad169-ship-it force-pushed the fix/discord-reply-context-v2 branch from f70dbee to 673f9f4 Compare May 23, 2026 23:14
@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor Author

Update: Rebased onto latest main with clean diff. Previous version had accumulated unrelated changes from a bad cherry-pick. This version contains only the reply-context fix: 14 insertions, 0 deletions in gateway/platforms/discord.py.

The fix: when a user replies to a Discord message, Hermes now fetches the referenced message content via API when Discord does not provide it inline (common for older/high-traffic messages), and prepends reply context to the message text so the agent understands what the user is responding to.

Fixes #30049

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/discord Discord bot adapter type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(gateway): resolve replied/quoted message context in Discord and WhatsApp

2 participants