fix(gateway): backfill Discord thread context

Discord threads where the bot has already participated bypass mention gating by default, but the backfill check was still tied to the mention-needed condition. That meant follow-up thread messages could trigger a response without providing recent thread history to the session.

Run history backfill for thread messages whenever backfill is enabled, while keeping DMs skipped and channel mention backfill behavior unchanged. Add a regression test for a known thread follow-up without an explicit mention.

Fixes #33666

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Pluviobyte
2026-05-28 04:52:02 -07:00
committed by Teknium
co-authored by Cursor
parent a1eaad2fc0
commit eafe11d456
3 changed files with 23 additions and 1 deletions
+1 -1
View File
@@ -4818,7 +4818,7 @@ class DiscordAdapter(BasePlatformAdapter):
and not in_bot_thread
)
_backfill_enabled = self._discord_history_backfill()
if _needed_mention and _backfill_enabled:
if _backfill_enabled and (_needed_mention or is_thread):
_backfill_text = await self._fetch_channel_context(
message.channel, before=message,
)