fix(slack): refresh thread context for investigations - #62299
Closed
oferlaor wants to merge 1 commit into
Closed
Conversation
Author
|
Refreshed onto current main at |
oferlaor
force-pushed
the
fix/slack-investigate-thread-context
branch
2 times, most recently
from
July 15, 2026 18:50
c315edb to
58f8f37
Compare
oferlaor
force-pushed
the
fix/slack-investigate-thread-context
branch
from
July 20, 2026 20:35
58f8f37 to
5141453
Compare
teknium1
pushed a commit
that referenced
this pull request
Jul 22, 2026
Once a thread has an active session, a later reply that explicitly @mentions the bot did not re-fetch Slack thread context, so the agent missed messages added to the thread after the initial hydrate (e.g. other bots/integrations replying in multi-agent workflows). The explicit mention is a fresh intent signal and now triggers a refresh. Mechanics: - SessionEntry gains a small persisted metadata dict, with SessionStore.get/set_session_metadata accessors (survives gateway restarts via the routing index). - The adapter stores a per-thread consumption watermark (slack_thread_watermark:<channel>:<thread>) recording the last thread ts the session consumed. - On explicit mention in an active thread, _fetch_thread_context runs with force_refresh=True (bypassing the TTL cache) and after_ts=<the watermark>, so only NOT-yet-seen messages are injected — as part of the new turn via channel_context. Prior conversation history is never rewritten, preserving prompt caching. - _fetch_thread_context caches raw conversations.replies payloads so watermark-scoped re-formatting needs no extra API call; formatting is split into _format_thread_context. - Thread session keys are built once in _build_thread_session_key (shared by the wake gate and the watermark accessors), still via build_session_key(). Fixes #23918. Supersedes #62299 (keyword-triggered refresh limited to 'investigate' prompts — the mention signal is the general fix). Salvaged from #23927 by @heathley, rebased onto the plugin adapter layout and rerouted through channel_context instead of text-prepend.
teknium1
pushed a commit
that referenced
this pull request
Jul 22, 2026
Once a thread has an active session, a later reply that explicitly @mentions the bot did not re-fetch Slack thread context, so the agent missed messages added to the thread after the initial hydrate (e.g. other bots/integrations replying in multi-agent workflows). The explicit mention is a fresh intent signal and now triggers a refresh. Mechanics: - SessionEntry gains a small persisted metadata dict, with SessionStore.get/set_session_metadata accessors (survives gateway restarts via the routing index). - The adapter stores a per-thread consumption watermark (slack_thread_watermark:<channel>:<thread>) recording the last thread ts the session consumed. - On explicit mention in an active thread, _fetch_thread_context runs with force_refresh=True (bypassing the TTL cache) and after_ts=<the watermark>, so only NOT-yet-seen messages are injected — as part of the new turn via channel_context. Prior conversation history is never rewritten, preserving prompt caching. - _fetch_thread_context caches raw conversations.replies payloads so watermark-scoped re-formatting needs no extra API call; formatting is split into _format_thread_context. - Thread session keys are built once in _build_thread_session_key (shared by the wake gate and the watermark accessors), still via build_session_key(). Fixes #23918. Supersedes #62299 (keyword-triggered refresh limited to 'investigate' prompts — the mention signal is the general fix). Salvaged from #23927 by @heathley, rebased onto the plugin adapter layout and rerouted through channel_context instead of text-prepend.
Contributor
|
Closing as superseded by #69320 (merged): keyword-triggered ('investigate') refresh was narrower than the explicit-mention watermark-delta refresh that landed; the general mechanism covers your use case. Thanks for digging into this — the consolidated fix stands on the cluster's collective analysis, and your work is credited in #69320's summary. |
randlee
pushed a commit
to randlee/hermes-agent
that referenced
this pull request
Aug 11, 2026
Once a thread has an active session, a later reply that explicitly @mentions the bot did not re-fetch Slack thread context, so the agent missed messages added to the thread after the initial hydrate (e.g. other bots/integrations replying in multi-agent workflows). The explicit mention is a fresh intent signal and now triggers a refresh. Mechanics: - SessionEntry gains a small persisted metadata dict, with SessionStore.get/set_session_metadata accessors (survives gateway restarts via the routing index). - The adapter stores a per-thread consumption watermark (slack_thread_watermark:<channel>:<thread>) recording the last thread ts the session consumed. - On explicit mention in an active thread, _fetch_thread_context runs with force_refresh=True (bypassing the TTL cache) and after_ts=<the watermark>, so only NOT-yet-seen messages are injected — as part of the new turn via channel_context. Prior conversation history is never rewritten, preserving prompt caching. - _fetch_thread_context caches raw conversations.replies payloads so watermark-scoped re-formatting needs no extra API call; formatting is split into _format_thread_context. - Thread session keys are built once in _build_thread_session_key (shared by the wake gate and the watermark accessors), still via build_session_key(). Fixes NousResearch#23918. Supersedes NousResearch#62299 (keyword-triggered refresh limited to 'investigate' prompts — the mention signal is the general fix). Salvaged from NousResearch#23927 by @heathley, rebased onto the plugin adapter layout and rerouted through channel_context instead of text-prepend.
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.
Summary
investigate,investigate ..., andinvestigate: ...thread replies even when a Hermes session already exists.Root cause
Slack thread context is normally fetched only when entering a thread with no active Hermes session. If an earlier empty or interrupted turn created the session without useful context, a later
investigaterequest skipped_fetch_thread_context()and the agent missed the parent alert/request.This keeps normal thread messages unchanged and refreshes context only for explicit investigation triggers.
Supersedes closed #23141 with a current-main port to
plugins/platforms/slack/adapter.py.Validation
scripts/run_tests.sh tests/gateway/test_slack.py tests/gateway/test_slack_channel_session_scope.py tests/gateway/test_slack_mention.py -q→329 passed.venv/bin/ruff check plugins/platforms/slack/adapter.py tests/gateway/test_slack.py→ passedgit diff --check origin/main...HEAD→ passedCurrent status
Rebased onto current
main(d7b36070ef807841699ad32c5b6af547fee3ff64) on 2026-07-20 while preserving newer workspace-scoped Slack thread state. No unresolved review threads at refresh time.