feat(gateway): unified thread context hook in BasePlatformAdapter - #7466
Closed
Tranquil-Flow wants to merge 3 commits into
Closed
feat(gateway): unified thread context hook in BasePlatformAdapter#7466Tranquil-Flow wants to merge 3 commits into
Tranquil-Flow wants to merge 3 commits into
Conversation
This was referenced Apr 11, 2026
Tranquil-Flow
force-pushed
the
feat/unified-thread-context
branch
from
May 18, 2026 21:29
007de5a to
ea960da
Compare
|
We've merged this into our local for two different Hermes installs -- getting the tests to pass wasn't too difficult and would be worth it to the community so we can have Hermes use the thread as a resource before wandering off to check every existing session for tips! |
Add fetch_thread_context() and has_active_session_for_event() to BasePlatformAdapter, providing a single extension point for platform adapters to fetch thread/conversation history when the bot first enters an existing thread. - Refactors Slack's existing thread context fetching into the new hook - Adds Discord implementation using channel.history(), giving Discord feature parity with Slack for thread context - Session liveness check evaluates reset policy (idle/daily expiry) so expired sessions still get context seeded and don't auto-trigger without @mention - Commands (/reset, /status, etc.) are not prefixed with context - Base default returns None so unimplemented platforms are unaffected Fixes NousResearch#6708 Related to NousResearch#6712 (absorbs Discord thread context into unified pattern) Related to NousResearch#1953, NousResearch#2950, NousResearch#5816 (Slack fixes refactored into base hook)
Tranquil-Flow
force-pushed
the
feat/unified-thread-context
branch
from
May 25, 2026 11:07
ea960da to
0be92f6
Compare
Contributor
|
Thanks for the unified treatment of thread context and for covering reset and command cases. Problems
Suggested changes
Automated hermes-sweeper review. |
Contributor
Author
|
Closing — current main already implements the Discord thread history backfill and related thread context hooks. This PR's porting step conflicts with the current adapter code; the remaining gap is small and the new shape is already in place. Thanks for the review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds
fetch_thread_context()andhas_active_session_for_event()toBasePlatformAdapter, providing a single extension point for platform adapters to fetch thread/conversation history when the bot first enters an existing thread._fetch_thread_context()into the new base class hook (no behavioral change for Slack users)fetch_thread_context()override usingchannel.history(), giving Discord feature parity with SlackNoneKey design decisions
has_active_session_for_event()calls_should_reset()on the entry, so expired sessions (idle timeout, daily reset) still get thread context seeded into the new sessionis_command()guard in the base call site prevents/reset,/status, etc. from having context prepended, which would break command parsing_has_active_session_for_thread()now delegates to the sharedhas_active_session_for_event(), so the "respond without @mention" check also respects session expiryRelated Issue
Fixes #6708
Related to #6712 (absorbs Discord thread context approach into unified base class pattern); #1953, #2950, #5816 (already fixed for Slack by #5890; this refactors the Slack implementation into a reusable hook); #6345, #7304 (complementary features — agent-side history tool and restart resilience).
Type of Change
Changes Made
gateway/platforms/base.py—has_active_session_for_event(),fetch_thread_context(), call site in_process_message_background()gateway/platforms/slack.py—fetch_thread_context()override,_has_active_session_for_thread()delegation, removed old inline call sitegateway/platforms/discord.py—fetch_thread_context()override usingchannel.history()tests/gateway/test_thread_context_hook.py— 18 new tests (base helper, integration, Discord override)tests/gateway/test_slack_approval_buttons.py— updated existing mocks for reset policy checkHow to Test
[Thread context]in the first response/resetinside a thread should work as a command, not get context prepended/newinside threads should work normallyChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs