From 47b02e961cb79f8bef3fdee63028e35e5462ccd9 Mon Sep 17 00:00:00 2001 From: alt-glitch Date: Sat, 25 Apr 2026 00:09:53 +0530 Subject: [PATCH] feat(discord): populate guild_id, parent_chat_id, message_id on SessionSource MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Discord knows all four identifiers for every inbound message — guild, channel (or thread), parent channel when in a thread, and the triggering message. Pass them into ``SessionSource`` via the new ``build_source()`` kwargs so downstream code (context-prompt builder, delivery, logging) can use them without re-resolving from discord.py objects. For auto-threaded messages, remember the original channel as the parent before swapping ``chat_id`` to the freshly created thread. Behavioural: still a no-op — nothing consumes these fields yet. --- gateway/platforms/discord.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gateway/platforms/discord.py b/gateway/platforms/discord.py index 3eaf6ac05e3..5d30f244e86 100644 --- a/gateway/platforms/discord.py +++ b/gateway/platforms/discord.py @@ -3261,6 +3261,7 @@ class DiscordAdapter(BasePlatformAdapter): if auto_thread and not skip_thread and not is_voice_linked_channel and not is_reply_message: thread = await self._auto_create_thread(message) if thread: + parent_channel_id = str(message.channel.id) is_thread = True thread_id = str(thread.id) auto_threaded_channel = thread @@ -3320,6 +3321,9 @@ class DiscordAdapter(BasePlatformAdapter): thread_id=thread_id, chat_topic=chat_topic, is_bot=getattr(message.author, "bot", False), + guild_id=str(message.guild.id) if message.guild else None, + parent_chat_id=parent_channel_id, + message_id=str(message.id), ) # Build media URLs -- download image attachments to local cache so the