Skip to content

Commit 03e35b1

Browse files
committed
fix(feishu): honor block streaming config
1 parent f74e901 commit 03e35b1

7 files changed

Lines changed: 78 additions & 6 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Docs: https://docs.openclaw.ai
2929

3030
### Fixes
3131

32+
- Feishu: accept and honor `channels.feishu.blockStreaming` at the top level and per account, while keeping the legacy default off so Feishu cards no longer reject documented config or silently drop block replies. Fixes #75555. Thanks @vincentkoc.
3233
- Google Chat: normalize custom Google auth transport headers before google-auth/gaxios interceptors run, restoring webhook token verification when certificate retrieval expects Fetch `Headers`. Fixes #76742. Thanks @donbowman.
3334
- Doctor/plugins: reset stale `plugins.slots.memory` and `plugins.slots.contextEngine` references during `doctor --fix`, so cleanup of missing plugin config does not leave unrecoverable slot owners behind. Fixes #76550 and #76551. Thanks @vincentkoc.
3435
- Docs/WhatsApp: merge the duplicate top-level `web` objects in the gateway channel config example so copy-pasted WhatsApp config keeps both `web.whatsapp` and reconnect settings. Fixes #76619. Thanks @WadydX.

‎docs/channels/feishu.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,13 @@ Feishu/Lark supports streaming replies via interactive cards. When enabled, the
273273
channels: {
274274
feishu: {
275275
streaming: true, // enable streaming card output (default: true)
276-
blockStreaming: true, // enable block-level streaming (default: true)
276+
blockStreaming: true, // opt into completed-block streaming
277277
},
278278
},
279279
}
280280
```
281281

282-
Set `streaming: false` to send the complete reply in one message.
282+
Set `streaming: false` to send the complete reply in one message. `blockStreaming` is off by default; enable it only when you want completed assistant blocks flushed before the final reply.
283283

284284
### Quota optimization
285285

@@ -428,7 +428,7 @@ Full configuration: [Gateway configuration](/gateway/configuration)
428428
| `channels.feishu.textChunkLimit` | Message chunk size | `2000` |
429429
| `channels.feishu.mediaMaxMb` | Media size limit | `30` |
430430
| `channels.feishu.streaming` | Streaming card output | `true` |
431-
| `channels.feishu.blockStreaming` | Block-level streaming | `true` |
431+
| `channels.feishu.blockStreaming` | Completed-block reply streaming | `false` |
432432
| `channels.feishu.typingIndicator` | Send typing reactions | `true` |
433433
| `channels.feishu.resolveSenderNames` | Resolve sender display names | `true` |
434434

‎extensions/feishu/openclaw.plugin.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
"enum": ["auto", "raw", "card"]
127127
},
128128
"streaming": { "type": "boolean" },
129+
"blockStreaming": { "type": "boolean" },
129130
"replyInThread": {
130131
"type": "string",
131132
"enum": ["disabled", "enabled"]
@@ -162,6 +163,7 @@
162163
"enum": ["auto", "raw", "card"]
163164
},
164165
"streaming": { "type": "boolean" },
166+
"blockStreaming": { "type": "boolean" },
165167
"replyInThread": {
166168
"type": "string",
167169
"enum": ["disabled", "enabled"]

‎extensions/feishu/src/config-schema.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,20 @@ describe("FeishuConfigSchema optimization flags", () => {
206206
expect(result.resolveSenderNames).toBe(true);
207207
});
208208

209+
it("accepts top-level and account-level block streaming", () => {
210+
const result = FeishuConfigSchema.parse({
211+
blockStreaming: true,
212+
accounts: {
213+
main: {
214+
blockStreaming: false,
215+
},
216+
},
217+
});
218+
219+
expect(result.blockStreaming).toBe(true);
220+
expect(result.accounts?.main?.blockStreaming).toBe(false);
221+
});
222+
209223
it("accepts account-level optimization flags", () => {
210224
const result = FeishuConfigSchema.parse({
211225
accounts: {

‎extensions/feishu/src/config-schema.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ const RenderModeSchema = z.enum(["auto", "raw", "card"]).optional();
6868
// Streaming card mode: when enabled, card replies use Feishu's Card Kit streaming API
6969
// for incremental text display with a "Thinking..." placeholder
7070
const StreamingModeSchema = z.boolean().optional();
71+
const BlockStreamingSchema = z.boolean().optional();
7172

7273
const BlockStreamingCoalesceSchema = z
7374
.object({
@@ -188,6 +189,7 @@ const FeishuSharedConfigShape = {
188189
dms: z.record(z.string(), DmConfigSchema).optional(),
189190
textChunkLimit: z.number().int().positive().optional(),
190191
chunkMode: z.enum(["length", "newline"]).optional(),
192+
blockStreaming: BlockStreamingSchema,
191193
blockStreamingCoalesce: BlockStreamingCoalesceSchema,
192194
mediaMaxMb: z.number().positive().optional(),
193195
httpTimeoutMs: z.number().int().positive().max(300_000).optional(),

‎extensions/feishu/src/reply-dispatcher.test.ts‎

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,55 @@ describe("createFeishuReplyDispatcher streaming behavior", () => {
286286
expect(sendMediaFeishuMock).not.toHaveBeenCalled();
287287
});
288288

289-
it("sets disableBlockStreaming in replyOptions to prevent silent reply drops", async () => {
289+
it("disables block streaming by default to prevent silent reply drops", async () => {
290+
const result = createFeishuReplyDispatcher({
291+
cfg: {} as never,
292+
agentId: "agent",
293+
runtime: {} as never,
294+
chatId: "oc_chat",
295+
});
296+
297+
expect(result.replyOptions).toHaveProperty("disableBlockStreaming", true);
298+
});
299+
300+
it("enables core block streaming when Feishu blockStreaming is explicitly true", async () => {
301+
resolveFeishuAccountMock.mockReturnValue({
302+
accountId: "main",
303+
appId: "app_id",
304+
appSecret: "app_secret",
305+
domain: "feishu",
306+
config: {
307+
renderMode: "auto",
308+
streaming: true,
309+
blockStreaming: true,
310+
},
311+
});
312+
313+
const { result, options } = createDispatcherHarness();
314+
expect(result.replyOptions).toHaveProperty("disableBlockStreaming", false);
315+
316+
await options.deliver({ text: "plain block" }, { kind: "block" });
317+
await options.onIdle?.();
318+
319+
expect(streamingInstances).toHaveLength(1);
320+
expect(streamingInstances[0].close).toHaveBeenCalledWith("plain block", {
321+
note: "Agent: agent",
322+
});
323+
});
324+
325+
it("keeps core block streaming disabled when Feishu blockStreaming is explicitly false", async () => {
326+
resolveFeishuAccountMock.mockReturnValue({
327+
accountId: "main",
328+
appId: "app_id",
329+
appSecret: "app_secret",
330+
domain: "feishu",
331+
config: {
332+
renderMode: "auto",
333+
streaming: true,
334+
blockStreaming: false,
335+
},
336+
});
337+
290338
const result = createFeishuReplyDispatcher({
291339
cfg: {} as never,
292340
agentId: "agent",

‎extensions/feishu/src/reply-dispatcher.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ export function createFeishuReplyDispatcher(params: CreateFeishuReplyDispatcherP
222222
const tableMode = core.channel.text.resolveMarkdownTableMode({ cfg, channel: "feishu" });
223223
const renderMode = account.config?.renderMode ?? "auto";
224224
const streamingEnabled = account.config?.streaming !== false && renderMode !== "raw";
225+
const coreBlockStreamingEnabled = account.config?.blockStreaming === true;
225226
const reasoningPreviewEnabled = streamingEnabled && params.allowReasoningPreview === true;
226227

227228
let streaming: FeishuStreamingSession | null = null;
@@ -530,7 +531,10 @@ export function createFeishuReplyDispatcher(params: CreateFeishuReplyDispatcherP
530531
}),
531532
);
532533
const useCard =
533-
hasText && (renderMode === "card" || (renderMode === "auto" && shouldUseCard(text)));
534+
hasText &&
535+
(renderMode === "card" ||
536+
(info?.kind === "block" && coreBlockStreamingEnabled && renderMode !== "raw") ||
537+
(renderMode === "auto" && shouldUseCard(text)));
534538
const skipTextForDuplicateFinal =
535539
info?.kind === "final" && hasText && deliveredFinalTexts.has(text);
536540
const skipTextForClosedStreamingFinal =
@@ -660,7 +664,8 @@ export function createFeishuReplyDispatcher(params: CreateFeishuReplyDispatcherP
660664
replyOptions: {
661665
...replyOptions,
662666
onModelSelected: prefixContext.onModelSelected,
663-
disableBlockStreaming: true,
667+
disableBlockStreaming:
668+
typeof account.config?.blockStreaming === "boolean" ? !account.config.blockStreaming : true,
664669
onPartialReply: streamingEnabled
665670
? (payload: ReplyPayload) => {
666671
if (!payload.text) {

0 commit comments

Comments
 (0)