Skip to content

fix(slack): fetch thread context when bot is mentioned in a thread - #1965

Closed
ygd58 wants to merge 1 commit into
NousResearch:mainfrom
ygd58:fix/slack-thread-context-on-mention
Closed

fix(slack): fetch thread context when bot is mentioned in a thread#1965
ygd58 wants to merge 1 commit into
NousResearch:mainfrom
ygd58:fix/slack-thread-context-on-mention

Conversation

@ygd58

@ygd58 ygd58 commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

Fixes #1953

Problem

When @mentioning Hermes in a Slack thread, it had no awareness of the thread's conversation history. It could only see the current message.

Fix

When the bot is mentioned inside a thread (thread_ts != ts), fetch the last 20 messages via conversations_replies API and prepend them to the message as context:

[Thread context:]
User: test
User: @rocky can you read this thread

[New message:]

Notes

  • Only fetches context when bot is mentioned in a thread (not top-level messages)
  • Graceful fallback: if API call fails, proceeds without context
  • Bot's own messages labeled as "Assistant", user messages labeled with their display name

@ygd58
ygd58 force-pushed the fix/slack-thread-context-on-mention branch from 84cb95f to 4b26503 Compare March 18, 2026 17:37
@ygd58

ygd58 commented Mar 18, 2026

Copy link
Copy Markdown
Contributor Author

The test failures (ImportError: cannot import name '_rich_text_from_ansi') are pre-existing failures unrelated to this PR. The function was removed from cli.py in a previous upstream commit but the test file wasn't updated. The slack.py changes are isolated and clean.

@ygd58
ygd58 force-pushed the fix/slack-thread-context-on-mention branch from 4b26503 to d886054 Compare March 19, 2026 16:16
@teknium1

teknium1 commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Superseded by PR #5890 which implements thread context fetching (based on the improved approach from PR #2953 by the same author). Thank you @ygd58!

@teknium1 teknium1 closed this Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Slack bot doesn't fetch the thread when it gets mentioned

2 participants