-
-
Notifications
You must be signed in to change notification settings - Fork 69.5k
[Bug]: MS Teams channel thread replies post as top-level messages instead of in the thread #52954
Description
Description
When the bot receives an @mention inside a Teams channel thread, the reply is posted as a new top-level channel message instead of within the same thread.
The Bot Framework inbound activity provides the thread root message ID, and the inbound handler in message-handler.ts correctly saves it as replyToId on the StoredConversationReference. However, by the time the reply is sent, replyStyle resolves to "top-level", so the stored replyToId is never used to route the reply into the thread.
The messenger infrastructure for thread replies already exists (buildActivity handles threadRootId, sendProactively constructs the ;messageid= conversation ID). The gap is in the policy resolution and the send path.
Root Cause
Two independent issues:
-
Reply policy defaults
replyStyleto"top-level"whenrequireMention: false--resolveMSTeamsReplyPolicy()inpolicy.tsdefaultsreplyStylebased on therequireMentionsetting. WhenrequireMentionisfalse,replyStyledefaults to"top-level"regardless of whether the inbound message came from a thread. SettingreplyStyle: "thread"explicitly in config does not fully resolve the issue either. -
send.tshardcodesreplyStyle: "top-level"-- The proactive send path insend.ts(~line 328) hardcodesreplyStyle: "top-level"when callingsendMSTeamsMessages, ignoring thread context entirely. This affects messages sent via the message tool.
Steps to Reproduce
- Configure msteams channel with
requireMention: false - @mention the bot in a Teams channel -- bot responds (as a top-level post)
- @mention the bot again inside the thread of any channel message
- Expected: Bot replies within the same thread
- Actual: Bot replies as a new top-level channel post
Confirmed via debug logging:
- Inbound:
conversationRef.replyToId=1774246097310(correct thread root ID) - Outbound:
replyStyle=top-level,threadRootId=undefined(thread context lost)
Related Issues
- [Bug]: msteams implicit mention fails — replyToId unreliable, conversation.id threadRootId not used as fallback #38629 --
replyToIdunreliable for implicit mention detection (related but distinct: that's about detecting thread replies, this is about replying into threads)
Version
Tested on OpenClaw 2026.3.13, @openclaw/msteams extension.