Skip to content

proactive send from DM may route to wrong conversation when user has multiple conversations #51947

@SidU

Description

@SidU

Summary

When a user has both a 1:1 and a channel/group conversation with the bot, proactive sends initiated from a 1:1 chat (e.g. agent sending an Adaptive Card via the send tool) may be delivered to the channel conversation instead.

Root Cause

For DMs, the inbound context sets To as user:{aadObjectId} (not conversation:{conversationId}). When the send tool resolves the target via findByUserId in conversation-store-fs.ts, it returns the first matching conversation for that user — which may be a channel or group chat rather than the originating 1:1 conversation.

findByUserId iterates Object.entries() on the conversation store JSON and returns the first match with no recency or conversation-type awareness.

Possible Fixes

  1. Track recency: Add an updatedAt timestamp to stored conversation references and have findByUserId return the most recently active conversation.
  2. Use conversation ID for DMs: Change the To value for DMs from user:{senderId} to conversation:{conversationId} so resolveMSTeamsSendContext does an exact conversation lookup instead of a user-based search.
  3. Pass originating conversation through: Have the agent's send tool inherit the originating conversation ID from the session context rather than resolving by user.

Reproduction

  1. Have a bot added to both a 1:1 chat and a team channel
  2. In the 1:1 chat, ask the bot to send you an Adaptive Card (or any proactive message via the send tool)
  3. The card may appear in the channel instead of the 1:1 chat

Files

  • extensions/msteams/src/conversation-store-fs.tsfindByUserId returns first match
  • extensions/msteams/src/monitor-handler/message-handler.ts — sets To as user:{id} for DMs
  • extensions/msteams/src/send-context.tsresolveMSTeamsSendContext uses findByUserId for user targets

Metadata

Metadata

Assignees

No one assigned

    Labels

    maintainerMaintainer-authored PR

    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