fix(tools): implement Mattermost direct send via REST API#3689
Open
miki-10xlab wants to merge 1 commit intoNousResearch:mainfrom
Open
fix(tools): implement Mattermost direct send via REST API#3689miki-10xlab wants to merge 1 commit intoNousResearch:mainfrom
miki-10xlab wants to merge 1 commit intoNousResearch:mainfrom
Conversation
Platform.MATTERMOST was registered but _send_to_platform() fell through to the else branch returning 'Direct sending not yet implemented for mattermost', silently breaking all cron job and agent deliveries. Fix: add _send_mattermost() using a direct aiohttp POST to /api/v4/posts, matching the same pattern as _send_discord and _send_slack. No new deps. Also wires thread_id -> root_id for threaded replies. Fixes NousResearch#3511
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.
What does this PR do?
Platform.MATTERMOSTwas fully registered and its config was parsed correctly, but_send_to_platform()had no handler for it — falling through to theelsebranch and returning"Direct sending not yet implemented for mattermost".This made every cron job or agent delivery targeting Mattermost silently fail. The root cause was that the only existing send path for Mattermost goes through
MattermostAdapter, which requiresconnect()to be called before use (setting upself._session). The direct-send path (used outside the gateway, e.g. cron jobs) never calledconnect(), leavingself._session = Noneand raisingAttributeError: 'NoneType' object has no attribute 'post'.Fix: add
_send_mattermost()using a directaiohttpPOST to/api/v4/posts, matching the same pattern already used by_send_discordand_send_slack. No new dependencies —aiohttpis already required by those handlers. Also wiresthread_id→ Mattermost'sroot_idfor threaded replies.Note: #3512 fixed platform registration (toolset config parsing). This PR fixes the complementary send-path bug — the platform was correctly registered but delivery was never implemented for the direct-send path used by cron jobs.
Related Issue
Fixes — (no existing issue; discovered in production via cron job delivery failure)
Type of Change
Changes Made
tools/send_message_tool.py— add_send_mattermost(pconfig, chat_id, message, thread_id=None)implementing direct REST delivery viaaiohttptools/send_message_tool.py— wirePlatform.MATTERMOSTin the_send_to_platform()dispatch loop (was hittingelsebranch)tests/tools/test_send_message_tool.py— addTestSendMattermostclass with 4 tests: routing, success (HTTP 201),thread_id→root_idmapping, API error (HTTP 403)How to Test
~/.hermes/config.yaml:deliver: mattermostand a channel ID as target, or callsend_messagewithplatform: mattermost{"error": "Direct sending not yet implemented for mattermost"}Unit tests:
pytest tests/tools/test_send_message_tool.py::TestSendMattermost -v— 4 passedChecklist
Code
fix(send_message): implement Mattermost direct send via REST API)pytest tests/ -qand all tests pass (10 pre-existing failures onmainunrelated to this PR, verified on cleanHEADbefore branching)Documentation & Housekeeping
cli-config.yaml.example— N/ACONTRIBUTING.mdorAGENTS.md— N/AScreenshots / Logs
Before (cron job delivery to Mattermost):
After: