#22951: feat(discord): make thread session isolation configurable
channel: discord
size: XS
Cluster:
Slack Thread Management Improvements
## Summary
- Adds `threadSessionSuffix` boolean to `DiscordAccountConfig`
- When `true`, thread messages get a `:thread:<threadId>` suffix on their session key, giving each thread its own isolated conversation session
- Defaults to `false` (existing behavior — threads share the parent channel's session)
### Motivation
Without this, all threads under a parent channel share the same session. This means conversation context from one thread bleeds into another — the bot may reference messages from a different thread, confusing users. With `threadSessionSuffix: true`, each thread gets its own session and the bot maintains separate conversation context per thread.
Note: `resolveThreadSessionKeys()` already supports the `useSuffix` parameter and defaults to `true` internally — this PR simply exposes the choice to operators via config rather than hardcoding `false`.
### Config
```json
{
"channels": {
"discord": {
"threadSessionSuffix": true
}
}
}
```
## Test plan
- [ ] With `threadSessionSuffix: false` (default): verify threads share parent session (existing behavior unchanged)
- [ ] With `threadSessionSuffix: true`: verify each thread gets its own session key (`:thread:<id>` suffix)
- [ ] Verify no impact on DM sessions
- [ ] Verify no impact on forum channel sessions
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds configurable thread session isolation for Discord via `threadSessionSuffix` boolean (defaults to `false` for backward compatibility). When enabled, each thread gets its own session key with `:thread:<threadId>` suffix, preventing conversation context from bleeding across threads.
**Key changes:**
- New `threadSessionSuffix?: boolean` field in `DiscordAccountConfig`
- Inbound message handler now respects config via `useSuffix: discordConfig?.threadSessionSuffix ?? false`
- Exposes existing `resolveThreadSessionKeys()` behavior that was previously hardcoded
**Issue found:**
- Outbound session resolution (`src/infra/outbound/outbound-session.ts:277`) still hardcodes `useSuffix: false`, creating a session key mismatch when the new config is enabled — inbound and outbound messages for the same thread would use different session keys, breaking conversation continuity
<h3>Confidence Score: 2/5</h3>
- This PR has a logic issue that breaks the feature when enabled
- Score reflects incomplete implementation — the inbound path correctly reads the new config, but the outbound path still hardcodes the old behavior, causing session key mismatches that would break conversation state when `threadSessionSuffix: true` is configured
- Pay close attention to `src/infra/outbound/outbound-session.ts` — needs updating to respect the new config
<sub>Last reviewed commit: 2fc51d1</sub>
<!-- 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>
<!-- /greptile_comment -->
Most Similar PRs
#19403: feat(slack): add dm.threadSession option for per-message thread ses...
by Vasiliy-Bondarenko · 2026-02-17
77.7%
#20078: feat(session): Add channelGroups config(optional config) for shared...
by demarlik01 · 2026-02-18
75.1%
#10686: fix(slack): use thread-level sessions for channels to prevent conte...
by pablohrcarvalho · 2026-02-06
73.9%
#15244: feat: Thread-session binding — route sub-agent I/O through platform...
by spk-alex · 2026-02-13
73.4%
#9181: feat(slack): add per-channel thread config override
by halbotley · 2026-02-05
73.3%
#16893: fix(threads): inject thread starter context on every turn, not just...
by battman21 · 2026-02-15
73.1%
#12075: feat(browser): session-aware context isolation for multi-agent brow...
by xiaoyaner0201 · 2026-02-08
73.0%
#16570: feat(mattermost): add replyToMode threading support
by FBartos · 2026-02-14
72.1%
#5935: fix(slack): persist thread starter body across thread messages
by thisischappy · 2026-02-01
71.4%
#19274: feat(mattermost): enable threaded replies in channels
by rockinyp · 2026-02-17
71.3%