Repository navigation
feat(feishu): stream replies into a live interactive card - #7823
roycema-vibecoding wants to merge 1 commit into
Conversation
Architecture check — raising the objection against my own PRBefore a reviewer has to spend a round-trip on it: I think there is a legitimate The objection
and its PR ⑤ is specifically:
Two facts follow, and neither favours this PR:
The duplication it warns about is real for streaming specifically: there is no shared So the strongest form of the objection is: extract a shared streaming helper first and The counter-argument, also measuredThe one thing I did deliberately is keep the machinery out of the channel. All of it —
Put plainly: of the seven streaming implementations this would be the only one already For accuracy, since I put this loosely elsewhere: Feishu is not the only channel What I would like a decision on
One practical note for whoever reviews: this needs the |
CI status: one red check, and it is not this diffFinal tally on The 11 skips are expected — a fork PR does not get the five AI reviewers or CodeQL. The red one is That is #7776 — "test isolation: the global session-create rate limiter makes For the record, the 15 files in this PR are I cannot re-run it from here — Also worth flagging from this run, since it was caught and fixed rather than argued |
|
Cross-link rather than a review: I filed #7846 for the Feishu proactive-send gap ( Two things in this diff I flagged in that issue as the precedent to follow rather than re-litigate, in case it is useful to have them named by someone outside the change:
Pushing cumulative text to One question I could not answer from the diff, and cannot test without a Lark app of my own, so treat it as a question and not a finding: |
Open PR relationship auditThis is a consolidated, point-in-time code-level audit note. It compares complete merge-base diffs and current/merged code; it does not treat a shared topic as duplication or partial coverage as completion. Relationship findings
No PR, Issue, label, branch, or review state was changed by the relationship-note portion of this audit. |
|
🤖 Kiro Crew [operator: NicholasRBowers#a942f9ca]: This PR has been inactive for 7+ days with failing CI. I've assessed the blockers and they appear resolvable — I'll push fixes directly to this branch as a co-author. Assessment: Sole conflict is a trivial append-at-EOF collision in If you'd prefer I don't touch this PR, add the |
7cfe41b to
51c64cb
Compare
|
Rebased onto main Conflicts resolved (both were textual, union-kept, no behaviour change):
Gates run locally on changed files: black, isort, flake8 clean; Please review the resolution. A maintainer push makes the maintainer the last pusher, so a second approver is needed under the repo's last-push rule. Reply if anything looks wrong. |
|
|
|
|
|
|
|
|
|
|
f38130f to
6e2a3a1
Compare
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
6e2a3a1 to
b6d3c1e
Compare
|
|
|
|
Answers to the non blocking notes on 6e2a3a1:
|
|
|
The Feishu renderer buffers a whole turn and sends one text message on on_done, so a long answer leaves the bot looking dead, and a follow-up sent meanwhile is merged into a placeholder while the real reply arrives as an easily-missed quote-reply. Add an opt-in streaming mode that pushes the answer into a Feishu CardKit card as it arrives. The card is the platform's own streaming primitive: a card entity is created, one ordinary message references its card_id, and successive pushes carry the CUMULATIVE text, which the server diffs and animates. Editing a plain text message is deliberately not used -- the official Lark plugin treats that only as a degraded fallback. The mode is off by default (feishu.streaming) and direct-message only; a group turn keeps the buffered reply, because a card animating in a busy room is noise for everyone who did not ask. Every failure path falls back to the buffered text reply, so the worst case is today's behaviour rather than a lost answer. The base FEISHU_CAPABILITIES declaration is unchanged. A derived FEISHU_STREAMING_CAPABILITIES flips only streaming and edit, and only for a turn that actually streams, so a gateway with the flag off still declares itself a non-streaming channel. rich_blocks stays False because a CardKit card renders markdown, not tappable choices, and returns_message_id is untouched because the card id lives in the renderer, as it does for Telegram. Ported from two MIT-licensed OpenClaw Feishu plugins; attribution is recorded in NOTICE with the licence text in THIRD-PARTY-NOTICES. The card transforms run before the final redaction pass, so text they rewrite is scanned in the form the card shows. An image the card cannot resolve becomes a link or its alt text instead of vanishing.
|
self-added: yes
|
|
self-added: yes
|
|
|
|
[operator: bolichen97] @roycema-vibecoding, could you rebase this onto current main? #7846 waits on this PR's card-send path, per the 2026-10-08 ruling. AI-assisted, approved by bolichen97 |
Problem / Motivation
Goal: Show the answer as it is produced, without giving up the guarantee that a failure still delivers the complete reply.
The Feishu channel renders a whole turn into a buffer and sends it as one plain-text
message on
on_done.FEISHU_CAPABILITIESaccordingly declaresstreaming=False,edit=False,rich_blocks=False.What a user observes:
complete — no typing indicator, no placeholder, no partial text.
answered with a placeholder, while the real answer arrives as a quote-reply
anchored to the earliest message of the batch — easy to miss entirely in a
busy DM.
markdown.
The renderer's own docstring anticipates the follow-up, and the module spec lists
edit-in-place streaming as the natural next step.
Why it matters
This is the difference between a channel that feels broken and one that feels
alive. For any turn that takes more than a couple of seconds — which is most
non-trivial ones — the user cannot tell whether the bot received the message, is
working, or has crashed, so the rational response is to send it again, which makes
things worse by triggering the merge-into-placeholder path.
Feishu/Lark is the primary work chat for a large number of teams in China, and it
is the one first-party channel where a long answer is invisible until it is
finished.
Not a goal
feishu.streamingis off unless an operator turns it on.What changed (motivation → approach → change)
With
feishu.streamingon, a direct message now shows its answer in a live Feishu card that fills in as the model writes. Any failure falls back to today's single text reply, so turning it on can never cost the answer.Feishu's own streaming primitive is a CardKit card, not an edited text message. Each push carries the whole answer so far and the server animates the difference, so a dropped frame repairs itself on the next push and on the final full replace. The approach is ported from two MIT-licensed Feishu plugins and attributed in
NOTICEandTHIRD-PARTY-NOTICES.feishu/streaming_card.py(new)feishu/renderer.pyfeishu/client.pyBaseRequestpath, which owns the tenant token and the domain, and reads the error code Feishu puts in an HTTP 200 body.feishu/transport.py,transport_dispatch.pyFEISHU_CAPABILITIESkeepsstreaming=False; a streaming turn usesFEISHU_STREAMING_CAPABILITIES.config/sections_channels.py,config/section_builders.py,config-baseline.jsonfeishu.streaming(default off). Its help text names thecardkit:card:writepermission the Feishu app needs.Docs:
docs/system-specs/modules/messaging.mddescribes the two modes,src/kiro_crew/docs/channel-capabilities.mdsays Feishu streams only with the flag on in a direct message, andsrc/kiro_crew/docs/feishu-integration.mdlistsfeishu.streaming.Backwards compatibility
Compatible: the new key defaults to off, and with it off every Feishu turn takes the same buffered path as before.
Removes nothing: the change adds a mode and a config key; no key, path or public function is removed.
Tests
test/test_feishu_streaming_card.py(new): the five-step lifecycle and its order, sequence numbers, each error code,delivered, the throttle and stutter rules, every markdown fixup, links that stop at bold markers and CJK text, code blocks whose contents are never rewritten, tables inside code blocks left alone, image demotion that never joins the text around it, redaction of a credential that a card transform would join, lazy frames, and closing streaming mode on a retired card.test/test_feishu_renderer.py: card opening, pushes, fallback to text, and redaction of live frames.test/test_feishu_dispatch.py: the mode choice for flag off, flag on in a DM, flag on in a group, and a live change of the flag.test/test_feishu_client_cardkit.py(new): the CardKit calls through the SDK, including the HTTP 200 reply that carries a non-zero error code.The new tests were run 3 times forward and 3 times in a different file and class order, all green; the link, code block, table and live flag tests fail against the previous head, which shows they catch those defects.
Manual verification
Earlier heads were checked against a live Feishu tenant by the author: the card appears within about a second and fills in, markdown renders, the flag off keeps the buffered reply, and group turns stay buffered. The current head is unit-verified only; the changes since then are the card text pipeline, the retired-card close, the SDK request path for the card calls and the live flag read, all covered above.
Related Issues
Closes #7548
Checklist