Skip to content

fix(feishu): set CommandSource=text for text slash commands#1

Open
wangdingxin wants to merge 3 commits into
mainfrom
fix/feishu-slash-commands
Open

fix(feishu): set CommandSource=text for text slash commands#1
wangdingxin wants to merge 3 commits into
mainfrom
fix/feishu-slash-commands

Conversation

@wangdingxin

Copy link
Copy Markdown
Owner

Summary

Fixes openclaw#79409 - Feishu channel does not handle text slash commands (/compact, /new, /stop)

The Feishu channel was not setting CommandSource when dispatching messages, causing slash commands like /compact, /new, /stop to be treated as regular messages instead of being intercepted by the command handler.

Root Cause

In extensions/feishu/src/bot.ts, the buildCtxPayloadForAgent function was not setting CommandSource in the context payload. Other channels (Discord, Matrix, Tlon) all set CommandSource: "text" to indicate that the message is a text command.

Fix

Added detection of text commands (messages starting with /) and conditionally set CommandSource: "text" in the context payload, following the pattern used by other channels.

Verification

  • Test that /compact command works in Feishu
  • Test that /new command works in Feishu
  • Test that /stop command works in Feishu
  • Verify regular messages still work correctly

Changes

+    // Determine if this message is a text command (starts with /)
+    const isTextCommand = effectiveCommandProbeBody.trim().startsWith("/");
+
     // --- Shared context builder for dispatch ---
     ...
         CommandAuthorized: commandAuthorized,
+        ...(isTextCommand ? { CommandSource: "text" as const } : {}),

Fixes openclaw#79409

wdx added 2 commits May 8, 2026 23:28
Fixes openclaw#79409 - Feishu channel does not handle text slash commands

The Feishu channel was not setting CommandSource when dispatching
messages, causing slash commands like /compact, /new, /stop to be
treated as regular messages instead of being intercepted by the
command handler.

This change follows the pattern used by other channels (Discord,
Matrix, Tlon) which all set CommandSource: "text" for messages
that start with "/".
When processing group messages, the From field only contains the sender's
open_id (e.g. feishu:ou_sender_1), not the group chat ID. This caused
resolveGroupSessionKey() to incorrectly extract the sender's open_id as
the groupId, which then got dropped by resolveTrustedGroupId() since it
doesn't match the actual group session context.

Adding GroupId: ctx.chatId for group messages ensures the correct group
chat ID is available to tool policy resolution, bypassing the malformed
From field parsing.

Fixes openclaw#78826
@wangdingxin wangdingxin force-pushed the fix/feishu-slash-commands branch from c931929 to ee7f220 Compare May 8, 2026 23:33
…essage tests

Add explicit assertions for:
- CommandSource: text in group slash command messages
- GroupId in group message context

These assertions verify the fixes for openclaw#79409 and openclaw#78826.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Feishu channel does not handle text slash commands (/compact, /new, /stop)

1 participant