openclaw - 💡(How to fix) Fix [Bug] dmScope: per-channel-peer does not work for webchat channel [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#73226Fetched 2026-04-29 06:22:02
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Participants

Root Cause

Root Cause:

Code Example

function resolvePolicyChannel(ctx) {
    const raw = normalizeOptionalString(ctx?.OriginatingChannel ?? ctx?.Provider ?? ctx?.Surface);
    if (!raw) return;
    const channel = normalizeLowercaseStringOrEmpty(raw);
    return channel && channel !== "webchat" ? channel : void 0; // ← BUG
}

---

const channel = resolvePolicyChannel(params.ctx);
const peerId = resolvePolicyDirectPeerId(params.ctx);
if (!channel || !peerId) return sessionKey; // ← falls through to main session

---

"origin": {
  "provider": "webchat",
  "from": "feishu:<feishu_user_id>"
}
RAW_BUFFERClick to expand / collapse

Environment:

  • OpenClaw v2026.4.26 (macOS, Node.js)
  • Configured session.dmScope: per-channel-peer
  • Channels: Feishu (websocket) + Web UI

Bug Summary:

Setting session.dmScope to per-channel-peer has no effect for the webchat channel. All webchat messages are routed to agent:main:main instead of creating a per-channel-peer session like agent:main:webchat:direct:<feishu_user_id>.


Root Cause:

File: dist/runtime-policy-session-key-D3idRY2M.js, function resolvePolicyChannel (line 9):

function resolvePolicyChannel(ctx) {
    const raw = normalizeOptionalString(ctx?.OriginatingChannel ?? ctx?.Provider ?? ctx?.Surface);
    if (!raw) return;
    const channel = normalizeLowercaseStringOrEmpty(raw);
    return channel && channel !== "webchat" ? channel : void 0; // ← BUG
}

The explicit && channel !== "webchat" check causes resolvePolicyChannel to return undefined for all webchat messages. This triggers an early return in resolveRuntimePolicySessionKey:

const channel = resolvePolicyChannel(params.ctx);
const peerId = resolvePolicyDirectPeerId(params.ctx);
if (!channel || !peerId) return sessionKey; // ← falls through to main session

Since channel is undefined, the function returns the main session key (agent:main:main) directly, bypassing the dmScope logic entirely.


Expected Behavior:

All channels (including webchat) should be routed according to dmScope. With dmScope: per-channel-peer, webchat messages should produce a session key like agent:main:webchat:direct:<feishu_user_id>.


Current Observations:

ChannelSession KeyCorrect?
Feishuagent:main:feishu:direct:<feishu_user_id>
Webchatagent:main:main

Sessions.json agent:main:main origin metadata confirms webchat is incorrectly tagged:

"origin": {
  "provider": "webchat",
  "from": "feishu:<feishu_user_id>"
}

Suggested Fix:

Remove the hardcoded && channel !== "webchat" exclusion from resolvePolicyChannel. Webchat should be treated the same as any other channel. If webchat was intentionally excluded for a reason, that rationale should be documented, and the proper solution would be to respect dmScope configuration or add an explicit webchat.dmScope option instead of hardcoding the exclusion.

extent analysis

TL;DR

Remove the && channel !== "webchat" check from the resolvePolicyChannel function to allow webchat messages to be routed according to the dmScope configuration.

Guidance

  • Identify the resolvePolicyChannel function in the dist/runtime-policy-session-key-D3idRY2M.js file and remove the hardcoded exclusion for webchat.
  • Verify that the dmScope configuration is set to per-channel-peer to ensure that webchat messages are routed correctly.
  • Test the change by sending a webchat message and checking the session key to confirm it matches the expected format agent:main:webchat:direct:<feishu_user_id>.
  • Review the origin metadata in the sessions.json file to ensure that webchat messages are correctly tagged.

Example

function resolvePolicyChannel(ctx) {
    const raw = normalizeOptionalString(ctx?.OriginatingChannel ?? ctx?.Provider ?? ctx?.Surface);
    if (!raw) return;
    const channel = normalizeLowercaseStringOrEmpty(raw);
    return channel; // Removed the hardcoded exclusion for webchat
}

Notes

The suggested fix assumes that the exclusion of webchat was an error and that webchat should be treated the same as other channels. If there was a specific reason for excluding webchat, additional changes may be necessary to respect the dmScope configuration or add an explicit webchat.dmScope option.

Recommendation

Apply the workaround by removing the hardcoded exclusion for webchat, as it is the most straightforward solution to resolve the issue and allow webchat messages to be routed according to the dmScope configuration.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Bug] dmScope: per-channel-peer does not work for webchat channel [1 participants]