Skip to content

feat(slack): add thread.autoReplyOnParticipation config option#41811

Open
carrotRakko wants to merge 3 commits intoopenclaw:mainfrom
delight-co:feat/thread-participation-opt-out
Open

feat(slack): add thread.autoReplyOnParticipation config option#41811
carrotRakko wants to merge 3 commits intoopenclaw:mainfrom
delight-co:feat/thread-participation-opt-out

Conversation

@carrotRakko
Copy link
Copy Markdown
Contributor

Summary

  • Problem: Thread participation auto-reply (feat(slack): track thread participation for auto-reply without @mention #29165) has no opt-out. Once the bot participates in a thread, it replies to every subsequent message — even when requireMention is enabled. This bypasses the operator's intent to require explicit mentions.
  • Why it matters: Operators who set requireMention: true expect the bot to stay quiet unless mentioned. The participation auto-reply breaks this contract, causing unexpected bot responses in active threads.
  • What changed: New Slack config option thread.autoReplyOnParticipation (default: true for backward compatibility). Setting it to false disables the participation-based auto-reply, restoring requireMention behavior in threads.
  • What did NOT change: Direct mentions always trigger a reply regardless of this setting. Thread participation tracking itself is unchanged.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • 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

User-visible / Behavior Changes

New Slack config option:

slack:
  thread:
    autoReplyOnParticipation: false  # default: true

When false, the bot only replies in threads when explicitly mentioned, even if it has previously participated in that thread.

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

Repro + Verification

Environment

  • OS: Linux
  • Runtime/container: Node.js
  • Model/provider: Any
  • Integration/channel: Slack
  • Relevant config: slack.thread.autoReplyOnParticipation: false

Steps

  1. Set requireMention: true and thread.autoReplyOnParticipation: false
  2. Mention the bot in a Slack thread (it replies)
  3. Send a follow-up message in the same thread without mentioning the bot

Expected

  • Bot does not reply to the follow-up (requireMention enforced).

Actual

  • Before: Bot replies to every message in the thread after initial participation.
  • After: Bot stays quiet unless explicitly mentioned.

Evidence

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

Tests in prepare.test.ts, context.test.ts, and monitor.test.ts verify opt-out behavior and config propagation.

Human Verification (required)

  • Verified scenarios: Tested on a fork with Slack. Bot respects requireMention in threads when autoReplyOnParticipation: false.
  • Edge cases checked: Direct mentions still work. Default true preserves existing behavior. Config propagated through monitor → context → prepare pipeline.
  • What you did not verify: Interaction with every possible Slack event type.

Review Conversations

N/A — fresh PR, no review conversations yet.

Compatibility / Migration

  • Backward compatible? Yes — default true preserves existing behavior
  • Config/env changes? New optional field slack.thread.autoReplyOnParticipation
  • Migration needed? No

Failure Recovery (if this breaks)

  • How to disable/revert: Remove thread.autoReplyOnParticipation from config (defaults to true).
  • Files/config to restore: src/slack/monitor/message-handler/prepare.ts, src/slack/monitor/context.ts
  • Known bad symptoms: Bot not replying in threads at all (would indicate config read error).

Risks and Mitigations

None — additive config option with backward-compatible default.

✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)

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

greptile-apps bot commented Mar 10, 2026

Greptile Summary

This PR adds a new opt-out config option slack.thread.autoReplyOnParticipation (default: true) that lets operators disable the bot's participation-based auto-reply in threads while preserving requireMention behavior. The change is purely additive with a backward-compatible default.

Key changes:

  • Config schema (src/config/types.slack.ts / zod-schema.providers-core.ts): new optional autoReplyOnParticipation field on SlackThreadConfig
  • Provider (src/slack/monitor/provider.ts): reads the value with ?? true default and passes it to createSlackMonitorContext
  • Context (src/slack/monitor/context.ts): threadAutoReplyOnParticipation added to SlackMonitorContext and propagated through the factory
  • Message preparation (src/slack/monitor/message-handler/prepare.ts): the implicitMention computation now wraps the hasSlackThreadParticipation(...) call in ctx.threadAutoReplyOnParticipation &&, leaving direct-mention and bot-started-thread paths untouched
  • Tests: updated across monitor.test.ts, context.test.ts, prepare.test-helpers.ts, and prepare.test.ts, though the new test uses manual mock cleanup that could cause cascading failures if the assertion fails

The implementation is minimal and safe. Direct mentions always trigger a reply regardless of this setting, and thread participation tracking itself is unchanged.

Confidence Score: 4/5

  • This PR is safe to merge — the production logic is sound and fully backward-compatible. Minor test fragility issue identified.
  • The implementation is minimal, additive, and backward-compatible with default true. Direct mentions always work. The single identified issue is a test-level fragility concern (mock cleanup on assertion failure) rather than a production bug. This is worth fixing before merge but does not affect runtime safety.
  • src/slack/monitor/message-handler/prepare.test.ts — update the test mock pattern to use mockReturnValueOnce instead of manual cleanup.

Last reviewed commit: 11c3909

delight-ai-agent pushed a commit to delight-co/openclaw-public that referenced this pull request Mar 10, 2026
Replace manual mock cleanup with mockReturnValueOnce in thread
participation opt-out test. The previous pattern left the mock in an
inconsistent state if the assertion failed before the cleanup line.

Related: openclaw#41811

✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)
@delight-ai-agent delight-ai-agent force-pushed the feat/thread-participation-opt-out branch from 6ab932d to 585afc5 Compare March 16, 2026 17:17
delight-ai-agent pushed a commit to delight-co/openclaw-public that referenced this pull request Mar 16, 2026
Replace manual mock cleanup with mockReturnValueOnce in thread
participation opt-out test. The previous pattern left the mock in an
inconsistent state if the assertion failed before the cleanup line.

Related: openclaw#41811

✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)
Mitsuyuki Osabe added 3 commits March 20, 2026 09:57
PR openclaw#29165 added always-on thread participation auto-reply that bypasses
requireMention gating with no opt-out. Add a config option under
channels.slack.thread to disable this behavior:

  channels.slack.thread.autoReplyOnParticipation: false

When false, hasSlackThreadParticipation() is skipped and implicitMention
only fires for parent_user_id === botUserId (the pre-openclaw#29165 behavior).
Default: true (preserves current behavior).

Closes openclaw#31728

✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)
Replace manual mock cleanup with mockReturnValueOnce in thread
participation opt-out test. The previous pattern left the mock in an
inconsistent state if the assertion failed before the cleanup line.

Related: openclaw#41811

✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)
@delight-ai-agent delight-ai-agent force-pushed the feat/thread-participation-opt-out branch from 585afc5 to a0d13d3 Compare March 20, 2026 09:57
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: a0d13d3896

ℹ️ 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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: slack Channel integration: slack size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant