Repository navigation
fix(feishu): prevent duplicate tails with preview and block streaming - #192482
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Built-Gateway proof for #192446Base: Executed in a secretless official Actual pathSigned Feishu The HTTPS fixture uses a task-generated CA certificate trusted only for the proof process. Its Docker bridge address is a real non-reserved address on a task-owned internal network; certificate verification and the shipped SSRF guard remain enabled. There is no production-source bypass, direct dispatcher invocation, manually assembled callback pipeline, or live tenant credential in the final runs. The model fixture sends 48-character SSE deltas at 70ms intervals. Partial streaming and completed blocks are enabled, with 80/180-character paragraph chunking and small coalescing limits to produce multiple real completed blocks. Results, two independent Gateway turns per row and per ref
The exact extra 54 characters on main were a completed suffix already present in the preview: The candidate's final card has that block once, not a suffix-based suppression of arbitrary new text. Inherited limitation, not hidden by the oracle: the aggressive block configuration causes multiple CardKit close/reopen cycles on both refs (13 for the long answer and four for the repeated-paragraph input). This PR fixes the extra tail within the completed card; it does not claim that the entire turn has only one card. The repeated-paragraph run also exposes inherited ordering: its canonical card places the tail between the two full paragraph copies, identically on main and head. The control proves no repeated paragraph was lost, not that this unrelated ordering is correct. No native Feishu client rendering or authenticated tenant behavior is claimed. Supporting regressionsThe same table retains corrected snapshots, private reasoning removal, independent additive blocks, repeated covered blocks and block-only repeated blocks. Changed-file Oxfmt and Oxlint pass. Test delta is -1, production delta +17, with no ratchet allocation. Two earlier local approaches passed the smaller tests but did not fix the real Gateway path. A proof-only observational module-load hook on the earlier candidate logged the real assembly inputs and established that paragraph blocks retain separators while sentence chunks can omit them. That diagnostic hook is outside the PR, was not used in either final baseline or candidate matrix, and does not supply or alter any accepted proof result. The final correction first matches exact bytes at the consumed offset, then skips only an unmatched whitespace gap; it never searches suffixes. All Gateway, model fixture and Feishu fixture processes shut down after their runs. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesThe Feishu dispatcher consumes completed blocks already represented in cumulative previews while preserving independent and genuinely repeated blocks. Example: A preview contains "First.\n\nLast." and completed blocks arrive as "First." then "\n\nLast.".
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR provides a focused repair for duplicate Feishu streaming tails still present on current main; no actionable introduced defects were found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Feishu reply dispatcher receives assistant previews and completed blocks from core, assembles visible text, and sends updates and final content through the CardKit transport. flowchart LR
A[Agent stream] --> B[Core preview and block pipeline]
B --> C[Feishu reply dispatcher]
C --> D[Ordered preview cursor]
D --> E[Streaming card session]
E --> F[CardKit HTTP requests]
Technical reviewBest possible solution: Keep ordered preview consumption in the existing Feishu dispatcher, preserving additive fallback text and assistant-message boundaries. Do we have a high-confidence way to reproduce the issue? Current-main source shows the duplicate-tail path, and the supplied paired Gateway receipt reproduces it through the real transport; this read-only review ran no target code. Is this the best way to solve the issue? The patch is a small owner-local repair: it consumes exact source-ordered contributions, tolerates omitted separator whitespace, and preserves independent blocks without suffix-overlap guessing. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1139abee8063. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +17, Tests -1. Total +16 across 2 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 3, 2026, 9:48 PM ET / November 4, 2026, 02:48 UTC (Revision 2). |
Current-main integration receiptNew exact head: Merged the freshly fetched On this exact merged head, in the retained secretless
The original main-twice/candidate-twice matrix and unchanged controls remain documented in #192482 (comment). Its disclosed inherited card lifecycle and repeated-paragraph ordering limitations are unchanged; this integration does not broaden the claim. All proof processes were shut down after the run. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 6a4638c. Feishu streamed replies no longer repeat their last block. |
…openclaw#192482) fix(feishu): don't repeat the last streamed block in the final card Fixes openclaw#192446. In Feishu streaming, the final card could include the last block twice: once from the cumulative preview and again as an additive block, so replies ended with a duplicated paragraph. The final text now matches each block against the preview: first at the exact cursor, then with whitespace-gap normalization only if the exact match fails. Already-consumed text is not added again, and genuinely repeated paragraphs are kept. Non-streaming and single-block replies are unchanged. Evidence: signed Feishu webhook, built Gateway, the real agent streaming pipeline and an HTTPS CardKit fixture. Main produced 1,784 characters with two copies of the tail, twice; with this change the exact 1,730-character answer with one tail was produced twice, and again after merging current main. Non-streaming, single-block and repeated-paragraph controls were unchanged. Card fanout and reordering behavior is not changed or claimed fixed here. Details: openclaw#192482 (comment) and openclaw#192482 (comment). Co-authored-by: Ayaan Zaidi <[email protected]>
…191585) Feishu core delivers attachment blocks even when text block streaming is disabled. Admit captioned media to the existing caption and native attachment delivery path instead of returning before either send. The 89 additional regression-test lines exercise the real dispatcher queue, caption sender and image uploader through a mocked Feishu SDK client in preview modes off and partial, without an injected final reply or production test seams. Co-authored-by: forrystudio <[email protected]> (cherry picked from commit 569ca48) Release adaptation: inline the existing public-SDK runtime fixture because reply-dispatcher.test-support.ts is absent on this release baseline. Keep real dispatcher, caption sender, media classifier and uploader coverage. Companion audit: later #192469 (monotonic retry window) and #192482 (preview tail deduplication) do not affect captioned non-streaming admission; not applicable to this fix. #197656 removes obsolete allocation records; retain the allocation for this release's existing ratchet. No PR-number follow-ups found through 7bccde6. Existing dispatcher producers, senders and reply-runtime exports are present-equivalent; no storage changes. Proof: git diff --check passed. Focused Vitest/typecheck/lint unavailable: this isolated worktree has no node_modules; no dependencies were installed. Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]> (cherry picked from commit 52e15d4e681397a7b596b5252688376a9979897d)
…openclaw#192482) fix(feishu): don't repeat the last streamed block in the final card Fixes openclaw#192446. In Feishu streaming, the final card could include the last block twice: once from the cumulative preview and again as an additive block, so replies ended with a duplicated paragraph. The final text now matches each block against the preview: first at the exact cursor, then with whitespace-gap normalization only if the exact match fails. Already-consumed text is not added again, and genuinely repeated paragraphs are kept. Non-streaming and single-block replies are unchanged. Evidence: signed Feishu webhook, built Gateway, the real agent streaming pipeline and an HTTPS CardKit fixture. Main produced 1,784 characters with two copies of the tail, twice; with this change the exact 1,730-character answer with one tail was produced twice, and again after merging current main. Non-streaming, single-block and repeated-paragraph controls were unchanged. Card fanout and reordering behavior is not changed or claimed fixed here. Details: openclaw#192482 (comment) and openclaw#192482 (comment). Co-authored-by: Ayaan Zaidi <[email protected]> Source: 6a4638c Release adaptation: Full source change cherry-picked (-x no-commit), preserving preview consumed-prefix order and block-only repeated paragraphs. Baseline double-counted cumulative preview plus blocks; outbound-media followup unrelated. Formatting passed. Focused vitest bounded at 20s ended without test verdict during setup; shared dependency/compiler limitations remain. No schema change. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit f9ea7d1b9065b82e51db7bced54b700194cfd166)
Fixes #192446
What Problem This Solves
Fixes: Feishu's completed streaming card repeats its last block when cumulative previews and completed-block streaming are enabled together. Reported by @MarMarLabs.
User Impact
User impact: the completed card retains the answer once instead of appending the already-previewed tail again. No configuration, public API, or persistence changes are required.
Why This Change Was Made
The dispatcher now consumes completed blocks against the latest preview in source order, within the existing assistant-message boundary. It tries an exact match at the consumed offset first, then allows separator whitespace omitted by sentence chunking. Independent blocks still append, and a genuinely repeated block beyond the consumed preview remains visible. It never guesses from suffix overlap.
The retained preview and consumed offset survive CardKit closeout but reset at the assistant-message boundary. This removes delta-text equality suppression without adding a second assembler or a global normalizer. Production +17 lines; tests -1 line against the merge base, with no test-line allocation.
Evidence
Original paired transport receipt · current merged-head validation.
Merge danger: two-way door; reverting fully restores prior behavior, with no migration or stored-state change. Blast radius is Feishu's streaming text assembly, especially the opt-in combination of partial previews and completed blocks.