From 3fd24c72fdd60b82bc2308993a23c4fc24207c1b Mon Sep 17 00:00:00 2001 From: Alfredo Arenas Date: Sat, 18 Apr 2026 07:15:38 -0600 Subject: [PATCH] fix(discord): allow bot-to-bot messaging, only drop self-loops (#3217) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously the Discord channel dropped every message from any bot account via `if message.author.bot`, which prevented legitimate multi-agent setups (one bot asking another for help, bot-to-bot @mentions, etc.) from working. Narrow the guard to only drop messages from this bot's own account by comparing against self._bot_user_id (already populated in on_ready). Self-loop protection is preserved — each bot instance still ignores its own outbound messages. Co-authored with Claude Opus 4.7 --- nanobot/channels/discord.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/nanobot/channels/discord.py b/nanobot/channels/discord.py index 60ca06982..9710c5efc 100644 --- a/nanobot/channels/discord.py +++ b/nanobot/channels/discord.py @@ -433,8 +433,15 @@ class DiscordChannel(BaseChannel): raise async def _handle_discord_message(self, message: discord.Message) -> None: - """Handle incoming Discord messages from discord.py.""" - if message.author.bot: + """Handle incoming Discord messages from discord.py. + + Self-loop guard: only drop messages from this bot's own account. Messages + from other bots are allowed through so multi-agent setups (one bot asking + another for help, a bot mentioning another by @name, etc.) can work. + Bot-from-bot loops are still prevented per-instance because each bot + still ignores its own outbound messages. (#3217) + """ + if self._bot_user_id is not None and str(message.author.id) == self._bot_user_id: return sender_id = str(message.author.id)