fix(msteams): detect implicit mentions in thread replies via conversation.id#261
Open
BingqingLyu wants to merge 4 commits intomainfrom
Open
fix(msteams): detect implicit mentions in thread replies via conversation.id#261BingqingLyu wants to merge 4 commits intomainfrom
BingqingLyu wants to merge 4 commits intomainfrom
Conversation
Teams doesn't reliably send replyToId in thread replies. Fall back to the thread root message ID extracted from conversation.id (the ;messageid=XXX suffix) when checking if the bot sent a message in that thread. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…lies The previous commit added conversation.id;messageid= as a fallback for implicit mention detection, but the lookup still failed because the sent-message cache only contained the bot's reply IDs, not the thread root ID that Teams puts in conversation.id. This commit also records the thread root message ID (conversationMessageId) when the bot sends a reply, so subsequent thread replies match correctly. Note: This fix requires ChannelMessage.Read.Group RSC permission in the Teams app manifest for thread replies to reach the bot at all. Tested and verified in production. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extract the implicit mention computation from message-handler.ts into a dedicated implicit-mention.ts module. Both the production code and the tests now import the same function, so regressions in the logic will be caught by the test suite. Addresses review feedback about test helper duplicating production logic. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes thread reply implicit mention detection for MS Teams. When
requireMention: true, replying to a bot message in a thread without @mention now correctly bypasses the mention gate.Two changes:
Fallback to
conversation.id;messageid=for implicit mention — Teams doesn't reliably sendreplyToId, but it does encode the thread root message ID inconversation.id. The existingextractMSTeamsConversationMessageId()function already parses this; now it's wired into the implicit mention check.Cache thread root ID on send — The
conversation.id;messageid=points to the thread root (the user's original message), not the bot's reply. So we also record the thread root ID in the sent-message cache when the bot replies, enabling the lookup to succeed.Important: RSC required
This fix also requires
ChannelMessage.Read.GroupRSC permission in the Teams app manifest. Without RSC, Teams doesn't deliver thread replies to the bot webhook at all — the messages never reach OpenClaw. This is a Teams platform limitation documented in MicrosoftDocs/msteams-docs#4530.Test plan
extractMSTeamsConversationMessageId(all pass)Closes openclaw#38629
🤖 Generated with Claude Code