Skip to content

feat(slack): add strict_mention gate for channel threads#12258

Closed
ching-kaching wants to merge 1 commit into
NousResearch:mainfrom
ching-kaching:slack-strict-mention
Closed

feat(slack): add strict_mention gate for channel threads#12258
ching-kaching wants to merge 1 commit into
NousResearch:mainfrom
ching-kaching:slack-strict-mention

Conversation

@ching-kaching

@ching-kaching ching-kaching commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

Problem

In Slack channel threads, once the bot has been @-mentioned once (or has any active session for that thread), it auto-responds to every subsequent message — even when humans are talking to each other and not addressing the bot. This makes it noisy and intrusive in multi-person threads.

The existing require_mention flag only gates the first message; once triggered, the bot sticks around forever.

Summary

Adds an opt-in strict_mention config for Slack. When enabled, the bot only responds in channel threads when explicitly @-mentioned in the specific message — disabling the 'once mentioned, forever in the thread', bot-message follow-up, and session-presence auto-triggers. Want a follow-up? @-mention again.

DMs and free-response channels are unaffected.

Changes

  • gateway/platforms/slack.py — new _slack_strict_mention() helper (reads platforms.slack.extra.strict_mention or SLACK_STRICT_MENTION env) + one-line gate in the channel mention-gating block
  • gateway/config.py — bridges top-level slack.strict_mention yaml → SLACK_STRICT_MENTION env, matching how require_mention / allow_bots / free_response_channels are already bridged
  • tests/gateway/test_slack_mention.py — 7 unit tests for the helper + 1 config bridge test

Config

slack:
  strict_mention: true   # default: false (backward-compatible)

Or via env: SLACK_STRICT_MENTION=true

Behavior matrix

Context Default strict_mention: true
DM Always responds Always responds
Free-response channel Always responds Always responds
Channel, explicit @mention Responds Responds
Channel thread, previously mentioned Responds (auto-trigger) Ignores until re-mentioned
Channel thread, has active session Responds (auto-trigger) Ignores until re-mentioned
Reply to bot's own message Responds Ignores until @mentioned

@ching-kaching ching-kaching force-pushed the slack-strict-mention branch 2 times, most recently from 538d5d6 to 059b2f6 Compare April 18, 2026 20:12
@ching-kaching ching-kaching changed the title feat(slack): add opt-in slack.strict_mention gate for channel threads feat(slack): add strict_mention gate for channel threads Apr 18, 2026
@ching-kaching ching-kaching force-pushed the slack-strict-mention branch 5 times, most recently from 9cf16b5 to f464c7f Compare April 18, 2026 20:24
Adds a strict_mention config option that, when enabled, requires an
explicit @-mention on every message in channel threads. Disables the
'once mentioned, forever in the thread' and session-presence auto-triggers.

- New _slack_strict_mention() helper (config.extra + SLACK_STRICT_MENTION env)
- Bridged top-level slack.strict_mention yaml to SLACK_STRICT_MENTION env,
  matching require_mention/allow_bots bridging
- Unit tests for the helper + config bridge
@Yiin

Yiin commented Apr 19, 2026

Copy link
Copy Markdown

We also encountered this annoying behavior, thanks for the patch

@teknium1

Copy link
Copy Markdown
Contributor

Merged via #16193 — your commit was cherry-picked onto current main with your authorship preserved (30bb02f). Thanks for the clean implementation with the helper, config bridge, and the behavior matrix in the PR body — salvage straightforward.
#16193

@teknium1 teknium1 closed this Apr 26, 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 P2 Medium — degraded but workaround exists platform/slack Slack app adapter type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants