Skip to content

feat(slack): add configurable thread implicit mentions#54414

Open
Alfie-longhui-Lin wants to merge 3 commits intoopenclaw:mainfrom
Alfie-longhui-Lin:slack-auto-reply-on-participation
Open

feat(slack): add configurable thread implicit mentions#54414
Alfie-longhui-Lin wants to merge 3 commits intoopenclaw:mainfrom
Alfie-longhui-Lin:slack-auto-reply-on-participation

Conversation

@Alfie-longhui-Lin
Copy link
Copy Markdown

@Alfie-longhui-Lin Alfie-longhui-Lin commented Mar 25, 2026

Summary

  • Problem: when Slack channels require mentions, once the bot replies in a thread, later thread replies can continue triggering the bot without an explicit mention.
  • Why it matters: this bypasses strict mention gating for users who expect every Slack thread reply to explicitly mention the bot.
  • What changed: added a Slack thread config toggle, autoReplyOnParticipation, to control whether thread participation should continue to count as an implicit mention.
  • What did NOT change (scope boundary): this does not change other channels' implicit mention behavior, and it does not change Slack's default behavior unless the new config is explicitly set to false.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Root Cause / Regression History (if applicable)

  • Root cause: Slack inbound handling treated prior bot participation in a thread as an implicit mention, which allowed later thread replies to bypass requireMention.
  • Missing detection / guardrail: there was no Slack-specific configuration to disable participation-based implicit mentions while preserving backward compatibility.
  • Prior context (git blame, prior PR, issue, or refactor if known): reported in [Feature]: Add opt-out config for thread participation auto-reply (#29165) #31728.
  • Why this regressed now: N/A
  • If unknown, what was ruled out: N/A

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: extensions/slack/src/monitor.tool-result.test.ts
  • Scenario the test should lock in: Slack thread replies still count as implicit mentions by default, but stop doing so when channels.slack.thread.autoReplyOnParticipation is explicitly set to false.
  • Why this is the smallest reliable guardrail: the behavior is decided in Slack monitor mention-gating prep logic, and this test file already exercises that path directly.
  • Existing test that already covers this (if any): the existing implicit mention test in the same file was updated to cover the default path.
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

  • Added channels.slack.thread.autoReplyOnParticipation
  • Default remains true, so existing Slack behavior is preserved
  • When explicitly set to false, each Slack thread reply must explicitly mention the bot to trigger a response

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: local dev environment
  • Model/provider: N/A
  • Integration/channel (if any): Slack
  • Relevant config (redacted): channels.slack.channels.C1.requireMention=true

Steps

  1. Configure a Slack channel with requireMention: true.
  2. Send a channel message that explicitly mentions the bot and let the bot reply in a thread.
  3. Send another message in the same thread without explicitly mentioning the bot.
  4. Repeat with channels.slack.thread.autoReplyOnParticipation: false.

Expected

  • Default config: existing behavior remains unchanged.
  • With autoReplyOnParticipation: false: non-mentioned thread replies should not trigger the bot.

Actual

  • Before this change, participation-based implicit mentions were always enabled.
  • After this change, they are configurable and can be disabled explicitly.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

  • Verified scenarios: ran the updated Slack monitor tests locally and manually verified the behavior with a real OpenClaw instance connected to a Slack bot
  • Edge cases checked: default behavior still allows participation-based implicit mentions, and setting channels.slack.thread.autoReplyOnParticipation=false requires an explicit mention for later thread replies
  • What you did not verify: broader Slack workspace scenarios outside the thread mention-gating flow

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (Yes)
  • Migration needed? (No)
  • If yes, exact upgrade steps:

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: remove the new config and fall back to default behavior, or revert this PR
  • Files/config to restore: channels.slack.thread.autoReplyOnParticipation
  • Known bad symptoms reviewers should watch for: Slack thread replies unexpectedly stop or continue auto-triggering despite config

Risks and Mitigations

  • Risk: participation-based implicit mention behavior could accidentally change for existing users
    • Mitigation: the default remains true, and tests cover both the default path and the explicit opt-out path

Made with Cursor

@openclaw-barnacle openclaw-barnacle bot added channel: slack Channel integration: slack size: XS labels Mar 25, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 25, 2026

Greptile Summary

This PR adds a new channels.slack.thread.autoReplyOnParticipation config toggle that controls whether prior bot participation in a Slack thread counts as an implicit mention. The default remains true, preserving existing behaviour; setting it to false requires every thread reply to contain an explicit @mention before the bot responds.

The change is small, well-scoped, and backward-compatible:

  • prepare.ts: A single ctx.autoReplyOnParticipation && guard short-circuits the implicitMention computation. As a bonus, the short-circuit also skips the hasSlackThreadParticipation store lookup when the flag is off.
  • provider.ts / context.ts: The value is plumbed through the existing config-reading / context-building path, consistent with other thread.* options.
  • types.slack.ts / zod-schema.providers-core.ts: Type and schema definitions are properly updated and marked optional.
  • Tests: Two test cases cover the default path and the explicit opt-out, providing a reliable guardrail against accidental regressions.

One minor observation: context.ts applies a ?? true fallback inside createSlackMonitorContext, but provider.ts already normalises the value to true before passing it in, making the second fallback unreachable. It is harmless and makes the factory self-documenting, but worth noting in case the context factory is ever called from a second callsite that omits the parameter.

Confidence Score: 5/5

  • This PR is safe to merge — the default is unchanged, changes are minimal and well-tested.
  • The feature is backward-compatible (default true), the implementation is a single boolean guard, the config plumbing follows existing patterns, and both the default and opt-out paths are covered by unit tests. No security surface, no data model changes, no breaking API changes.
  • No files require special attention. The redundant ?? true default in context.ts is the only micro-imperfection and is completely harmless.

Reviews (1): Last reviewed commit: "feat(slack): add configurable thread imp..." | Re-trigger Greptile

@openclaw-barnacle openclaw-barnacle bot added the docs Improvements or additions to documentation label Mar 25, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 90f541830a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@JackReacher0807
Copy link
Copy Markdown

Need this!

@Alfie-longhui-Lin Alfie-longhui-Lin force-pushed the slack-auto-reply-on-participation branch from 8f5bdc1 to fc5e828 Compare March 26, 2026 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: slack Channel integration: slack docs Improvements or additions to documentation size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add opt-out config for thread participation auto-reply (#29165)

2 participants