Skip to content

fix(feishu): suppress NO_REPLY silent token before API send - #44828

Closed
Gitnapp wants to merge 1 commit into
openclaw:mainfrom
Gitnapp:fix/feishu-suppress-no-reply
Closed

Gitnapp wants to merge 1 commit into
openclaw:mainfrom
Gitnapp:fix/feishu-suppress-no-reply

Conversation

@Gitnapp

@Gitnapp Gitnapp commented Mar 13, 2026

Copy link
Copy Markdown

Summary

  • Feishu channel was missing SILENT_REPLY_TOKEN filtering that other channels (e.g. MSTeams) already implement
  • When an agent delivered a message via a plugin (e.g. the Feishu plugin itself) and replied with NO_REPLY, the token was sent as real text to the Feishu API, triggering a ⚠️ ✉️ Message failed error
  • Add isSilentReplyText checks in both the outbound adapter (sendText) and the reply dispatcher (deliver) to suppress the token before it reaches the Feishu API

Changes

  • extensions/feishu/src/outbound.ts: early-return with suppressed result when text is NO_REPLY
  • extensions/feishu/src/reply-dispatcher.ts: skip delivery when text-only payload is NO_REPLY

Test plan

  • Send a message via Feishu plugin that triggers a NO_REPLY response — should no longer show Message failed
  • Normal text messages still deliver correctly
  • Messages with media + NO_REPLY text still deliver the media

🤖 Generated with Claude Code

The Feishu channel was missing SILENT_REPLY_TOKEN filtering that other
channels (e.g. MSTeams) already implement. When an agent delivered a
message via a plugin and replied with NO_REPLY, the token was sent as
real text to the Feishu API, triggering a "Message failed" error.

Add isSilentReplyText checks in both the outbound adapter (sendText)
and the reply dispatcher (deliver) to suppress the token before it
reaches the Feishu API.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Copilot AI review requested due to automatic review settings March 13, 2026 07:37
@openclaw-barnacle openclaw-barnacle Bot added channel: feishu Channel integration: feishu size: XS labels Mar 13, 2026
@greptile-apps

greptile-apps Bot commented Mar 13, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds NO_REPLY / SILENT_REPLY_TOKEN suppression to the Feishu channel, bringing it in line with MSTeams. The core intent is correct and the happy path (text-only NO_REPLY via sendText and deliver) is properly handled. However, two gaps remain that allow the token to reach the Feishu API in edge-case paths:

  • outbound.ts – sendMedia text path (lines 134–141, 172–180): sendMedia calls sendOutboundText directly, which has no suppression guard. If text = "NO_REPLY" is passed alongside (or instead of) media, the token is still sent to Feishu.
  • reply-dispatcher.ts – deliver with mixed payloads (line 259): The !hasMedia condition in the isSilentReplyText guard means that when a ReplyPayload carries both NO_REPLY text and media, the suppression is skipped and the literal string "NO_REPLY" is forwarded to sendMarkdownCardFeishu / sendMessageFeishu, reproducing the original bug.

Confidence Score: 3/5

  • The PR partially fixes the NO_REPLY leakage but leaves two paths where the token can still reach the Feishu API.
  • The text-only sendText path is correctly patched and will resolve the most common case. However, the sendMedia bypass and the !hasMedia guard in reply-dispatcher.ts mean the fix is incomplete for mixed-payload scenarios, reintroducing the original "Message failed" error in those cases.
  • extensions/feishu/src/outbound.ts (sendMedia text path) and extensions/feishu/src/reply-dispatcher.ts (deliver with media) both need attention.

Comments Outside Diff (1)

  1. extensions/feishu/src/outbound.ts, line 134-141 (link)

    sendMedia text path bypasses the NO_REPLY suppression

    The sendText adapter now correctly suppresses NO_REPLY via the early-return added at line 87. However, sendMedia calls sendOutboundText directly (a private helper that has no suppression guard), so any time sendMedia is invoked with text = "NO_REPLY" the token still reaches the Feishu API.

    There are two call-sites in sendMedia that are affected:

    1. Line 134–141 – the "send text first" block
    2. Lines 172–180 – the "no media URL, just text" fallback

    The fix is to add an isSilentReplyText guard before calling sendOutboundText, matching the pattern already used in sendText:

    The "no media URL, just text" fallback at lines 172–180 needs the same treatment.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: extensions/feishu/src/outbound.ts
    Line: 134-141
    
    Comment:
    **`sendMedia` text path bypasses the `NO_REPLY` suppression**
    
    The `sendText` adapter now correctly suppresses `NO_REPLY` via the early-return added at line 87. However, `sendMedia` calls `sendOutboundText` **directly** (a private helper that has no suppression guard), so any time `sendMedia` is invoked with `text = "NO_REPLY"` the token still reaches the Feishu API.
    
    There are two call-sites in `sendMedia` that are affected:
    1. **Line 134–141** – the "send text first" block
    2. **Lines 172–180** – the "no media URL, just text" fallback
    
    The fix is to add an `isSilentReplyText` guard before calling `sendOutboundText`, matching the pattern already used in `sendText`:
    
    
    
    The "no media URL, just text" fallback at lines 172–180 needs the same treatment.
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/feishu/src/reply-dispatcher.ts
Line: 259-261

Comment:
**`NO_REPLY` text not suppressed when media is also present**

The `!hasMedia` guard means that when a payload carries both `NO_REPLY` text *and* media, the early-return is skipped and execution falls straight through to the `if (shouldDeliverText)` block (line 263), which calls `sendMarkdownCardFeishu` / `sendMessageFeishu` with the literal string `"NO_REPLY"` — exactly the bug this PR is trying to fix.

The intent described in the PR ("Messages with media + `NO_REPLY` text still deliver the media") requires the *text* to be suppressed while still delivering the media, not skipping the suppression entirely.

A safer pattern mirrors what the pre-existing empty-text guard already does: derive an effective `shouldDeliverText` that accounts for the silent token, then let the rest of the function use it:

```
// Suppress NO_REPLY silent token — already delivered via another channel/plugin.
const isSilentText = shouldDeliverText && isSilentReplyText(text, SILENT_REPLY_TOKEN);
if (isSilentText && !hasMedia) {
  return;
}

if (shouldDeliverText && !isSilentText) {
  // ... existing text delivery logic
}
```

With this approach, `NO_REPLY`-only payloads still short-circuit, while mixed payloads skip the text but continue to the `hasMedia` block.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: extensions/feishu/src/outbound.ts
Line: 134-141

Comment:
**`sendMedia` text path bypasses the `NO_REPLY` suppression**

The `sendText` adapter now correctly suppresses `NO_REPLY` via the early-return added at line 87. However, `sendMedia` calls `sendOutboundText` **directly** (a private helper that has no suppression guard), so any time `sendMedia` is invoked with `text = "NO_REPLY"` the token still reaches the Feishu API.

There are two call-sites in `sendMedia` that are affected:
1. **Line 134–141** – the "send text first" block
2. **Lines 172–180** – the "no media URL, just text" fallback

The fix is to add an `isSilentReplyText` guard before calling `sendOutboundText`, matching the pattern already used in `sendText`:

```suggestion
    if (text?.trim() && !isSilentReplyText(text.trim(), SILENT_REPLY_TOKEN)) {
      await sendOutboundText({
        cfg,
        to,
        text,
        accountId: accountId ?? undefined,
        replyToMessageId,
      });
    }
```

The "no media URL, just text" fallback at lines 172–180 needs the same treatment.

How can I resolve this? If you propose a fix, please make it concise.

Last reviewed commit: 0da34a2

Comment on lines +259 to +261
if (shouldDeliverText && !hasMedia && isSilentReplyText(text, SILENT_REPLY_TOKEN)) {
return;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO_REPLY text not suppressed when media is also present

The !hasMedia guard means that when a payload carries both NO_REPLY text and media, the early-return is skipped and execution falls straight through to the if (shouldDeliverText) block (line 263), which calls sendMarkdownCardFeishu / sendMessageFeishu with the literal string "NO_REPLY" — exactly the bug this PR is trying to fix.

The intent described in the PR ("Messages with media + NO_REPLY text still deliver the media") requires the text to be suppressed while still delivering the media, not skipping the suppression entirely.

A safer pattern mirrors what the pre-existing empty-text guard already does: derive an effective shouldDeliverText that accounts for the silent token, then let the rest of the function use it:

// Suppress NO_REPLY silent token — already delivered via another channel/plugin.
const isSilentText = shouldDeliverText && isSilentReplyText(text, SILENT_REPLY_TOKEN);
if (isSilentText && !hasMedia) {
  return;
}

if (shouldDeliverText && !isSilentText) {
  // ... existing text delivery logic
}

With this approach, NO_REPLY-only payloads still short-circuit, while mixed payloads skip the text but continue to the hasMedia block.

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/feishu/src/reply-dispatcher.ts
Line: 259-261

Comment:
**`NO_REPLY` text not suppressed when media is also present**

The `!hasMedia` guard means that when a payload carries both `NO_REPLY` text *and* media, the early-return is skipped and execution falls straight through to the `if (shouldDeliverText)` block (line 263), which calls `sendMarkdownCardFeishu` / `sendMessageFeishu` with the literal string `"NO_REPLY"` — exactly the bug this PR is trying to fix.

The intent described in the PR ("Messages with media + `NO_REPLY` text still deliver the media") requires the *text* to be suppressed while still delivering the media, not skipping the suppression entirely.

A safer pattern mirrors what the pre-existing empty-text guard already does: derive an effective `shouldDeliverText` that accounts for the silent token, then let the rest of the function use it:

```
// Suppress NO_REPLY silent token — already delivered via another channel/plugin.
const isSilentText = shouldDeliverText && isSilentReplyText(text, SILENT_REPLY_TOKEN);
if (isSilentText && !hasMedia) {
  return;
}

if (shouldDeliverText && !isSilentText) {
  // ... existing text delivery logic
}
```

With this approach, `NO_REPLY`-only payloads still short-circuit, while mixed payloads skip the text but continue to the `hasMedia` block.

How can I resolve this? If you propose a fix, please make it concise.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents Feishu outbound sends from accidentally posting the NO_REPLY / SILENT_REPLY_TOKEN marker as real text, aligning Feishu with other channels’ silent-reply handling and avoiding Feishu API “Message failed” errors.

Changes:

  • Add a NO_REPLY suppression guard in Feishu outbound sendText.
  • Add a NO_REPLY suppression guard in the Feishu reply dispatcher deliver path.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
extensions/feishu/src/outbound.ts Adds early suppression for silent-reply token before calling Feishu send APIs.
extensions/feishu/src/reply-dispatcher.ts Skips delivering text-only silent replies before they reach the Feishu send APIs.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 85 to +89
sendText: async ({ cfg, to, text, accountId, replyToId, threadId, mediaLocalRoots }) => {
// Suppress NO_REPLY silent token — already delivered via another channel/plugin.
if (!text?.trim() || isSilentReplyText(text.trim(), SILENT_REPLY_TOKEN)) {
return { channel: "feishu", messageId: "suppressed", channelId: to };
}
@@ -1,5 +1,6 @@
import fs from "fs";
import path from "path";
import { isSilentReplyText, SILENT_REPLY_TOKEN } from "openclaw/plugin-sdk";
Comment on lines +258 to +261
// Suppress NO_REPLY silent token — already delivered via another channel/plugin.
if (shouldDeliverText && !hasMedia && isSilentReplyText(text, SILENT_REPLY_TOKEN)) {
return;
}
Comment on lines +258 to +261
// Suppress NO_REPLY silent token — already delivered via another channel/plugin.
if (shouldDeliverText && !hasMedia && isSilentReplyText(text, SILENT_REPLY_TOKEN)) {
return;
}
@@ -1,3 +1,4 @@
import { isSilentReplyText, SILENT_REPLY_TOKEN } from "openclaw/plugin-sdk";
sendText: async ({ cfg, to, text, accountId, replyToId, threadId, mediaLocalRoots }) => {
// Suppress NO_REPLY silent token — already delivered via another channel/plugin.
if (!text?.trim() || isSilentReplyText(text.trim(), SILENT_REPLY_TOKEN)) {
return { channel: "feishu", messageId: "suppressed", channelId: to };

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0da34a2da2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +259 to +260
if (shouldDeliverText && !hasMedia && isSilentReplyText(text, SILENT_REPLY_TOKEN)) {
return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Close streaming card before suppressing silent final text

When renderMode is card with streaming enabled, onReplyStart opens a Feishu streaming card immediately; this new early return skips the normal final-text path that calls closeStreaming(), so a final NO_REPLY payload with no media exits before the streaming session is finalized with content. The later idle close runs with empty streamText, and FeishuStreamingSession.close does not update card content for empty text, leaving users with a lingering ⏳ Thinking... placeholder instead of a truly silent reply.

Useful? React with 👍 / 👎.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Apr 28, 2026
@clawsweeper

clawsweeper Bot commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as superseded: this branch is a partial, conflicting Feishu silent-token fix, while current main already handles the shared reply-dispatcher normalization path and the remaining Feishu outbound hardening is tracked by the newer canonical PR at #56167.

So I’m closing this here and keeping the remaining discussion on the canonical linked item.

Review details

Best possible solution:

Close this partial branch and finish any still-needed Feishu outbound guard and tests through #56167 or a narrow rebased replacement.

Do we have a high-confidence way to reproduce the issue?

Yes, at source level. The PR branch leaves sendMedia text exits and mixed media-plus-NO_REPLY dispatcher payloads able to forward the token, while current main already handles the shared dispatcher normalization path.

Is this the best way to solve the issue?

No. This PR is not the best way to solve the issue because it uses a non-exported root SDK import, only partially guards Feishu text exits, and is superseded by the newer outbound-focused PR with tests.

Security review:

Security review cleared: The diff only touches Feishu runtime code and imports existing SDK helpers; it does not change workflows, dependencies, scripts, generated artifacts, publishing, permissions, or secrets handling.

What I checked:

Likely related people:

  • vincentkoc: Recent current-main history includes Feishu outbound runtime split, voice-text handling, streaming labels, and reply-dispatcher work on the same files; the timeline also shows Vincent assigned to this PR. (role: recent Feishu outbound/runtime contributor; confidence: high; commits: 14312ff5704f, e4cc8cd97513, 111df161df38; files: extensions/feishu/src/outbound.ts, extensions/feishu/src/outbound.test.ts, extensions/feishu/src/reply-dispatcher.ts)
  • steipete: Recent history touches the shared plugin SDK surface, Feishu outbound/reply-dispatcher paths, and the related user-facing Feishu NO_REPLY report was closed with implementation provenance by Peter Steinberger. (role: recent reply pipeline and SDK surface contributor; confidence: medium; commits: 827b0de0ce74, 8dd6a2d323e1, 62edfdffbdd0; files: src/plugin-sdk/index.ts, src/plugin-sdk/reply-runtime.ts, src/auto-reply/reply/normalize-reply.ts)
  • obviyus: Commit history shows related cron/announce NO_REPLY suppression work modifying reply normalization, tokens, and cron delivery tests, which is adjacent to the original Feishu heartbeat leak context. (role: related NO_REPLY suppression contributor; confidence: medium; commits: 16c608e3937e; files: src/auto-reply/reply/normalize-reply.ts, src/auto-reply/tokens.ts, src/cron/isolated-agent/delivery-dispatch.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 839a5b1ec0d9.

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Apr 29, 2026
@vincentkoc vincentkoc self-assigned this May 3, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu size: XS stale Marked as stale due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants