fix(slack): prevent duplicate DM processing from app_mention events
Fixes duplicate message processing in Slack DMs where both message.im and app_mention events fire for the same message, causing: - 2x token/credit usage per message - 2x API calls - Duplicate agent invocations with same runId Root cause: app_mention events should only fire for channel mentions, not DMs. Added channel_type check to skip im/mpim in app_mention handler. Evidence of bug (from production logs): - Same runId firing twice within 200-300ms - Example: runId 13cd482c... at 20:32:42.699Z and 20:32:42.954Z After fix: - One message = one runId = one processing run - 50% reduction in duplicate processing
This commit is contained in:
@@ -63,6 +63,14 @@ export function registerSlackMessageEvents(params: {
|
||||
}
|
||||
|
||||
const mention = event as SlackAppMentionEvent;
|
||||
|
||||
// Skip app_mention for DMs - they're already handled by message.im event
|
||||
// This prevents duplicate processing when both message and app_mention fire for DMs
|
||||
const channelType = mention.channel_type;
|
||||
if (channelType === "im" || channelType === "mpim") {
|
||||
return;
|
||||
}
|
||||
|
||||
await handleSlackMessage(mention as unknown as SlackMessageEvent, {
|
||||
source: "app_mention",
|
||||
wasMentioned: true,
|
||||
|
||||
Reference in New Issue
Block a user