Skip to content

[Bug] Feishu: /new command reply routed to webchat instead of Feishu #53559

@riku

Description

@riku

Bug Description

When triggering /new from Feishu (via native Feishu message), the session reply appears in the web UI dashboard instead of being delivered back to the Feishu conversation.

Steps to reproduce:

  1. Have OpenClaw configured with Feishu channel
  2. From a Feishu DM, send /new
  3. The new session greeting appears in web UI, not in Feishu

Expected behavior:
The /new session should respect the Feishu delivery context and reply back to the Feishu conversation.

Actual behavior:
The reply is delivered to the web UI dashboard, completely missing the Feishu channel.


Root Cause Analysis

After examining the gateway source code (gateway-cli-DzTv3_FS.js), the issue is in how new sessions are created:

1. Session creation clears deliveryContext

When isNewSession = true, the gateway explicitly clears all delivery context (lines ~1321-1332):

...isNewSession && {
  lastChannel: void 0,
  lastTo: void 0,
  lastAccountId: void 0,
  lastThreadId: void 0,
  deliveryContext: void 0  // ← cleared
}

2. No channel hint passed to session resolution

resolveExplicitAgentSessionKey does not use the channel hint from the incoming request. It directly returns agent:main:main regardless of whether the request came from Feishu, Telegram, etc.

3. Routing decision fails

resolveChatSendOriginatingRoute (around line 11847) uses:

const routeChannelCandidate = normalizeMessageChannel(
  params.entry?.deliveryContext?.channel ?? params.entry?.lastChannel
);

When both are void 0, routeChannelCandidate is undefined, causing:

return {
  originatingChannel: INTERNAL_MESSAGE_CHANNEL,  // "internal"
  explicitDeliverRoute: false
};

Reply goes to internal webchat instead of Feishu.


Related Issues / Similar Fixes

This is similar to #48204 (Telegram/DM topic session keys), which was fixed in 2026.3.22:

Telegram/DM topic session keys: route named-account DM topics through the same per-account base session key across inbound messages, native commands, and session-state lookups so /status and thread recovery stop creating phantom sessions.

And #47797 (Control UI/session routing):

Control UI/session routing: preserve established external delivery routes when webchat views or sends in externally originated sessions.

The same pattern should apply to Feishu /new commands.


Environment

  • OpenClaw version: 2026.3.23
  • Channel: Feishu (websocket mode)
  • OS: macOS
  • Node: v25.6.0

Suggested Fix

When creating a new session from a channel-specific context (Feishu DM), the gateway should:

  1. Preserve the deliveryContext from the incoming message when creating the new session
  2. OR derive the session shape from the channel hint (e.g., agent:main:feishu:direct:ou_xxx for Feishu DMs)
  3. Ensure resolveChatSendOriginatingRoute can find the Feishu delivery target

The /new command handler should inherit the channel context from the message that triggered it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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