Skip to content

fix(discord): recall prior thread context after bot replies - #52650

Open
reefmind wants to merge 1 commit into
NousResearch:mainfrom
reefmind:fix-discord-thread-history-access
Open

fix(discord): recall prior thread context after bot replies#52650
reefmind wants to merge 1 commit into
NousResearch:mainfrom
reefmind:fix-discord-thread-history-access

Conversation

@reefmind

Copy link
Copy Markdown

Summary

  • allow Discord thread history backfill to continue past Hermes' last reply in threads
  • skip Hermes-authored messages while recalling earlier human thread context
  • add regression coverage for short follow-ups like “fix it” after Hermes previously answered it could not see history

Tests

  • python -m pytest tests/gateway/test_discord_free_response.py -q
  • python -m ruff check plugins/platforms/discord/adapter.py tests/gateway/test_discord_free_response.py
  • python -m py_compile plugins/platforms/discord/adapter.py tests/gateway/test_discord_free_response.py

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/discord Discord bot adapter P3 Low — cosmetic, nice to have sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Jun 25, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related: #42075 (skip bot messages in thread backfill) and #51414 (history_full_thread opt-in). Same goal (recall earlier human thread context past Hermes' last reply) but a different mechanism here: thread-scoped, config-gated (thread_history_recall / DISCORD_THREAD_HISTORY_RECALL, default on), and it segregates earlier-vs-recent context into separate windows. Not a duplicate — maintainer should pick among the competing approaches.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for isolating the thread-history gap and adding a focused cold-start regression test.

Problems

  • The new continuation branch does not work after a normal Hermes response. The unchanged after=_after_obj call at plugins/platforms/discord/adapter.py:4414 filters out messages at or before the cached self-message ID before the new if recall_thread_history branch at :4433 can see them. Current main stores that cache after normal sends at plugins/platforms/discord/adapter.py:2085-2092.
  • The new regression test at tests/gateway/test_discord_free_response.py:682 does not seed _last_self_message_id, so it covers only the cache-miss path.

Suggested changes

  • Disable or adjust the cached after boundary when recall is enabled, and add a cache-seeded regression case.
  • Coordinate the default/configuration choice with the related approaches cited in the existing triage note (#42075 and #51414).

Automated hermes-sweeper review.

# session transcript. (Redundant when _after_obj is set, but
# needed for cold start.)
if msg.author == self._client.user:
if recall_thread_history:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch is unreachable for the normal hot path: the unchanged channel.history(..., after=_after_obj) above already excludes every message at or before _last_self_message_id, and normal sends populate that cache. Disable/adjust that after boundary when recall is enabled, then add a regression test that seeds _last_self_message_id.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have platform/discord Discord bot adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants