Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions plugins/platforms/slack/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2578,10 +2578,15 @@ async def _handle_slack_message(self, event: dict) -> None:
# 3. The message is in a thread where the bot was previously @mentioned, OR
# 4. There's an existing session for this thread (survives restarts)
bot_uid = self._team_bot_user_ids.get(team_id, self._bot_user_id)
routing_text = original_text or ""
# Check both flat text and blocks text for mentions — Block Kit
# messages may have the @mention only in blocks, not in the flat
# text field (#52387).
blocks = event.get("blocks")
blocks_text = _extract_text_from_slack_blocks(blocks) if blocks else ""
mention_text = (original_text or "") + ("\n" + blocks_text if blocks_text else "")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

_extract_text_from_slack_blocks() includes nested rich_text_quote content, so this makes a quoted/forwarded <@bot> satisfy routing. Current main deliberately rejects that case in tests/gateway/test_slack.py:1687-1721; use a detector that collects only non-quoted user elements instead.

is_mentioned = bool(
(bot_uid and f"<@{bot_uid}>" in routing_text)
or self._slack_message_matches_mention_patterns(routing_text)
(bot_uid and f"<@{bot_uid}>" in mention_text)
or self._slack_message_matches_mention_patterns(mention_text)
)
event_thread_ts = event.get("thread_ts")
is_thread_reply = bool(event_thread_ts and event_thread_ts != ts)
Expand Down