Skip to content

fix(mattermost): harden thread routing and delivery hygiene - #41640

Closed
WolframRavenwolf wants to merge 1 commit into
NousResearch:mainfrom
WolframRavenwolf:fix/mattermost-thread-delivery-hygiene
Closed

fix(mattermost): harden thread routing and delivery hygiene#41640
WolframRavenwolf wants to merge 1 commit into
NousResearch:mainfrom
WolframRavenwolf:fix/mattermost-thread-delivery-hygiene

Conversation

@WolframRavenwolf

Copy link
Copy Markdown
Contributor

Summary

Hardens Mattermost gateway delivery and thread routing:

  • keeps plugin/platform sends inside the active Mattermost thread when thread metadata is available
  • treats Mattermost root posts as thread roots for progress/status routing where appropriate
  • prevents tool/status/progress noise from falling back as flat channel messages when the thread root is missing or rejected
  • keeps final-answer delivery robust so the answer is not silently lost
  • makes assistant scratch/thinking progress require explicit Mattermost per-platform opt-in

Motivation

Mattermost is a threaded chat surface. If gateway progress, plugin sends, or fallback delivery escape into the root channel, users get noisy flat-channel clutter and can lose task/session context. The gateway should preserve thread locality for operational messages and be conservative about fallback behavior.

Verification

  • python3 -m py_compile gateway/run.py gateway/platforms/base.py gateway/stream_consumer.py plugins/platforms/mattermost/adapter.py tests/gateway/test_mattermost.py tests/gateway/test_stream_consumer_thread_routing.py
  • uv run pytest tests/gateway/test_mattermost.py tests/gateway/test_stream_consumer_thread_routing.py -q -o addopts=

Result: 70 passed, 3 warnings from third-party lark_oapi/websockets deprecations.

@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 Jun 8, 2026
@WolframRavenwolf
WolframRavenwolf force-pushed the fix/mattermost-thread-delivery-hygiene branch 3 times, most recently from b16419e to 76a0323 Compare June 14, 2026 17:38
teknium1 added a commit that referenced this pull request Jun 15, 2026
Salvage the valid thread-routing pieces from #41640:
- route Mattermost progress/status sends through metadata thread IDs
- treat top-level Mattermost channel posts as thread roots for progress
- preserve thread metadata through media/file sends
- allow flat fallback only for final notify-worthy replies on confirmed broken roots

Co-authored-by: Wolfram Ravenwolf <github.com@wolfram.ravenwolf.de>
@WolframRavenwolf
WolframRavenwolf force-pushed the fix/mattermost-thread-delivery-hygiene branch from 76a0323 to acad055 Compare June 16, 2026 00:38
PROBLEM: Mattermost threads can become invalid or enormous, exposing two failure modes: internal scratch/reasoning/commentary displays could leak into persistent Mattermost threads via global display toggles, while rejected threaded user-visible replies could disappear unless every failed send fell back flat. A broad flat fallback would pollute channels with tool/status/progress noise.

SOLUTION: Require explicit Mattermost platform opt-in for scratch displays, keep using the existing notify=True metadata marker for user-visible final text/media/file replies, and allow the Mattermost plugin adapter to flat-fallback only notify-worthy sends whose threaded POST failure looks like a broken root/thread. Keep tool/status/progress and other non-notify sends thread-strict. Add regression tests for display opt-in, notify-only broken-thread fallback, generic API failure suppression, and stream notify metadata.

Verification: tests/gateway/test_mattermost.py tests/gateway/test_stream_consumer.py tests/gateway/test_stream_consumer_thread_routing.py tests/gateway/test_stream_consumer_fresh_final.py tests/gateway/test_stream_consumer_draft.py; tests/gateway/test_session_api.py tests/gateway/test_status_command.py tests/gateway/test_resume_command.py tests/hermes_cli/test_commands.py; py_compile touched gateway files; git diff --check.

Session: Mattermost thread 6qg8e9dd1pd9pkhi74xyaa1mry, 2026-06-01.
@teknium1

Copy link
Copy Markdown
Contributor

Merged via #47250 — your commit was cherry-picked onto current main with your authorship preserved in git log (rebase-merge).

The thread-locality routing, the notify-marking of final user-visible sends (text/voice/media/files + streamed final chunks), the per-platform scratch-text opt-in for Mattermost, and the robust broken-thread-root fallback are all in. Thanks!

@teknium1 teknium1 closed this Jun 16, 2026
alanbratu pushed a commit to alanbratu/hermes-agent that referenced this pull request Jun 17, 2026
Salvage the valid thread-routing pieces from NousResearch#41640:
- route Mattermost progress/status sends through metadata thread IDs
- treat top-level Mattermost channel posts as thread roots for progress
- preserve thread metadata through media/file sends
- allow flat fallback only for final notify-worthy replies on confirmed broken roots

