Skip to content

fix(slack): allowBots "mentions" admits untagged bot replies through implicit thread mentions - #160752

Closed
maxpuppet wants to merge 1 commit into
openclaw:mainfrom
maxpuppet:fix/slack-allowbots-mentions-explicit
Closed

maxpuppet wants to merge 1 commit into
openclaw:mainfrom
maxpuppet:fix/slack-allowbots-mentions-explicit

Conversation

@maxpuppet

Copy link
Copy Markdown
Contributor

Closes #160750

What Problem This Solves

Fixes: with Slack allowBots: "mentions", another bot's untagged reply in a thread this bot joined (or in a thread this bot started) is admitted as a mention, so two bots sharing a thread can wake each other.

User Impact

User impact: in "mentions" mode, bot-authored Slack messages need an explicit mention: native <@bot>, app_mention, a user-group mention that includes the bot, or a configured mention pattern. Human thread follow-ups keep their implicit mentions, so operators no longer have to turn off implicitMentions (and make humans re-tag the bot) to stop bot-to-bot loops.

Compatibility note: a bot handoff that relied only on an untagged reply in a shared thread must now tag the receiving bot. DMs, allowBots: true, and the existing authorized text-command bypass are unchanged.

Why This Change Was Made

The bot-sender gate accepted effectiveWasMentioned, which folds in the implicit kinds reply_to_bot and bot_thread_participant. It now accepts the explicit wasMentioned fact instead, keeping the DM and authorized-command paths. Human messages never reach this branch.

Maintainer decision: I changed the meaning of "mentions" rather than adding a new option. This follows the Discord precedent in #111821 / #111822, which made reply metadata stop admitting bot authors under allowBots: "mentions" instead of adding the opt-in implicitReplyMentions.fromBots proposed in #80235. Unlike Discord, this excludes both implicit kinds, because both are thread facts on Slack and the reported loop comes from thread participation. The original Slack mentions-mode proposal (#43588) described thread participation as admitting bots. If maintainers prefer to keep that, an opt-in flag is the alternative, but it would leave the loop-prone default in place.

Evidence

  • Regression: requires an explicit mention from bots despite reply_to_bot|bot_thread_participant when allowBots is mentions fails on main (the untagged bot reply is admitted) and passes with this change. The same test then admits the bot once it writes <@bot>.
  • Human control: keeps implicit thread mentions for human replies when allowBots is mentions passes before and after (ImplicitMentionKinds: ["reply_to_bot"]).
  • Local checks:
    • extensions/slack/src/monitor/message-handler/: 509/509 tests pass.
    • extensions/slack/src/monitor/: 1383 tests pass. Two provider transport files fail to load identically on main in my environment (Cannot find module '/node_modules/ws/wrapper.mjs', an artifact of my dependency layout).
    • oxlint and oxfmt --check (code and docs) are clean.
    • tsc on tsconfig.extensions.json and test/tsconfig/tsconfig.extensions.test.json reports no Slack errors.
    • The docs anchor audit, MDX check, and i18n glossary check are clean for the changed pages.
  • Test cost: prepare.bot-threads.test.ts runs in 7.1s wall with --maxWorkers=1 (27 tests). The three new cases take 3–4 ms each.
  • Autoreview (Claude engine; Codex was unavailable on this host): no P0/P1 findings.

…tions

With allowBots: "mentions", the bot-sender gate accepted implicit mentions:
an untagged bot reply to this bot's message (reply_to_bot) or in a thread this
bot joined (bot_thread_participant). Two bots sharing a thread could wake each
other until loop protection engaged. Disabling implicitMentions to stop that
also forced humans to re-tag the bot on every thread follow-up.

Bot senders now need a direct message, an explicit mention (native bot or
user-group mention, app_mention, configured mention pattern), or the existing
authorized-command bypass. Human senders keep implicit mentions. This matches
the Discord mention-only contract for bot authors.
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: slack Channel integration: slack size: XS labels Sep 28, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR requires explicit mentions from Slack bot senders in mentions-only mode while preserving implicit thread mentions for humans.

Example: Bot B_OTHER posts “Continue here” in C123 after receiving bot B1 has participated, with allowBots set to "mentions".

  • Before: Thread participation admits the untagged bot message and can start another agent turn.
  • After: The message is rejected; “<@b1> Continue here” remains eligible.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused implementation has useful regression coverage, but its shipped-behavior compatibility finding remains unresolved and required exact-head runtime proof is absent.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Bots sharing Slack threads can repeatedly wake one another without explicit tags while humans need implicit thread follow-ups.
Reason: Stopping unintended bot turns has concrete value, but this implementation changes behavior the existing Slack owner shipped.

Merge readiness

⛔ Blocked before merge - 5 items remain

