#16893: fix(threads): inject thread starter context on every turn, not just new sessions
size: XS
Cluster:
Slack Thread Management Improvements
## Summary
Fixes #4927
The `ThreadStarterBody` injection in `get-reply-run.ts` was gated by `isNewSession`, which means follow-up messages in a thread lost the parent message context. This caused the bot to have no knowledge of what started the thread after the first reply.
**Root cause:** When the first thread reply creates the session, `isNewSession = true` and the thread starter is injected. But subsequent messages find the session already exists, so `isNewSession = false` and the thread starter body is silently dropped — even though the Slack message handler correctly fetches it for every thread message.
**Fix:** Remove the `isNewSession` gate from the `threadStarterBody` branch. The thread starter is a small context note (just the parent message text) that should be available on every turn. The `threadHistoryBody` (full thread history dump) retains the `isNewSession` gate since it's large and only needed once.
This affects all channels with thread support (Slack, Discord) that use `inheritParent: true`.
## Test plan
- [x] Existing thread tests pass (`pnpm test -- src/auto-reply/reply/get-reply-run.media-only.test.ts src/slack/monitor.tool-result.threads-top-level-replies-replytomode-is-all.test.ts`)
- [x] Verified thread starter is always populated by Slack/Discord prepare handlers for thread messages
- [x] `threadHistoryBody` still gated by `isNewSession` (no change in behavior for large history dumps)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Removed the `isNewSession` gate from `threadStarterBody` injection so that thread parent context is available on every turn, not just the first reply. Previously, follow-up messages in threads lost context of the parent message that started the thread. The `threadHistoryBody` (full thread history) correctly retains the `isNewSession` gate since it's large and only needed once.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The change is a minimal, well-targeted fix that removes an incorrect conditional gate. The logic is sound: `threadStarterBody` is a small context note (just the parent message text) that should be available on every turn in a thread, while `threadHistoryBody` (full history dump) correctly remains gated by `isNewSession`. The test coverage is good with a new test specifically validating the fix, and the change aligns with how Slack/Discord handlers populate thread starter context for every thread message.
- No files require special attention
<sub>Last reviewed commit: b92b28a</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#20389: fix(slack): inject thread history on first thread turn, not only on...
by lafawnduh1966 · 2026-02-18
86.5%
#5935: fix(slack): persist thread starter body across thread messages
by thisischappy · 2026-02-01
86.0%
#22433: Slack: fix thread context loss after session reset
by stgarrity · 2026-02-21
82.1%
#19083: Slack: preserve per-thread context and consistent thread replies
by jkimbo · 2026-02-17
80.1%
#23320: fix(slack): respect replyToMode when incomingThreadTs is auto-created
by dorukardahan · 2026-02-22
79.9%
#10686: fix(slack): use thread-level sessions for channels to prevent conte...
by pablohrcarvalho · 2026-02-06
78.4%
#20406: fix(slack): respect replyToMode when computing statusThreadTs in DMs
by QuinnYates · 2026-02-18
78.1%
#21108: slack: keep requireMention thread follow-ups when thread session is...
by JayElRay · 2026-02-19
77.6%
#23804: fix(slack): preserve string thread context in queue + DM route
by vincentkoc · 2026-02-22
77.3%
#12244: fix(slack): preserve thread context for DM thread replies
by junhoyeo · 2026-02-09
77.2%