Co-authored-by: Wolfram Ravenwolf <github.com@wolfram.ravenwolf.de>
zmlgit pushed a commit to zmlgit/hermes-agent that referenced this pull request Jun 17, 2026
Salvage the valid thread-routing pieces from NousResearch#41640:
- route Mattermost progress/status sends through metadata thread IDs
- treat top-level Mattermost channel posts as thread roots for progress
- preserve thread metadata through media/file sends
- allow flat fallback only for final notify-worthy replies on confirmed broken roots

Co-authored-by: Wolfram Ravenwolf <github.com@wolfram.ravenwolf.de>
al3xar pushed a commit to al3xar/hermes-agent that referenced this pull request Jun 17, 2026
Salvage the valid thread-routing pieces from NousResearch#41640:
- route Mattermost progress/status sends through metadata thread IDs
- treat top-level Mattermost channel posts as thread roots for progress
- preserve thread metadata through media/file sends
- allow flat fallback only for final notify-worthy replies on confirmed broken roots

Co-authored-by: Wolfram Ravenwolf <github.com@wolfram.ravenwolf.de>
T02200059 pushed a commit to T02200059/hermes-agent that referenced this pull request Jun 18, 2026
Salvage the valid thread-routing pieces from NousResearch#41640:
- route Mattermost progress/status sends through metadata thread IDs
- treat top-level Mattermost channel posts as thread roots for progress
- preserve thread metadata through media/file sends
- allow flat fallback only for final notify-worthy replies on confirmed broken roots

Co-authored-by: Wolfram Ravenwolf <github.com@wolfram.ravenwolf.de>
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
Salvage the valid thread-routing pieces from NousResearch#41640:
- route Mattermost progress/status sends through metadata thread IDs
- treat top-level Mattermost channel posts as thread roots for progress
- preserve thread metadata through media/file sends
- allow flat fallback only for final notify-worthy replies on confirmed broken roots

Co-authored-by: Wolfram Ravenwolf <github.com@wolfram.ravenwolf.de>
Methodician added a commit to Methodician/hermes-agent that referenced this pull request Jul 4, 2026
Salvage the valid thread-routing pieces from NousResearch#41640:
- route Mattermost progress/status sends through metadata thread IDs
- treat top-level Mattermost channel posts as thread roots for progress
- preserve thread metadata through media/file sends
- allow flat fallback only for final notify-worthy replies on confirmed broken roots

Co-authored-by: Wolfram Ravenwolf <github.com@wolfram.ravenwolf.de>
habarmc1223-sudo pushed a commit to habarmc1223-sudo/hermes-agent-fluxmem that referenced this pull request Jul 8, 2026
Salvage the valid thread-routing pieces from NousResearch#41640:
- route Mattermost progress/status sends through metadata thread IDs
- treat top-level Mattermost channel posts as thread roots for progress
- preserve thread metadata through media/file sends
- allow flat fallback only for final notify-worthy replies on confirmed broken roots

Co-authored-by: Wolfram Ravenwolf <github.com@wolfram.ravenwolf.de>
santhreal pushed a commit to santhreal/hermes-agent that referenced this pull request Jul 13, 2026
Salvage the valid thread-routing pieces from NousResearch#41640:
- route Mattermost progress/status sends through metadata thread IDs
- treat top-level Mattermost channel posts as thread roots for progress
- preserve thread metadata through media/file sends
- allow flat fallback only for final notify-worthy replies on confirmed broken roots

Co-authored-by: Wolfram Ravenwolf <github.com@wolfram.ravenwolf.de>
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
Salvage the valid thread-routing pieces from NousResearch#41640:
- route Mattermost progress/status sends through metadata thread IDs
- treat top-level Mattermost channel posts as thread roots for progress
- preserve thread metadata through media/file sends
- allow flat fallback only for final notify-worthy replies on confirmed broken roots

Co-authored-by: Wolfram Ravenwolf <github.com@wolfram.ravenwolf.de>
leewenjie pushed a commit to leewenjie/hermes-agent that referenced this pull request Aug 7, 2026
Salvage the valid thread-routing pieces from NousResearch#41640:
- route Mattermost progress/status sends through metadata thread IDs
- treat top-level Mattermost channel posts as thread roots for progress
- preserve thread metadata through media/file sends
- allow flat fallback only for final notify-worthy replies on confirmed broken roots

Co-authored-by: Wolfram Ravenwolf <github.com@wolfram.ravenwolf.de>
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.

3 participants