fix: prevent Discord NO_REPLY bot loops#29932
Open
JeffreyDavidson wants to merge 1 commit into
Open
Conversation
zombi3butt
pushed a commit
to zombi3butt/hermes-agent
that referenced
this pull request
May 21, 2026
Three-layer fix for Discord bot-to-bot silence token handling: 1. Entry filter (_handle_message): Drop Discord bot messages with content exactly "NO_REPLY" before they enter the agent loop. When DISCORD_ALLOW_BOTS=mentions, other bots' NO_REPLY must be ignored. 2. Backfill exclusion (_fetch_channel_context): Exclude NO_REPLY sentinel messages from channel history backfill so they don't contaminate session context. 3. Delivery suppression (send): Suppress literal NO_REPLY responses from being sent to Discord channels — it's a control/silence token, not user-facing content. Fixes noisy bot-to-bot loops caused by agent silence being surfaced as empty-response retries.
19 tasks
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
NO_REPLYbefore they can enter the agent loopNO_REPLYsentinel messages from Discord channel history backfillNO_REPLYplatform responses at delivery timeWhy
When bot-to-bot routing is enabled with
DISCORD_ALLOW_BOTS=mentions, a botNO_REPLYsentinel can be treated as a real prompt. If the receiving agent then intentionally stays silent, the gateway can surface empty-response retries and create noisy bot-to-bot loops.NO_REPLYshould behave as a control/silence token, not a user prompt.Verification
./venv/bin/python -m pytest tests/gateway/test_discord_bot_filter.py tests/gateway/test_discord_bot_auth_bypass.py -q