Skip to content

fix(msteams): channel thread replies land as top-level posts or in wrong thread #58030

@tazmon95

Description

@tazmon95

Bug Description

Channel thread replies in MS Teams frequently land as new top-level channel posts or in the wrong thread. This happens because the conversation store uses the channel ID as the key (stripping the ;messageid= thread suffix), so all threads in a channel share one stored conversation reference with a single activityId that gets overwritten by every new message.

Root Cause

In extensions/msteams/src/monitor-handler/access.ts, normalizeMSTeamsConversationId() strips the thread-identifying ;messageid=THREAD_ROOT suffix:

function normalizeMSTeamsConversationId(raw: string): string {
  return raw.split(";")[0] ?? raw;
}

This means:

  1. All threads in a channel share one conversationId key in the conversation store
  2. Each new message overwrites the stored activityId (which identifies the thread)
  3. When proactive fallback fires, it picks up whatever activityId was last stored — often from a different thread
  4. Result: reply lands in the wrong thread, or as a new top-level post if the stored activityId does not match any thread root

Symptoms

  • Reply to Thread A → response appears as new top-level post in the channel
  • Reply to Thread A → response appears in Thread B (whichever thread was most recently active)
  • Responses work initially but break after activity in other threads

Proposed Fix

The conversation store and reference lookup need to be thread-aware for channel conversations:

  1. For channel thread messages, preserve the full conversation ID including ;messageid= suffix as the store key (or use a composite key of channelId + threadRootId)
  2. When building the proactive reference for channel threads, include the thread root activityId from the original inbound message context, not from the latest stored reference
  3. Extract messageid from activity.conversation.id (already done by extractMSTeamsConversationMessageId() but not used for routing)

PR #56608 partially addresses this for the proactive fallback path but does not fix the underlying shared-reference problem.

Environment

  • OpenClaw 2026.3.28
  • MS Teams with multiple active channel threads
  • Bot configured with replyStyle: "thread"

Reproduction

  1. Set up a bot in a Teams channel with mention-based activation
  2. Send a message in Thread A → bot replies correctly in Thread A
  3. Send a message in Thread B → bot replies correctly in Thread B
  4. Send another message in Thread A → response may land in Thread B or as a top-level post (because Thread B overwrote the stored activityId)

cc @onutc (MS Teams maintainer)

— Fitzy 🐾

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions