Skip to content

fix(mattermost): start fresh session for each top-level channel message#12283

Closed
imapotato123 wants to merge 1 commit into
NousResearch:mainfrom
imapotato123:fix/mattermost-top-level-session-keys
Closed

fix(mattermost): start fresh session for each top-level channel message#12283
imapotato123 wants to merge 1 commit into
NousResearch:mainfrom
imapotato123:fix/mattermost-top-level-session-keys

Conversation

@imapotato123

Copy link
Copy Markdown

Summary

  • Top-level Mattermost messages (no 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.
  • 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, 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 use event.thread_ts or ts as the session key. This brings the Mattermost adapter to parity.

Test plan

  • Verify reply_mode: thread — new top-level message starts fresh session, thread replies continue it
  • Verify reply_mode: off — behavior unchanged, channel shares one session
  • Verify thread replies with root_id join the correct parent session

🤖 Generated with Claude Code

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>
@imapotato123

Copy link
Copy Markdown
Author

Superseded by new PR with additional fixes (edit_message finalize regression from DingTalk PR, root_id resolution for thread replies). See replacement PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant