openclaw - 💡(How to fix) Fix [Bug] Feishu streaming card merges unrelated replies when agent produces multiple final messages [1 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#43707Fetched 2026-04-08 00:16:55
View on GitHub
Comments
1
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
closed ×1commented ×1locked ×1

When the agent produces multiple independent final replies (replies=2) in a single request, the Feishu streaming card incorrectly merges content from the second reply into the first card, while also sending the second reply as a separate card. This results in duplicate content being displayed to the user.

Root Cause

The `mergeStreamingText` function in `extensions/feishu/src/streaming-card.ts` has a fallback that concatenates unrelated text when no overlap is detected:

```typescript // Fallback for fragmented partial chunks: append as-is to avoid losing tokens. return `${previous}${next}`; ```

This causes unrelated final replies to be incorrectly merged.

Fix Action

Fix / Workaround

When agent produces multiple independent replies, each should be delivered as a separate message, OR they should be properly merged into a single coherent message without duplication.

``` Mar 12 12:01:27 Started streaming: cardId=7616214340648340671, messageId=om_x100b5417e74b60a4c3a474e9be9dc4f Mar 12 12:02:10 Closed streaming: cardId=7616214340648340671 Mar 12 12:02:10 Started streaming: cardId=7616214523998375126, messageId=om_x100b5417e2e3907cc2906e393e5ae37 Mar 12 12:02:11 Closed streaming: cardId=7616214523998375126 Mar 12 12:02:11 dispatch complete (queuedFinal=true, replies=2) ```

RAW_BUFFERClick to expand / collapse

Summary

When the agent produces multiple independent final replies (replies=2) in a single request, the Feishu streaming card incorrectly merges content from the second reply into the first card, while also sending the second reply as a separate card. This results in duplicate content being displayed to the user.

What happened?

  1. Agent received a request to create a calendar meeting
  2. Agent produced two independent replies:
    • First reply: "让我先读取一下日历工具的使用说明..." followed by meeting details
    • Second reply: Just the meeting details
  3. User received two Feishu messages:
    • First message: Contains both the first reply AND the second reply content (merged)
    • Second message: Contains only the second reply content
  4. The content is duplicated across messages

Expected behavior

When agent produces multiple independent replies, each should be delivered as a separate message, OR they should be properly merged into a single coherent message without duplication.

Evidence from logs

``` Mar 12 12:01:27 Started streaming: cardId=7616214340648340671, messageId=om_x100b5417e74b60a4c3a474e9be9dc4f Mar 12 12:02:10 Closed streaming: cardId=7616214340648340671 Mar 12 12:02:10 Started streaming: cardId=7616214523998375126, messageId=om_x100b5417e2e3907cc2906e393e5ae37 Mar 12 12:02:11 Closed streaming: cardId=7616214523998375126 Mar 12 12:02:11 dispatch complete (queuedFinal=true, replies=2) ```

Two different `cardId`s were created, but the first card contained content from both replies.

Root cause analysis

The `mergeStreamingText` function in `extensions/feishu/src/streaming-card.ts` has a fallback that concatenates unrelated text when no overlap is detected:

```typescript // Fallback for fragmented partial chunks: append as-is to avoid losing tokens. return `${previous}${next}`; ```

This causes unrelated final replies to be incorrectly merged.

Environment

  • OpenClaw version: 2026.3.8
  • Channel: Feishu
  • Streaming mode: enabled (card mode)

Suggested fix

  1. Track whether streaming session has received a final delivery
  2. If a new final reply arrives after a previous final was already delivered, start a new streaming card instead of merging
  3. Or: Add a "strict" mode to `mergeStreamingText` that refuses to merge completely unrelated content

extent analysis

Fix Plan

To address the issue of duplicate content being displayed to the user, we need to modify the mergeStreamingText function in extensions/feishu/src/streaming-card.ts. Here are the steps:

  • Track whether a streaming session has received a final delivery by introducing a finalDelivered flag.
  • If a new final reply arrives after a previous final was already delivered, start a new streaming card instead of merging.
  • Alternatively, add a "strict" mode to mergeStreamingText that refuses to merge completely unrelated content.

Example Code

// Introduce a flag to track final delivery
let finalDelivered = false;

// ...

// Modify the mergeStreamingText function
function mergeStreamingText(previous: string, next: string): string {
  if (finalDelivered) {
    // Start a new streaming card if a new final reply arrives after a previous final was delivered
    return next;
  }

  // Check for overlap and merge if possible
  const overlap = getOverlap(previous, next);
  if (overlap) {
    return mergeWithOverlap(previous, next, overlap);
  }

  // If no overlap is detected, do not merge unrelated text
  finalDelivered = true;
  return previous;
}

// ...

// Set finalDelivered to true when a final reply is delivered
function deliverFinalReply(reply: string) {
  finalDelivered = true;
  // Deliver the reply
}

Verification

To verify that the fix worked, test the following scenarios:

  • Send multiple independent final replies in a single request and verify that each reply is delivered as a separate message.
  • Send a final reply after a previous final reply was delivered and verify that a new streaming card is started instead of merging the content.

Extra Tips

  • Make sure to reset the finalDelivered flag when a new streaming session is started.
  • Consider adding logging to track when a new streaming card is started and when a final reply is delivered.

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…

FAQ

Expected behavior

When agent produces multiple independent replies, each should be delivered as a separate message, OR they should be properly merged into a single coherent message without duplication.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING