From 74e845c000de1f32cd325758407ea706f18b7c36 Mon Sep 17 00:00:00 2001 From: dirtyren Date: Wed, 3 Jun 2026 11:43:34 +0000 Subject: [PATCH] fix(slack): pass thread_ts in standalone send_message tool path The standalone `_send_slack()` function used by the send_message tool and cron delivery fallback was not passing `thread_ts` to the Slack API, causing messages to post to the top-level channel instead of inside threads. - Add `thread_ts` parameter to `_send_slack()` - Include `thread_ts` in the chat.postMessage payload when present - Pass `thread_id` from `_send_to_platform()` to `_send_slack()` Co-Authored-By: Claude Opus 4.6 (1M context) --- tests/tools/test_send_message_tool.py | 1 + tools/send_message_tool.py | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/tools/test_send_message_tool.py b/tests/tools/test_send_message_tool.py index 10a486865..56b196a47 100644 --- a/tests/tools/test_send_message_tool.py +++ b/tests/tools/test_send_message_tool.py @@ -595,6 +595,7 @@ class TestSendToPlatformChunking: "***", "C123", "*hello* from ", + thread_ts=None, ) def test_slack_bold_italic_formatted_before_send(self, monkeypatch): diff --git a/tools/send_message_tool.py b/tools/send_message_tool.py index 88bcb4005..f8386a51e 100644 --- a/tools/send_message_tool.py +++ b/tools/send_message_tool.py @@ -767,7 +767,7 @@ async def _send_to_platform(platform, pconfig, chat_id, message, thread_id=None, last_result = None for chunk in chunks: if platform == Platform.SLACK: - result = await _send_slack(pconfig.token, chat_id, chunk) + result = await _send_slack(pconfig.token, chat_id, chunk, thread_ts=thread_id) elif platform == Platform.WHATSAPP: result = await _send_whatsapp(pconfig.extra, chat_id, chunk) elif platform == Platform.SIGNAL: @@ -1049,7 +1049,7 @@ async def _send_telegram(token, chat_id, message, media_files=None, thread_id=No return _error(f"Telegram send failed: {e}") -async def _send_slack(token, chat_id, message): +async def _send_slack(token, chat_id, message, thread_ts=None): """Send via Slack Web API.""" try: import aiohttp @@ -1063,6 +1063,8 @@ async def _send_slack(token, chat_id, message): headers = {"Authorization": f"Bearer {token}", "Content-Type": "application/json"} async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=30), **_sess_kw) as session: payload = {"channel": chat_id, "text": message, "mrkdwn": True} + if thread_ts: + payload["thread_ts"] = thread_ts async with session.post(url, headers=headers, json=payload, **_req_kw) as resp: data = await resp.json() if data.get("ok"):