-
-
Notifications
You must be signed in to change notification settings - Fork 79.1k
Bug: Text before tool calls is lost in Feishu streaming card reply mode #84486
Copy link
Copy link
Open
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.Channel message delivery can be lost, duplicated, or misrouted.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.Channel message delivery can be lost, duplicated, or misrouted.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Bug: Text before tool calls is lost in Feishu streaming card reply mode
Summary
When the model outputs text before invoking a tool call (stopReason=toolUse), the pre-tool text is silently discarded in Feishu streaming card reply mode. Only the final assistant reply (stopReason=stop) is visible to the user. This results in missing content in Feishu messages.
Environment
streaming(default for Feishu p2p)Steps to Reproduce
stopReason=toolUseto invoke a toolstopReason=stopExpected Behavior
All text produced by the model across the entire turn (including text before tool calls) should be accumulated and delivered together in the final reply, or the streaming card should preserve previously rendered content when a new model invocation starts within the same turn.
Actual Behavior
The pre-tool text is rendered into the Feishu streaming card during the first model invocation. When the model stops with
toolUseand a new invocation begins, the streaming card is overwritten with the new invocation content, discarding the previously rendered text. Only the post-tool text remains visible.Root Cause Analysis
Two independent dispatch systems
OpenClaw has two reply dispatch systems:
dispatch-acp): Used for ACP sessions/subagents. Controlled byacp.stream.deliveryModeconfig ("live"|"final_only").replyMode=streamingwith Feishu interactive cards. Not controlled byacp.stream.deliveryMode.Why
acp.stream.deliveryMode=livedoes not fix thisSetting
acp.stream.deliveryModeto"live"only affects the ACP dispatch path. Feishu messages go through the Feishu card reply dispatcher, which is a completely separate system. Theacp.stream.deliveryModeconfig has no effect on Feishu streaming card behavior.Evidence from gateway logs
Every Feishu message shows:
This confirms Feishu uses
replyMode=streaming, not ACP dispatch.Evidence from session history
Session history shows two assistant messages in a single turn:
toolUsestopOnly seq 155 content was visible in the Feishu card. Seq 153 text was rendered into the streaming card but then overwritten when the new model invocation started.
The overwrite mechanism
The Feishu streaming card reply dispatcher updates a single interactive card in-place as the model streams text. When the model stops with
toolUseand a new invocation begins within the same turn, the dispatcher starts updating the same card with the new invocation output, replacing the previous content instead of appending to it.Previously Incorrect Analysis
The initial version of this issue incorrectly attributed the bug to ACP dispatch
final_onlymode andresetTurnState()clearingfinalOnlyOutputText. While that mechanism exists, it is not the cause for Feishu because Feishu does not use ACP dispatch for message delivery. The actual cause is the Feishu streaming card reply dispatcher overwriting previously rendered content when a new model invocation starts.Suggested Fix
The Feishu streaming card reply dispatcher should preserve previously rendered content across model invocations within the same turn. Options:
final_onlymode, buffer all text across invocations and only render the complete card when the turn finishes (stopReason=stop).Workarounds
Impact
Any scenario where the model outputs explanatory text before invoking a tool will lose that text in Feishu. This includes: