hermes - 💡(How to fix) Fix Discord auto-thread backfill fetches from parent channel instead of thread

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

_handle_message at line 4786-4788:

_backfill_text = await self._fetch_channel_context(
    message.channel, before=message,
)

message.channel is set before auto-threading occurs and still points to the parent text channel. The session itself is correctly routed to the thread via effective_channel (set at line 4601), but the backfill bypasses it.

This means the backfill grabs messages from the entire parent channel instead of just the thread — leaking context from unrelated conversations into the session.

Fix Action

Fix

Change line 4787 to use effective_channel:

_backfill_text = await self._fetch_channel_context(
    effective_channel, before=message,
)

Code Example

_backfill_text = await self._fetch_channel_context(
    message.channel, before=message,
)

---

_backfill_text = await self._fetch_channel_context(
    effective_channel, before=message,
)
RAW_BUFFERClick to expand / collapse

Bug

When auto-threading is enabled and a user @mentions the bot in a text channel, the backfill at _handle_message line 4787 fetches recent channel context from message.channel (the parent channel) instead of the newly-created thread.

Root Cause

_handle_message at line 4786-4788:

_backfill_text = await self._fetch_channel_context(
    message.channel, before=message,
)

message.channel is set before auto-threading occurs and still points to the parent text channel. The session itself is correctly routed to the thread via effective_channel (set at line 4601), but the backfill bypasses it.

This means the backfill grabs messages from the entire parent channel instead of just the thread — leaking context from unrelated conversations into the session.

Fix

Change line 4787 to use effective_channel:

_backfill_text = await self._fetch_channel_context(
    effective_channel, before=message,
)

Additional Note

There is a secondary cache-miss issue: the _last_self_message_id cache (keyed by thread_id at line 1470) never matches the backfill's lookup (keyed by message.channel.id = parent channel ID), so the after optimization at line 3747-3751 never fires for auto-threaded conversations. Fixing the channel above also fixes the cache.

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 auto-thread backfill fetches from parent channel instead of thread