Skip to content

Feishu channel: tool call status display causes streaming output reset #312

@39499740

Description

@39499740

Pre-checks

Deployment Method

Source (setup.sh)

Steps to Reproduce

  1. Configure a Feishu bot for an agent with CardKit streaming enabled.
  2. Send a message that triggers a tool call (e.g., asking the agent to search the web, read a document, etc.).
  3. Observe the streaming card output during the tool execution.

Expected vs Actual Behavior

Expected: The streaming output should flow smoothly without interruption. The LLM reply text should appear continuously in the CardKit streaming element.

Actual: When a tool call starts or completes, the _ws_on_tool_call callback triggers _flush_stream("tool"), which injects tool status text (e.g., ⏳ Tool running: search_web / ✅ Tool done: search_web) into the CardKit streaming element content. This concatenation of tool status lines before the actual reply text causes the streaming element to be rewritten from scratch, visually resetting the output and creating a jarring flash/flicker.

Root Cause

The tool call status display was originally added to work around Feishu card block rendering limitations (blocks not updating smoothly). Now that CardKit streaming mode is used, the tool status text injected into the streaming element disrupts the smooth incremental output:

  1. Each tool status change triggers _flush_stream("tool") → an extra stream_card_content call.
  2. The tool status lines are prepended to the accumulated reply text before being sent to the CardKit streaming element, effectively rewriting the entire content.
  3. This breaks the continuity of the streaming element, causing visible resets/flickers.

Proposed Fix

Remove the tool call status display logic from the Feishu channel:

  1. Stop passing on_tool_call=_ws_on_tool_call to _call_agent_llm().
  2. Remove _tool_status_running, _tool_status_done state tracking variables.
  3. Remove tool status rendering from _build_card() and _flush_stream().
  4. Remove the _TOOL_STATUS_KEEP_LINES constant.
  5. Remove the _ws_on_tool_call callback function.

This way the Feishu streaming output only contains the LLM reply text and is never interrupted by tool call status updates.

Impact

  • Only affects the Feishu channel message display.
  • WebSocket (Web Chat) tool call display is unaffected.
  • Trigger daemon tool call logging is unaffected.
  • Image streaming path (_handle_feishu_file) is unaffected (it never used tool status display).

Logs / Screenshots

Relevant code in backend/app/api/feishu.py:

  • _TOOL_STATUS_KEEP_LINES constant
  • _tool_status_running / _tool_status_done state dicts
  • _ws_on_tool_call callback (the main trigger)
  • _build_card() tool status section rendering
  • _flush_stream() CardKit path tool status concatenation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions