#7868: Default DM sessions to per-channel scope (avoid webchat contention)
stale
## Summary
- Default DM session scope to per-channel-peer for non-webchat channels.
- Keep webchat on main to preserve UI continuity.
- Add tests for the new default behavior.
## Why
Feishu and other non-webchat DM channels currently collapse into the main session when `session.dmScope` is unset. This allows webchat to contend for the same session and can mis-route replies. Using per-channel-peer by default isolates channels while keeping webchat unchanged.
## Tests
- `resolve-route` unit tests updated. (Full test suite requires pnpm.)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR changes the default DM session scoping used by routing/session-key generation: when `cfg.session.dmScope` is unset, non-`webchat` DM channels now default to `per-channel-peer` (isolating each channel+peer into its own session key), while `webchat` keeps the historical default of collapsing DMs into the agent’s `main` session key for UI continuity. Unit tests in `src/routing/resolve-route.test.ts` were updated/added to lock in the new defaults.
<h3>Confidence Score: 5/5</h3>
- This PR appears safe to merge and matches the stated routing/session scoping intent.
- Changes are small, localized, and covered by updated/added unit tests. The new default dmScope selection only affects DM peers (non-DM session keys are unchanged), and `webchat` explicitly preserves the previous main-session behavior.
- No files require special attention
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</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
#9051: fix(sessions): respect dmScope config in CLI agent commands
by benleavett · 2026-02-04
85.3%
#13580: fix(telegram): skip updateLastRoute when dmScope isolates DM sessions
by lailoo · 2026-02-10
81.1%
#14689: onboard: set per-channel DM scope by default for multi-channel setups
by constansino · 2026-02-12
80.1%
#8095: fix(sessions): include accountId in deliveryContext for outbound pe...
by codeslayer44 · 2026-02-03
78.6%
#4693: fix: keep main session displayName on outbound sends
by ManojINaik · 2026-01-30
77.9%
#20078: feat(session): Add channelGroups config(optional config) for shared...
by demarlik01 · 2026-02-18
77.6%
#13057: feat(matrix): add sessionScope=room to route sessions by roomId
by spengrah · 2026-02-10
77.6%
#19403: feat(slack): add dm.threadSession option for per-message thread ses...
by Vasiliy-Bondarenko · 2026-02-17
77.6%
#11659: fix: Clarify session.dmScope is global in security audit warning
by veast · 2026-02-08
77.2%
#6084: Add dynamic Telegram agent routing for DM and groups
by Alfonsxh · 2026-02-01
75.3%