Skip to content

Feishu: pre-tool narration text visible in streaming cards — confusing UX for end users #54080

Closed

Description

@kagura-chen

Problem

When an agent writes narration text before making tool calls (e.g., "Let me check the recent conversation context to understand..."), this text is delivered to the Feishu streaming card and visible to the end user. This creates a confusing experience — the user sees internal reasoning that was not intended as part of the reply.

Before vs after

This behavior appeared after upgrading the gateway from 2026.3.13 to 2026.3.22. We suspect the fix in #36957 ("pre-tool text is preserved in live chat deltas/finals") changed the delivery semantics — previously, pre-tool text was silently dropped in Feishu cards; now it is retained and displayed.

The original fix was correct for the TUI/WebChat (where losing text was a bug), but for Feishu (and likely other messaging channels), showing pre-tool narration creates UX issues:

  • Users see English "thinking out loud" text mixed into their native-language conversation
  • Intermediate reasoning appears as part of the reply, making it feel unfinished or broken
  • Users may think the model changed or something is misconfigured

Expected behavior

Pre-tool narration text should not be delivered to Feishu (and other messaging channels) as visible content. Only the final text — after all tool calls complete — should be sent.

Current workaround

Instructing the agent in AGENTS.md to never narrate before tool calls. This works but is fragile and suppresses narration that may be useful in other contexts (TUI, WebChat).

Proposed solution

A per-channel or global config option to suppress pre-tool text delivery to messaging channels. Something like:

{
  channels: {
    feishu: {
      suppressPreToolText: true  // only deliver final text after tool calls
    }
  }
}

Or integrate with the existing blockStreamingBreak semantics:

  • "message_end" should naturally suppress pre-tool text by waiting for the full response

Related issues

Environment

  • Gateway: 2026.3.22
  • Channel: Feishu (websocket mode, streaming cards enabled)
  • Model: Claude (Anthropic API)
  • Config: default blockStreamingDefault (off), Feishu streaming: true, blockStreaming: true

Activity

  1. kagura-chen commented on Mar 24, 2026

    @kagura-chen
    ContributorAuthor

    Investigation — Root Cause Analysis

    After tracing the code path, here is a detailed analysis.

    The delivery pipeline for Feishu streaming cards

    text_delta event
      → handleMessageUpdate() (pi-embedded-subscribe.handlers.messages.ts:151)
        → deltaBuffer accumulates text
        → onPartialReply(data) fires (line 306-308)
          → feishu reply-dispatcher queueStreamingUpdate() (line 483-492)
            → FeishuStreamingSession.update() → card API update
    

    Key observation: Feishu explicitly sets disableBlockStreaming: true (reply-dispatcher.ts:482) and uses onPartialReply for streaming instead. This means onPartialReply fires on every text_delta event, not just final text.

    What happens with pre-tool text

    1. Agent writes "Let me check..." → text_delta events fire → onPartialReply updates streaming card
    2. Agent makes tool call → text stops, card still shows "Let me check..."
    3. Agent writes final response → text_delta events fire again
    4. mergeStreamingText() (streaming-card.ts:114) merges old + new text
    5. Since the new text doesn't start with the old text, the fallback at line 146 appends them
    6. Final card shows: "Let me check..." + final response concatenated

    Additionally, buildEmbeddedRunPayloads() (payloads.ts) iterates over all entries in assistantTexts[], which includes both pre-tool and post-tool text segments.

    Why this wasn't visible before 2026.3.22

    In 2026.3.13, the #36957 fix ("pre-tool text is preserved in live chat deltas/finals") changed how assistantTexts accumulates text. Before that fix, pre-tool text segments were dropped during streaming, so onPartialReply would only fire for the final text block. After the fix, all text segments are retained — which is correct for TUI/WebChat but creates this UX issue for messaging channels.

    Possible solutions (in order of preference)

    1. Per-channel onPartialReply filtering: The handleMessageUpdate handler could check a flag (e.g., suppressPreToolPartials) and only emit onPartialReply for text in the final assistant message (i.e., after the last tool call). This requires knowing whether the current text will be followed by tool calls — which isn't known at streaming time.

    2. mergeStreamingText reset on new assistant message: When a new message_start fires after a tool call, reset streamText in the Feishu dispatcher so the new text doesn't get concatenated with old pre-tool text. The streaming card would show only the latest text segment.

    3. Channel-level suppressIntermediateText config (as proposed in Suppress intermediate text output before tool calls in group channels #50989): Drop all text segments except the last one in buildEmbeddedRunPayloads when configured. This would fix the final delivery but not the streaming preview.

    4. blockStreamingBreak: "message_end" as workaround: Setting this would delay text emission until the full message is complete. But since Feishu uses onPartialReply (not block streaming), this alone wouldn't help — onPartialReply still fires during streaming regardless of blockStreamingBreak.

    Current workaround

    Instructing the agent to never write narration before tool calls (via AGENTS.md "do not narrate routine tool calls"). Effective but fragile.

    Config-level workaround?

    Setting channels.feishu.streaming: false would disable the streaming card entirely and wait for the full reply. This would eliminate the pre-tool text preview issue, but also removes the real-time streaming experience. Not ideal.

    Environment

    • Gateway: 2026.3.22
    • Feishu: websocket mode, streaming cards enabled (default)
    • blockStreamingDefault: off (default)
    • disableBlockStreaming: true (hardcoded in feishu reply-dispatcher)
  2. kagura-chen commented on Mar 24, 2026

    @kagura-chen
    ContributorAuthor

    Correction: Root cause is NOT the 2026.3.22 upgrade

    After further investigation with the user, the behavior was not present yesterday despite running the same gateway version (2026.3.22). The issue only started in today's session.

    Reviewing the session JSONL confirms:

    • Today's session has 45 pre-tool narration instances — the model was unusually verbose with internal reasoning before tool calls
    • Yesterday's sessions (both cron/isolated and DM) had far fewer pre-tool narrations
    • Cron/isolated sessions deliver only final results (not streaming), so pre-tool text was never visible to the user even if present

    Revised root cause

    The actual issue is that onPartialReply in the Feishu streaming card path faithfully renders all text_delta events, including pre-tool narration. This has always been the case — but it only becomes a UX problem when the model writes significant amounts of narration text before tool calls.

    The original issue request remains valid: there should be a way for messaging channels to suppress intermediate text that precedes tool calls, regardless of whether the model chooses to narrate or not. But the #36957 attribution was incorrect — the pre-tool text was already being rendered in streaming cards before that fix.

    Summary

    • Not a regression from 2026.3.22
    • Model behavior variance caused today's session to produce more pre-tool narration
    • Feature request remains valid: per-channel config to suppress pre-tool text in streaming would prevent this UX issue regardless of model behavior
  3. steipete commented on Apr 25, 2026

    @steipete
    Contributor

    Closing this as implemented after Codex review.

    Current main already suppresses commentary/pre-tool assistant text before channel partial delivery, which prevents Feishu streaming cards from showing that narration.

    What I checked:

    So I’m closing this as already implemented rather than keeping a duplicate issue open.

    Review notes: reviewed against 8f64cd3e4d83; fix evidence: commit 8f64cd3e4d83.

  4. locked as resolved and limited conversation to collaborators on Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions