Skip to content

feat(routing): add per-account-channel-peer session scope#3095

Merged
obviyus merged 2 commits into
openclaw:mainfrom
jarvis-sam:feat/per-account-channel-peer-scope
Jan 28, 2026
Merged

feat(routing): add per-account-channel-peer session scope#3095
obviyus merged 2 commits into
openclaw:mainfrom
jarvis-sam:feat/per-account-channel-peer-scope

Conversation

@jarvis-sam

Copy link
Copy Markdown

Summary

Adds a new dmScope option: per-account-channel-peer that includes the accountId in session keys, enabling isolated sessions per channel account.

Problem

When running multiple Telegram bots (or other channel accounts) pointing to the same agent, all DMs from the same user merge into a single session. This breaks:

  • Separation of concerns (work/personal/tasks contexts mixing)
  • Parallelism (can't have concurrent conversations across bots)
  • Privacy (sensitive context leaks between bots)

Solution

New session key format that includes accountId:

  • Before: agent:main:telegram:dm:123456
  • After: agent:main:telegram:tasks:dm:123456

Configuration

{
  "session": {
    "dmScope": "per-account-channel-peer"
  }
}

Changes

  • src/config/types.base.ts — Add new scope to DmScope type
  • src/config/zod-schema.session.ts — Add to zod schema
  • src/routing/session-key.ts — Include accountId in key generation
  • src/routing/resolve-route.ts — Pass accountId through routing
  • src/infra/outbound/outbound-session.ts — Extract accountId from delivery context
  • src/routing/resolve-route.test.ts — Add tests (13/13 passing)

Testing

npm test -- src/routing/resolve-route.test.ts

All 13 tests pass, including 2 new tests for per-account-channel-peer routing.

Closes #3094

@obviyus obviyus self-assigned this Jan 28, 2026
@obviyus obviyus added the channel: telegram Channel integration: telegram label Jan 28, 2026
Jarvis Deploy and others added 2 commits January 28, 2026 11:34
Adds a new dmScope option that includes accountId in session keys,
enabling isolated sessions per channel account for multi-bot setups.

- Add 'per-account-channel-peer' to DmScope type
- Update session key generation to include accountId
- Pass accountId through routing chain
- Add tests for new routing behavior (13/13 passing)

Closes openclaw#3094

Co-authored-by: Sebastian Almeida <[email protected]>
@obviyus
obviyus force-pushed the feat/per-account-channel-peer-scope branch from 08ff474 to 914b0c1 Compare January 28, 2026 06:12
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: whatsapp-web Channel integration: whatsapp-web gateway Gateway runtime security Security documentation commands Command implementations and removed channel: telegram Channel integration: telegram labels Jan 28, 2026
@obviyus
obviyus merged commit b6a3a91 into openclaw:main Jan 28, 2026
1 check passed
@obviyus

obviyus commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

Correction: SHAs below (previous comment had literal vars).

  • Gate: pnpm lint && pnpm build && pnpm test
  • Land commit: b6a3a91
  • Merge commit: b6a3a91

Thanks @jarvis-sam!

YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Feb 1, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Feb 1, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Feb 1, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Feb 1, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Feb 1, 2026
bestNiu pushed a commit to bestNiu/clawdbot that referenced this pull request Feb 5, 2026
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: whatsapp-web Channel integration: whatsapp-web commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime security Security documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add per-account-channel-peer session scope for multi-bot setups

2 participants