Skip to content

fix(mattermost): proactive message tool sends ignore thread context #45082

@teconomix

Description

@teconomix

Problem

When an agent uses the message tool to send a proactive message (without an explicit replyTo), the message lands in the Mattermost channel root — even when the active session is thread-scoped (replyToMode: "all").

Reproduction:

  1. Configure Mattermost with replyToMode: "all"
  2. Start a conversation in a channel thread
  3. Have the agent call message(action="send", channel="mattermost", target="channel:<id>", message="...") without specifying replyTo
  4. Message appears at channel root, not in the thread

Expected behavior

When the active session has thread context (session key contains :thread:<postId>, delivery context has threadId set), a proactive message tool send should default to the current thread.

Root cause

The message tool constructs a delivery payload with an explicit to target but no threadId/replyTo. It bypasses the session delivery routing that carries thread context. Unlike the TUI chat.send path (fixed in #44283 via deliver: true), the tool send path does not inherit session.deliveryContext.threadId.

Relationship

This is the remaining open case from #39759 after #44283 is merged. Manually tested and confirmed on prod 2026-03-13.

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