fix(mattermost): isolate thread sessions#12299
Conversation
|
✓ Automated scan: no security concerns. Mattermost threading fix. |
877fe2c to
408e701
Compare
|
Are there any merger plans? |
|
Heads-up — the original PR included three fixes; the |
408e701 to
5ffb964
Compare
|
Rebased onto current main (clean merge). Also cleaned up the commit message to accurately reflect the two fixes in the diff. This is a small change (+19/−5) fixing two thread-handling bugs in the Mattermost platform — happy to address any feedback. Would appreciate a review when someone has a chance. 🙏 |
5ffb964 to
95bae59
Compare
|
Rebased onto current main. This is a small 2-fix PR for Mattermost threading (root_id resolution + per-thread session keying). Would appreciate a review when you get a chance. cc @teknium1 |
cc0f3d7 to
72a05e7
Compare
72a05e7 to
0a1feb9
Compare
|
Rebased/refreshed this PR onto current Changes in the refreshed branch:
Validation:
I also tried the broader |
Use explicit Mattermost thread metadata when available while preserving root-id resolution for reply_to. Treat top-level posts as their own thread roots in thread mode so unrelated channel threads do not share a session.
0a1feb9 to
e54003a
Compare
|
Refreshed this PR onto current Validation from the refreshed branch:
|
Independent confirmation from a real deploymentJust hit this bug on a self-hosted Mattermost install (LXC running Hermes off Repro before the patch (
|
Top-level Mattermost posts in reply_mode=thread were keyed by user_id while thread replies were keyed by thread_id, so the same user in the same channel landed in two separate sessions and the bot lost context across turns. Prefer an explicit thread root from metadata on send, and key top-level posts in thread mode by their own post id on receive. Carries upstream PR NousResearch#12299 (still open). Runtime fix only; upstream PR test hunks omitted (refactored test file diverged). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
Refreshes the Mattermost threading fix onto current
mainand keeps the diff focused on the two thread/session behaviors still needed ingateway/platforms/mattermost.py:reply_mode=thread, prefermetadata["thread_id"]as the authoritative Mattermost root id. If metadata is absent, preserve upstream's_resolve_root_id(reply_to)fallback so reply ids are resolved to the actual thread root.reply_mode=thread, top-level Mattermost posts now use their own post id assource.thread_id. Replies already carryroot_id, so they join the same session. This prevents unrelated top-level channel threads from sharing one Hermes session/context.When
reply_mode=off, the existing flat channel behavior is preserved for top-level messages.Supersedes #12283. Fixes #12290.
Notes
Upstream has since added
_resolve_root_id(), so this refresh intentionally composes with upstream's resolver rather than replacing it.Test plan
uv run --with pytest==9.0.2 --with pytest-asyncio==1.3.0 --with pytest-timeout==2.4.0 --with aiohttp==3.13.2 pytest tests/gateway/test_mattermost.py -q -o addopts=46 passedpython3 -m py_compile gateway/platforms/mattermost.py tests/gateway/test_mattermost.pygit diff --check origin/main..HEAD