Skip to content

feat(gateway): auto-respond in Slack threads without @mention#2764

Closed
ondraz wants to merge 1 commit into
NousResearch:mainfrom
ondraz:feat/slack-auto-respond-in-threads
Closed

feat(gateway): auto-respond in Slack threads without @mention#2764
ondraz wants to merge 1 commit into
NousResearch:mainfrom
ondraz:feat/slack-auto-respond-in-threads

Conversation

@ondraz

@ondraz ondraz commented Mar 24, 2026

Copy link
Copy Markdown

Summary

  • Port the Discord thread participation tracking pattern to the Slack adapter
  • When enabled, the bot responds to follow-up messages in threads where it has already participated — no @mention required
  • Thread participation is persisted to ~/.hermes/slack_threads.json (capped at 500 entries) so it survives restarts
  • Feature is off by default, enabled via config.yaml or env var:
slack:
  auto_respond_threads: true

Or: SLACK_AUTO_RESPOND_THREADS=true

Changes

  • gateway/platforms/slack.py: Add thread participation tracking (_bot_participated_threads) and gate the mention-skip on the new config flag
  • gateway/config.py: Bridge slack.auto_respond_threads from config.yaml to env var
  • tests/gateway/test_slack.py: 6 new tests

Test plan

  • Message in participated thread is processed without @mention (when enabled)
  • Message in participated thread still requires @mention when feature is disabled
  • Message in unknown thread without @mention is ignored
  • @mention in a thread tracks participation
  • Top-level @mention tracks the message ts as thread
  • DM messages don't track thread participation
  • All existing tests still pass

Platforms tested

  • macOS (Darwin 25.3.0)

🤖 Generated with Claude Code

Port the Discord thread participation tracking to the Slack adapter.
When the bot has already participated in a thread (via @mention), it
will now respond to follow-up messages in that thread without requiring
a new @mention — matching the existing Discord behaviour.

The feature is off by default and can be enabled via config.yaml:

  slack:
    auto_respond_threads: true

Or via env var: SLACK_AUTO_RESPOND_THREADS=true

- Track thread IDs where the bot has participated, persisted to
  ~/.hermes/slack_threads.json (capped at 500 entries)
- Skip the mention check for messages in tracked threads (when enabled)
- Add config bridging in gateway/config.py (slack.auto_respond_threads → env var)
- Add 6 tests covering the new behaviour

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
jeremiahrthompson pushed a commit to sumofagents/hermes-agent that referenced this pull request Apr 1, 2026
Add two new hook events that fire in BasePlatformAdapter for ALL platform
adapters without requiring per-adapter modification:

- message:received: fires before session registration, hooks can set
  context['should_process']=False to drop the message silently. Uses
  asyncio.wait_for with configurable 5s timeout (HERMES_HOOK_TIMEOUT).
  Fail-open on timeout and exception (hooks never break message delivery).

- message:processed: fires after agent response is sent (or on error),
  includes response text, success flag, and error string.

Both hooks use the existing HookRegistry. set_hooks() added to
BasePlatformAdapter to wire the registry from GatewayRunner. No
adapter files modified — all 12 adapters inherit hook support via
BasePlatformAdapter.

Ref: NousResearch#3539 NousResearch#2764 NousResearch#3434
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for this PR @ondraz! The core feature — auto-responding in Slack threads where the bot has participated without requiring a repeat @mention — has since been implemented on main via commit e49c8bb (feat(slack): thread engagement — auto-respond in bot-started and mentioned threads (#5897), merged April 7, 2026).

This is an automated hermes-sweeper review.

Evidence:

Design differences worth noting:

  • Main's implementation is always-on within the existing require_mention gate, rather than a separate auto_respond_threads opt-in flag as proposed here
  • Main does not persist thread participation across restarts (slack_threads.json) — participation is in-memory only

If either of those gaps matters to you (opt-in flag for users with require_mention: true, or restart-survivable persistence), a focused follow-up PR targeting just those additions would be a clean fit on top of the current implementation.

@teknium1 teknium1 closed this Apr 27, 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.

2 participants