Keep open: the Slack admission defect remains on current main and the latest release, and the alternative PR does not yet supersede this work; the existing upgrade finding remains unresolved.

Priority: P2
Reviewed head: 69cbd819ed1b77ef75d5b40478403c448d48ac97
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should Slack mentions-only mode become strict for existing installations, or should strict bot mentions require an explicit opt-in?
  • Recommendation: Preserve existing installations: Choose a narrowly scoped opt-in for strict bot mentions while retaining existing untagged handoffs.
  • Why: The shipped gate accepts implicit thread mentions, and neither this PR nor its linked alternative has recorded Slack-owner approval to change that contract.

Before merge

  • Add real behavior proof - The exact-head evidence exercises prepareSlackMessage with synthetic events and mocked Slack clients; shannon0430's production mitigation uses different code and explicitly lacks a live positive control. Provide redacted after-fix Slack logs or a recording showing rejected untagged bots and admitted explicit-bot and human controls, removing IPs, API keys, phone numbers, and non-public endpoints. Upgrade evidence must also start from v2026.10.5 with existing settings intact. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Preserve existing bot-thread handoffs on upgrade (P1) - An existing installation using allowBots: "mentions" with implicit thread mentions currently admits an allowlisted bot's untagged reply. Replacing effectiveWasMentioned with wasMentioned makes the identical message return bot-missing-mention after updating, stopping that handoff without a configuration change. This is the previously reported, still-unresolved compatibility finding. Preserve the shipped behavior pending an owner-approved opt-in or an explicit decision accepting the breaking upgrade.
  • Complete next step - Resolve the GitHub-reported merge conflict and validate any code changed by that resolution.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P1] Preserve existing bot-thread handoffs on upgrade — extensions/slack/src/monitor/message-handler/prepare.ts:1143

Tests

  • Missing end-to-end proof: Supply after-fix Slack event-to-dispatch evidence for both untagged bot thread kinds, an explicit-mention control, and an untagged human follow-up.
Agent review details

How this fits together

Slack message preparation combines sender access, channel policy, explicit mentions, and thread facts before passing an admitted message to agent dispatch.

flowchart LR
  A[Slack event] --> B[Message handler]
  B --> C[Sender and room access]
  C --> D[Explicit and thread mention facts]
  D --> E[Bot admission gate]
  E --> F[Agent dispatch]
Loading

Technical review

Best possible solution:

Use the existing Slack bot-admission owner to stop unintended bot turns under an explicitly accepted upgrade policy.

Do we have a high-confidence way to reproduce the issue?

Current-main and released source combine enabled implicit thread facts into effectiveWasMentioned and admit the reported bot replies; the linked issue supplies concrete configuration and steps, with independent production corroboration.

Is this the best way to solve the issue?

The one-line gate change targets the correct owner and preserves human handling, but redefining shipped mentions-only behavior needs an explicit compatibility decision.

Full review comments:

  • [P1] Preserve existing bot-thread handoffs on upgrade — extensions/slack/src/monitor/message-handler/prepare.ts:1143
    An existing installation using allowBots: "mentions" with implicit thread mentions currently admits an allowlisted bot's untagged reply. Replacing effectiveWasMentioned with wasMentioned makes the identical message return bot-missing-mention after updating, stopping that handoff without a configuration change. This is the previously reported, still-unresolved compatibility finding. Preserve the shipped behavior pending an owner-approved opt-in or an explicit decision accepting the breaking upgrade.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against b6666b7eabb9.

Provenance checked

  • Slack mentions-only bot gate changes intended behavior with a stated reason (8654144: Port mentions-only bot admission into the active Slack plugin, including implicit thread participation; the later audio-mention change carried this gate forward.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit fa3eb67 adds extensions/slack/src/monitor/message-handler/prepare.ts:1118 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: fa3eb673cd0f; files: extensions/slack/src/monitor/message-handler/prepare.ts)

PR surface

Source +2, Tests +42, Docs +4. Total +48 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 3 1 +2
Tests 1 42 0 +42
Docs 2 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 49 1 +48

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #160750
Summary: The linked issue owns Slack bot admission through implicit thread mentions; the alternative proposes a different upgrade policy for the same defect.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Unintended turns affect multi-bot Slack threads with mentions-only admission, causing channel noise and model consumption within a limited configuration.
  • merge-risk: 🚨 compatibility: The same stored allowBots setting changes meaning after an update.
  • merge-risk: 🚨 message-delivery: Previously admitted untagged bot handoffs become rejected messages.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-28T22:17:28.530Z sha 69cbd81 :: needs real behavior proof before merge. :: [P1] Preserve existing bot-thread handoffs on upgrade

Reviewed October 19, 2026, 2:36 PM ET / 18:36 UTC (Revision 2).

@shannon0430

Copy link
Copy Markdown
Contributor

