Skip to content

Commit 87b3742

Browse files
adk47claude
andcommitted
fix(slack): bypass mention gate for app_mention events
When requireMention is true, the mention gate checks message text for bot mentions. However, Slack delivers both `message` and `app_mention` events for @mentions, with no guaranteed order. When the `message` event arrives first and is processed (or deduped), the subsequent `app_mention` event can be incorrectly dropped by the mention gate even though Slack has confirmed the bot was explicitly mentioned. This fix skips the mention gate when opts.source is "app_mention", since Slack's app_mention event is only delivered to the mentioned bot's app — the mention is already confirmed at the platform level. The existing dedup + retry mechanism (rememberAppMentionRetryKey / consumeAppMentionRetryKey) addresses part of this issue but doesn't cover the case where the mention gate itself blocks the app_mention event after it passes dedup. Fixes #34833 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent 3814f95 commit 87b3742

File tree

1 file changed

+7
-1
lines changed
  • extensions/slack/src/monitor/message-handler

1 file changed

+7
-1
lines changed

extensions/slack/src/monitor/message-handler/prepare.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,13 @@ export async function prepareSlackMessage(params: {
487487
commandAuthorized,
488488
});
489489
const effectiveWasMentioned = mentionGate.effectiveWasMentioned;
490-
if (isRoom && shouldRequireMention && mentionGate.shouldSkip) {
490+
// When the event source is "app_mention", Slack has already confirmed this bot
491+
// was explicitly mentioned. Skip the mention gate — the text-based detection in
492+
// mentionGate can fail due to dedup race conditions (message event arrives before
493+
// app_mention, sets dedup key, then app_mention is either deduped or the text-based
494+
// mention check fails because the message was already processed without wasMentioned).
495+
// See: https://github.com/openclaw/openclaw/issues/34833
496+
if (isRoom && shouldRequireMention && mentionGate.shouldSkip && opts.source !== "app_mention") {
491497
ctx.logger.info({ channel: message.channel, reason: "no-mention" }, "skipping channel message");
492498
const pendingText = (message.text ?? "").trim();
493499
const fallbackFile = message.files?.[0]?.name

0 commit comments

Comments
 (0)