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) <noreply@anthropic.com>
This commit is contained in:
dirtyren
2026-06-03 11:43:34 +00:00
committed by Teknium
parent fe4e327bb5
commit 74e845c000
2 changed files with 5 additions and 2 deletions

View File

@ -595,6 +595,7 @@ class TestSendToPlatformChunking:
"***",
"C123",
"*hello* from <https://example.com|Hermes>",
thread_ts=None,
)
def test_slack_bold_italic_formatted_before_send(self, monkeypatch):

View File

@ -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"):