Independent production corroboration on 2026.9.8 (official core fc23bc864e4553c2d215e479eeec47b67a0bf943, Slack plugin 2026.9.8), observed on October 4, 2026.

A human addressed several assistants in a shared Slack thread. Subsequent untagged bot completion acknowledgements and generic no-visible-reply notices kept waking thread participants and producing more bot messages. The bot-pair rate guard did not terminate the distributed loop. Temporarily disabling bot admission for that channel stopped it while preserving human intake.

The faulty bot gate is also still present on official main at 979466250d54290e42945acc1ad42923c465b8c1: isDirectMessage || effectiveWasMentioned || shouldBypassMention. The effective mention includes implicit thread participation.

Our local mitigation rejects an unmentioned bot-authored follow-up under allowBots: "mentions", admits a native explicit bot mention, and preserves unmentioned human follow-ups. The exact synthetic admission regression failed on the released baseline and passed after the fix. We installed the mitigation on five runtimes and subsequently observed no continuing incident-thread loop.

Evidence limits: our local gate accepts native bot/user-group mentions and app_mention; it is not this PR's head and does not establish this PR's configured-pattern or command-bypass behavior. We did not send a live explicit-mention positive canary after the repair. The rollout observation therefore corroborates the failure and mitigation, rather than supplying the complete live negative/positive proof requested by the review.

For the maintainer compatibility decision: untagged handoffs will need explicit tags if this change is accepted. We prefer strict mentions behavior for bot senders while retaining implicit human follow-ups, and support documenting that upgrade impact. The related optional-reply problem in #141556 can amplify the loop; fixing admission and preserving optional silence address separate boundaries.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Oct 18, 2026
@shannon0430

Copy link
Copy Markdown
Contributor

Fresh distribution corroboration (2026-10-19), following my October 4 incident report above. The official @openclaw/[email protected] artifact still has the same admission defect: bot-authored, untagged thread replies are admitted under allowBots: "mentions" through both bot_thread_participant and reply_to_bot.

Artifact SHA-256: ed18bfa9483ca706b0bec9f23090cf923741455acc8e46fff4f582002bfd9b8d. Registry integrity verified. The distributed bot gate still uses isDirectMessage || effectiveWasMentioned || shouldBypassMention. Combining that verbatim gate with the actual distributed core mention decision gives:

Input Observed Requested behavior
Untagged bot, participating thread admitted dropped
Untagged bot, reply-to-bot thread admitted dropped
Explicitly mentioned bot admitted admitted
Untagged human thread follow-up admitted admitted
Bot direct message admitted admitted

These are offline compiled-code checks, not live Slack proof and not execution of this PR’s exact head. I am not claiming they satisfy the review’s real-Slack after-fix proof request. The earlier incident observation likewise remains scoped as documented above.

The outstanding upstream decisions are clear: the author/maintainer must settle strict mentions versus an explicit opt-in upgrade policy, and complete the exact-head Slack event-to-dispatch proof requested by review. Our operational preference remains strict explicit bot mentions while preserving implicit human follow-ups. We are retaining the existing mitigation rather than creating another competing private repair or duplicate PR. Please keep this existing issue/PR as the canonical route for the resolution.

@shannon0430

Copy link
Copy Markdown
Contributor

Following the distribution corroboration above, I submitted #177555 as a compatibility-preserving alternative for the outstanding P1 upgrade concern here. It keeps the shipped behavior when omitted/false and offers requireExplicitBotMention: true alongside allowBots: "mentions" at the existing Slack scopes. It does not close this PR or presume the Slack owner's policy decision.

Head: a383a0d1ca796aeeb96358f57610f1cd17743e40. The actual Slack message handler rejects untagged bots for both implicit thread kinds, then admits explicit bot mentions and untagged human follow-ups. Legacy handoffs and scoped overrides pass. The Slack extension lane passed 162 files / 1,844 tests; the 22 focused tests and production/test typechecks were rerun after the final mechanical classifier relocation.

The official Slack E2E doctor could not authenticate the Convex broker from this seat, so no live Socket Mode or final-delivery proof is claimed. That remains separate from the handler-level integration proof. The proposal explicitly asks the Slack owner to accept or reject the opt-in contract before landing; it is not another downstream distribution.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 19, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Oct 19, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale after 7 days without qualifying human activity.
Without new human activity, Barnacle may close it as not planned 7 days after this message was posted. This is administrative inactivity cleanup, not a claim that the problem is fixed.
A human update restarts the inactivity clock; a new PR head also restarts it. A maintainer can add no-stale for a durable hold, or bad-barnacle to suppress Barnacle. Remove the hold when work can resume.

@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

@openclaw-barnacle openclaw-barnacle Bot closed this Nov 4, 2026
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 merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Slack allowBots: "mentions" admits untagged bot replies through implicit thread mentions

2 participants