fix(slack): use channel-level session key when replyToMode=off and message is top-level#31662
Closed
CZH-THU wants to merge 1 commit intoopenclaw:mainfrom
Closed
Conversation
…ssage is top-level When replyToMode is off and a message is top-level (no thread_ts), each message was creating a separate agent context because the session key included 🧵message.ts suffix. This broke conversation continuity for users who chat in channels without threads. Fix: For channels/groups, use thread-level sessions only when message is in a thread (has thread_ts) OR replyToMode is all or first. Otherwise (replyToMode=off and top-level), use channel-level session key. Thread replies always use thread-level session key regardless of replyToMode. Fixes openclaw#31613
Contributor
Greptile SummaryThis PR fixes a regression introduced in v2026.3.1 where every message in a Slack channel with Key Changes:
Test Coverage:
Impact: Confidence Score: 5/5
Last reviewed commit: e220965 |
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.
Problem
After upgrading from
2026.2.26to2026.3.1, every message in a Slack channel creates a separate agent context whenreplyToMode="off"and messages are top-level (not in threads).Previously, chatting with OpenClaw in a Slack channel worked like a normal chatbot — each message in the channel shared the same agent session, so the agent remembered prior context. Now each message is completely isolated with no memory of previous messages.
Root Cause
Commit
11d34700cchanged the session key to always include thread-level sessions for channels:agent:main:slack:channel:${channelId}agent:main:slack:channel:${channelId}:thread:${messageTs}For users who chat in channels without threads and
replyToMode="off", each top-level message gets its ownts, so every message creates a brand new isolated session.Solution
Modified the session key resolution logic to:
thread_ts), ORreplyToModeis"all"or"first"(threading enabled)replyToMode="off"and top-level), use channel-level session keyreplyToModeThis restores the behavior from v2026.2.26 where channel-level messages shared the same agent context when
replyToMode="off".Testing
Added test cases to verify:
replyToMode="off"use channel-level session keyreplyToMode="off"still use thread-level session keyreplyToMode="all"or"first"use thread-level session keyFixes #31613