hermes - 💡(How to fix) Fix Feature: Discord message catch-up on gateway reconnect [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#16754Fetched 2026-04-28 06:50:57
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×4

When the Hermes Discord gateway goes offline (restart, crash, network issue), any messages sent by the user during the downtime are lost. The bot has no way to catch up on missed messages when it reconnects.

Root Cause

When the Hermes Discord gateway goes offline (restart, crash, network issue), any messages sent by the user during the downtime are lost. The bot has no way to catch up on missed messages when it reconnects.

Code Example

GET /channels/{channel_id}/messages?after={last_message_id}&limit=50
RAW_BUFFERClick to expand / collapse

Summary

When the Hermes Discord gateway goes offline (restart, crash, network issue), any messages sent by the user during the downtime are lost. The bot has no way to catch up on missed messages when it reconnects.

Proposed Solution

  1. Persist last-seen message ID: After processing each Discord message, save the message ID to a local file (e.g., ~/.hermes/discord_last_message_id)
  2. Catch-up on startup: When the Discord gateway connects (or reconnects), call the Discord REST API:
    GET /channels/{channel_id}/messages?after={last_message_id}&limit=50
  3. Process missed messages: Feed retrieved messages through the normal message processing pipeline, as if they had just arrived via the WebSocket gateway

Implementation Details

  • The bot token and channel ID are already available in the gateway config
  • The Discord REST API (GET /channels/{id}/messages) supports pagination with before/after cursors
  • Should respect rate limits (5 requests per 5 seconds per channel)
  • Could optionally have a max catch-up window (e.g., only process messages from the last hour) to avoid replaying very old commands

Use Case

User sends instructions to the bot while the agent is temporarily down (e.g., during a restart or update). Currently these messages are silently lost. With catch-up, the agent would process them on next startup, making the bot more reliable for time-sensitive tasks.

Environment

  • Hermes Agent running on WSL with Discord gateway
  • Bot connected via WebSocket, message processing is real-time only

Alternatives Considered

  • Scheduled DB polling: Not applicable since Discord messages are push-only via gateway
  • External message queue: Over-engineered for this use case
  • User re-sends messages: Poor UX, defeats the purpose of a background agent

extent analysis

TL;DR

Implementing a message catch-up mechanism by persisting the last-seen message ID and using the Discord REST API to retrieve missed messages on startup is likely to fix the issue of lost messages during downtime.

Guidance

  • To verify the proposed solution, test the bot's behavior during a simulated downtime and restart, checking if messages sent during downtime are processed correctly after the bot reconnects.
  • Consider implementing rate limiting to avoid exceeding the Discord API's request limits (5 requests per 5 seconds per channel) when catching up on missed messages.
  • A max catch-up window (e.g., only process messages from the last hour) could be introduced to prevent replaying very old commands and reduce the load on the bot.
  • Ensure the bot token and channel ID are correctly configured and available in the gateway config to use the Discord REST API for catching up on missed messages.

Example

import requests

# Assuming last_message_id is persisted and loaded correctly
last_message_id = load_last_message_id()
channel_id = get_channel_id()
bot_token = get_bot_token()

# Catch-up on startup
url = f"https://discord.com/api/channels/{channel_id}/messages?after={last_message_id}&limit=50"
headers = {"Authorization": f"Bearer {bot_token}"}
response = requests.get(url, headers=headers)

# Process retrieved messages
for message in response.json():
    process_message(message)

Notes

The proposed solution relies on the Discord REST API and the bot's ability to persist and load the last-seen message ID. Ensure that the bot's configuration and environment support these requirements.

Recommendation

Apply the proposed workaround by implementing the message catch-up mechanism, as it addresses the issue of lost messages during downtime and provides a reliable way to process missed messages on startup.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix Feature: Discord message catch-up on gateway reconnect [1 participants]