hermes - 💡(How to fix) Fix Discord thread backfill skipped when in_bot_thread is true (thread_require_mention=false) [3 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

gateway/platforms/discord.py line 4671-4677:

_needed_mention = (
    require_mention
    and not is_free_channel
    and not in_bot_thread      # false when thread_require_mention=false
)
_backfill_enabled = self._discord_history_backfill()
if _needed_mention and _backfill_enabled:
    # backfill never runs for threads

Backfill is gated on _needed_mention, which requires in_bot_thread == false. But thread_require_mention: false (the default) sets in_bot_thread = true, so backfill always skips.

The condition conflates "mention was needed" with "backfill is needed" — they are separate concerns. A thread where the bot responds freely still benefits from backfilling recent thread history.

Fix Action

Fixed

Code Example

_needed_mention = (
    require_mention
    and not is_free_channel
    and not in_bot_thread      # false when thread_require_mention=false
)
_backfill_enabled = self._discord_history_backfill()
if _needed_mention and _backfill_enabled:
    # backfill never runs for threads

---

if _needed_mention and _backfill_enabled:

---

if _backfill_enabled and (_needed_mention or is_thread):
RAW_BUFFERClick to expand / collapse

Bug

When discord.thread_require_mention: false (or default, which is false), in_bot_thread evaluates to true for threads the bot has previously participated in. This bypasses the @mention requirement — but it also silently disables history backfill.

Root Cause

gateway/platforms/discord.py line 4671-4677:

_needed_mention = (
    require_mention
    and not is_free_channel
    and not in_bot_thread      # false when thread_require_mention=false
)
_backfill_enabled = self._discord_history_backfill()
if _needed_mention and _backfill_enabled:
    # backfill never runs for threads

Backfill is gated on _needed_mention, which requires in_bot_thread == false. But thread_require_mention: false (the default) sets in_bot_thread = true, so backfill always skips.

The condition conflates "mention was needed" with "backfill is needed" — they are separate concerns. A thread where the bot responds freely still benefits from backfilling recent thread history.

Steps to Reproduce

  1. Default config: discord.thread_require_mention: false (or unset)
  2. Bot has participated in a thread (so thread_id in self._threads)
  3. User sends a message in that thread (with or without @mention)
  4. Bot responds but has no thread context via backfill

Check gateway.log — no "fetching channel context" entries for thread messages.

Expected

Backfill runs for thread messages regardless of whether thread_require_mention is true or false. The backfill's purpose is to provide thread context, not just to fill the "mention gap".

Suggested Fix

gateway/platforms/discord.py line 4677 — change:

if _needed_mention and _backfill_enabled:

to:

if _backfill_enabled and (_needed_mention or is_thread):

This ensures threads always get backfill when history_backfill is enabled, independent of the mention gate.

Related

  • #31467 — Discord auto-thread backfill fetches from parent channel instead of thread
  • #16725 — Discord known-thread participation bypass cannot be disabled
  • #23084 — discord.thread_require_mention YAML key is ignored (only env var works)
  • #20742 — Add Discord strict mention mode for thread follow-ups

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix Discord thread backfill skipped when in_bot_thread is true (thread_require_mention=false) [3 pull requests]