#2917: Slack: fix thread context + prevent reply spillover
channel: slack
agents
Cluster:
Slack Thread Management Improvements
## Problem\nSlack thread replies sometimes lose context, and tool replies can post in the wrong place. Auto-threaded tool sends could also trigger a duplicate follow-up reply.\n\n## Changes\n- Recover missing Slack thread IDs when Slack omits thread_ts\n- Keep tool replies in the correct thread\n- Prevent tool replies from consuming the first-reply thread slot\n- Treat auto-threaded Slack tool sends as the same thread for suppression\n- Make tool-reply suppression thread-aware in follow-ups\n- Stop injecting Slack message IDs into prompt text\n\n## Why it helps\n- Replies stay in the right thread\n- Fewer context leaks and confusing replies\n- Cleaner prompt input for the model
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR improves Slack threading reliability and reply routing by (1) recovering missing `thread_ts` for inbound thread replies, (2) making reply delivery thread-aware so tool output and model replies don’t spill into the wrong thread, and (3) tightening messaging-tool dedupe/suppression by including a `threadId` dimension. It also removes Slack message IDs from the user-visible prompt body in favor of structured metadata fields, which should reduce prompt noise and accidental leakage.
Key changes span the Slack monitor pipeline (`prepareSlackMessage`/`dispatchPreparedSlackMessage`), auto-reply payload building/suppression logic, and messaging tool send extraction so downstream routing can preserve thread context consistently across Slack (and partially Telegram).
<h3>Confidence Score: 3/5</h3>
- This PR is plausibly safe to merge but has a couple threading edge cases that could mis-route or suppress replies in Slack/Telegram.
- Most changes are localized and consistent (adding `threadId` propagation and improving Slack thread_ts recovery), but the new Slack tool-delivery threading behavior can change semantics (tool sends may start threads) and the suppression heuristic can hide genuine replies when thread IDs are assumed. Telegram’s new `caption` fallback also changes precedence when `message` is intentionally empty.
- src/slack/monitor/message-handler/dispatch.ts, src/auto-reply/reply/reply-payloads.ts, src/channels/plugins/actions/telegram.ts
<!-- greptile_other_comments_section -->
<sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#19083: Slack: preserve per-thread context and consistent thread replies
by jkimbo · 2026-02-17
85.3%
#22433: Slack: fix thread context loss after session reset
by stgarrity · 2026-02-21
84.1%
#12244: fix(slack): preserve thread context for DM thread replies
by junhoyeo · 2026-02-09
83.3%
#5935: fix(slack): persist thread starter body across thread messages
by thisischappy · 2026-02-01
82.9%
#4749: fix: handle string thread IDs in queue drain for Slack
by nvonpentz · 2026-01-30
82.2%
#20406: fix(slack): respect replyToMode when computing statusThreadTs in DMs
by QuinnYates · 2026-02-18
82.0%
#23320: fix(slack): respect replyToMode when incomingThreadTs is auto-created
by dorukardahan · 2026-02-22
81.5%
#7719: fix(slack): thread replies with @mentions dropped in requireMention...
by SocialNerd42069 · 2026-02-03
81.5%
#12199: fix(message): add threadId parameter to fetch schema for Slack thre...
by dbg-vanie · 2026-02-09
81.4%
#15864: feat: add deliverOnlyToolMessages config for clean messaging channe...
by gandalf-the-engineer · 2026-02-14
81.4%