feat(discord): trusted bot @mention bypasses involvement gate#967
Merged
Conversation
Allow trusted bots to @mention other bots into threads, treating the mention the same as a human @mention. Previously, all bot messages were blocked by the allow_bot_messages mode check (defaults to Off), even from trusted bots. Now, if a bot is in trusted_bot_ids AND explicitly @mentions this bot, the mode check is skipped entirely. This enables bot-to-bot coordination (e.g. a coordinator bot pulling reviewer bots into threads) without requiring human intervention for every thread.
|
All PRs must reference a prior Discord discussion to ensure community alignment before implementation. Please edit the PR description to include a link like: This PR will be automatically closed in 3 days if the link is not added. |
- Expanded code comment to explain this is a 'bot admission override' not just an involvement gate bypass - Updated config doc for trusted_bot_ids to document the @mention override behavior - Added should_admit_bot_message() integration test helper that mirrors the actual gating logic in EventHandler::message - Added 6 integration tests covering: Off+trusted mention (pass), Off+untrusted (block), Off+trusted no mention (block), Off+empty trusted_ids (block), Mentions+trusted (pass), All+untrusted (block)
- messaging.md: update design principle, gate flow diagram, practical impact table, config table, and add dedicated 'Trusted bot admission override' section - discord.md: update trusted_bot_ids section and involvement gate examples to show trusted bot path - config-reference.md: update trusted_bot_ids description
Collaborator
Author
|
LGTM ✅ — Trusted bot admission override What This PR DoesAllows trusted bots to @mention other bots into threads, treating the mention identically to a human @mention. The target bot becomes involved and processes the message regardless of How It WorksAdds a Findings
Review Team
What's Good (🟢)
|
thepagent
approved these changes
Jun 1, 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.
What
Allow trusted bots to @mention other bots into threads — treating the mention identically to a human @mention. The target bot becomes involved in the thread and will process the message.
Why
The current involvement gate (documented in #950) enforces "humans are gatekeepers" — only humans can pull a bot into a thread via @mention. Bot-to-bot @mention of a non-involved bot is silently dropped because
allow_bot_messagesdefaults toOff, which rejects all bot messages before any other check runs.This creates friction for legitimate bot-to-bot coordination:
trusted_bot_idsconfig already expresses trust, but that trust is gated behind the mode checkHow
In the bot message gating block (
src/discord.rs), added atrusted_mentioncheck before theallow_bot_messagesmode switch:If a trusted bot explicitly @mentions this bot, the entire mode check and trusted filter are skipped — the message proceeds as if it came from a human.
Behavior change
Opt-in only — no surprise for existing users
This feature is strictly opt-in:
trusted_bot_idsdefaults to empty → behavior is identical to beforetrusted_bot_idsget the new capabilitytrusted_bot_ids = [](default) is the opt-outtrusted_bot_idsare completely unaffectedIf a future need arises to allow
trusted_bot_idsfor other purposes without granting involvement bypass, we can add a dedicated flag at that point. For now, configuringtrusted_bot_idsimplies trust for thread involvement.Safety
trusted_bot_idsfieldmax_bot_turnsandbot_turnstracker still apply after involvementtrusted_bot_ids(default) preserves current behavior exactlyTesting
Added 4 unit tests for the pure
is_trusted_bot_mentiondecision function:Refs #949, #950