openclaw - 💡(How to fix) Fix [Bug] v2026.3.11: CLI 'openclaw agent --channel discord --to' routes to agent:*:main instead of live channel session [3 comments, 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#44448Fetched 2026-04-08 00:46:55
View on GitHub
Comments
3
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
commented ×3

Root Cause

The CLI session resolver does not search by real delivery context (channel + to + accountId). Additionally:

  1. The command path did not propagate enough context to the resolver
  2. Discord targets were not normalized (difference between 148... and channel:148...)
  3. The session resolver in compact used incorrect logic for lookup by delivery context

Fix Action

Fix / Workaround

Manual Patch Applied (Local)

Post-Patch Validation

HIGH: This is a manual patch on compiled files in dist/. It will be lost on the next OpenClaw update/reinstall. Recommended:

  1. Apply official fix in source
  2. Maintain post-update revalidation script
RAW_BUFFERClick to expand / collapse

Bug Summary

In OpenClaw v2026.3.11, the CLI openclaw agent --channel discord --to ... incorrectly resolves the agent:*:main session instead of the live session associated with the specified Discord channel/thread.

Observed Symptoms

  • openclaw agent --channel discord --to ... appears to deliver but resolves wrong session
  • Messages go to agent:*:main instead of the live session of the Discord target
  • No way to route CLI to a specific channel/thread session by delivery context

Root Cause

The CLI session resolver does not search by real delivery context (channel + to + accountId). Additionally:

  1. The command path did not propagate enough context to the resolver
  2. Discord targets were not normalized (difference between 148... and channel:148...)
  3. The session resolver in compact used incorrect logic for lookup by delivery context

Affected Files (compiled dist/)

  • dist/gateway-cli-BjsM6fWb.js - Session resolver without delivery target lookup
  • dist/compact-1mmJ_KWL.js - Session resolver for agent command without delivery context lookup
  • dist/register.agent-DHoJWl4M.js - Command path without passing channel and replyAccount/accountId

Manual Patch Applied (Local)

File: dist/gateway-cli-BjsM6fWb.js

  • Added session resolution by real delivery target (channel + to + accountId)
  • Normalization of Discord targets (148...channel:148...)

File: dist/compact-1mmJ_KWL.js

  • Added lookup by delivery context within the agent command session resolver
  • Fixed regression: use buildAgentMainSessionKey(...) instead of resolveAgentMainSessionKey

File: dist/register.agent-DHoJWl4M.js

  • Now passes channel and replyAccount/accountId to the resolver

Post-Patch Validation

  • ✅ CLI can route by real Discord target
  • ✅ Messages reach the correct channel/thread session
  • ✅ No longer defaults to agent:*:main

Regression Risk

HIGH: This is a manual patch on compiled files in dist/. It will be lost on the next OpenClaw update/reinstall. Recommended:

  1. Apply official fix in source
  2. Maintain post-update revalidation script

Related Issues

  • #36401 - [Feature]: Add --session-key option to openclaw agent CLI for precise session routing
  • #41562 - Discord: thread session delivery leaks to main session target when fallback triggers
  • #16149 - Regression: Discord guild channel messages route to agent:main:main

Environment

  • OpenClaw: v2026.3.11
  • CLI: openclaw agent --channel discord --to ...
  • Patch date: March 2026

extent analysis

Fix Plan

To resolve the issue, apply the following changes:

  • Update the session resolver in gateway-cli-BjsM6fWb.js to search by real delivery context (channel + to + accountId).
  • Normalize Discord targets in compact-1mmJ_KWL.js by prefixing the channel ID with channel:.
  • Modify register.agent-DHoJWl4M.js to pass channel and replyAccount/accountId to the resolver.

Example code changes:

// gateway-cli-BjsM6fWb.js
function resolveSession(channel, to, accountId) {
  // Search by real delivery context
  const deliveryContext = `${channel}:${to}:${accountId}`;
  // ...
}

// compact-1mmJ_KWL.js
function normalizeDiscordTarget(target) {
  if (!target.startsWith('channel:')) {
    return `channel:${target}`;
  }
  return target;
}

// register.agent-DHoJWl4M.js
function handleAgentCommand(channel, to, accountId) {
  // Pass channel and replyAccount/accountId to the resolver
  const session = resolveSession(channel, to, accountId);
  // ...
}

Verification

To verify the fix, run the following commands:

  • openclaw agent --channel discord --to <channel_id> -- <message>
  • Check that the message is delivered to the correct channel/thread session.
  • Repeat the test with different channel IDs and message contents to ensure the fix is working as expected.

Extra Tips

  • To prevent regressions, consider adding automated tests for the session resolver and Discord target normalization.
  • When updating OpenClaw, reapply the manual patch or ensure that the official fix is included in the new version.
  • Consider implementing the --session-key option (issue #36401) to provide an alternative way to specify the session key.

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