Skip to content

Discord/Telegram/Slack slash commands ignore session.dmScope routing #39605

Description

@Ciward

Bug Description

Native slash commands (/status, /ask, etc.) in Discord, Telegram, and Slack DMs route to agent:main:main instead of respecting session.dmScope (e.g. per-channel-peer). Normal text messages in the same DM correctly route to agent:main:discord:direct:<userId>.

Reproduction

  1. Set session.dmScope = per-channel-peer in config
  2. Restart gateway
  3. Send a normal text message in a Discord DM → session updates correctly (e.g. agent:main:discord:direct:1324002460267974737)
  4. Use /status in the same DM → session shows agent:main:main

Root Cause

All three channel providers (Discord, Telegram, Slack) load config once at provider startup (loadConfig()) and capture it in a closure. Normal message handlers call loadConfig() fresh per message, but the slash/native-command routing path reuses the stale startup config snapshot.

Since resolveAgentRoute reads cfg.session.dmScope to compute the session key, the slash command path always uses the config state from startup time, which may not reflect the current dmScope setting.

Affected code paths:

  • src/discord/monitor/native-command.tsdispatchDiscordCommandInteraction uses closure-captured cfg
  • src/telegram/bot-native-commands.tsresolveCommandRuntimeContext uses closure-captured cfg
  • src/slack/monitor/slash.tshandleSlashCommand uses ctx.cfg from startup

Working code path (for comparison):

  • src/discord/monitor/message-handler.preflight.ts – calls loadConfig() fresh per message

Impact

  • Users with dmScope = per-channel-peer (or per-peer, per-account-channel-peer) see slash commands operating on the wrong session
  • /status shows stale or unrelated session info in DMs
  • Affects all three built-in channels with native command support (Discord, Telegram, Slack)

Metadata

Metadata

Assignees

Labels

P2Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions