fix(mattermost): start fresh session for each top-level channel message#12283
Closed
imapotato123 wants to merge 1 commit into
Closed
fix(mattermost): start fresh session for each top-level channel message#12283imapotato123 wants to merge 1 commit into
imapotato123 wants to merge 1 commit into
Conversation
Previously, all top-level Mattermost messages (no root_id) shared a single channel-level session key. This caused context to accumulate indefinitely — users could not start a fresh conversation without restarting the gateway. When reply_mode is "thread", use the post's own id as thread_id for top-level messages so each gets its own session. Replies in the resulting thread carry root_id matching the original post, joining the same session automatically. When reply_mode is "off" (flat channel, no threads), preserve the existing channel-level session since all messages are top-level and per-message sessions would break multi-turn conversations. This matches the Slack adapter behavior (slack.py:1022) where channels use `event.thread_ts or ts` as the session key. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
|
Superseded by new PR with additional fixes (edit_message finalize regression from DingTalk PR, root_id resolution for thread replies). See replacement PR. |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
root_id) all shared a single channel-level session key, causing context to accumulate indefinitely. Users could not start a fresh conversation without restarting the gateway.reply_modeisthread, use the post's ownidasthread_idfor top-level messages so each gets its own session. Replies in the resulting thread carryroot_idmatching the original post, joining the same session automatically.reply_modeisoff, preserve the existing channel-level session — since all messages are top-level, per-message sessions would break multi-turn conversations.Context
The Slack adapter already implements this pattern (
slack.py:1022) where channels useevent.thread_ts or tsas the session key. This brings the Mattermost adapter to parity.Test plan
reply_mode: thread— new top-level message starts fresh session, thread replies continue itreply_mode: off— behavior unchanged, channel shares one sessionroot_idjoin the correct parent session🤖 Generated with Claude Code