Skip to content

fix(gateway): use metadata thread_id for Mattermost root_id - #24420

Closed
steveafrost wants to merge 1 commit into
NousResearch:mainfrom
steveafrost:fix/mattermost-threading-root-id
Closed

fix(gateway): use metadata thread_id for Mattermost root_id#24420
steveafrost wants to merge 1 commit into
NousResearch:mainfrom
steveafrost:fix/mattermost-threading-root-id

Conversation

@steveafrost

Copy link
Copy Markdown

Problem

Mattermost replies were not threading correctly. The root_id field must contain the thread root post ID, not the specific message being replied to.

Root Cause

The adapter was passing reply_to (the message_id) as root_id, causing each reply to start a new thread instead of continuing the existing one.

Solution

Use metadata["thread_id"] (the actual root post ID) when available, falling back to reply_to for backward compatibility.

Changes

  • send_message(): Uses effective_reply_to = metadata.get("thread_id") or reply_to
  • send_image_url(): Same pattern
  • send_image_file(): Same pattern
  • send_document(): Same pattern
  • send_voice(): Same pattern
  • send_video(): Same pattern

Testing

  • Tested on self-hosted Mattermost instance
  • Verified replies now correctly thread under the original message
  • Backward compatible: falls back to reply_to if thread_id not provided

Mattermost requires root_id to be the thread root post ID, not the
specific message being replied to. The reply_to parameter contains
the message_id which is incorrect for root_id.

This fix uses metadata["thread_id"] (the actual root post ID) when
available, falling back to reply_to for backward compatibility.

Affected methods:
- send_message
- send_image_url
- send_image_file
- send_document
- send_voice
- send_video
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery labels May 12, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #20874 which is the most comprehensive fix for this threading issue (also supersedes #6617, #12096, #12299, #18280). All address the same root cause: Mattermost adapter not using metadata.thread_id for root_id in outbound replies (see #12063 for the original issue report).

@steveafrost

Copy link
Copy Markdown
Author

Closing as duplicate of #20874

@steveafrost
steveafrost deleted the fix/mattermost-threading-root-id branch May 12, 2026 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants