← Back to PRs

#2917: Slack: fix thread context + prevent reply spillover

by SocialNerd42069 open 2026-01-27 19:02 View on GitHub →
channel: slack agents
## 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