惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IT之家
IT之家
Microsoft Azure Blog
Microsoft Azure Blog
人人都是产品经理
人人都是产品经理
博客园 - 聂微东
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
小众软件
小众软件
F
Fortinet All Blogs
Microsoft Security Blog
Microsoft Security Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Google DeepMind News
Google DeepMind News
Jina AI
Jina AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
aimingoo的专栏
aimingoo的专栏
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
宝玉的分享
宝玉的分享
有赞技术团队
有赞技术团队
J
Java Code Geeks
WordPress大学
WordPress大学
The Cloudflare Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(whatsapp): deliver tool replies that include media (#...
adaclaw · 2026-04-25 · via Recent Commits to openclaw:main

@@ -2,6 +2,14 @@ import { describe, expect, it, vi, beforeEach } from "vitest";

2233

let capturedDispatchParams: unknown;

445+

type CapturedReplyPayload = {

6+

text?: string;

7+

isReasoning?: boolean;

8+

isCompactionNotice?: boolean;

9+

mediaUrl?: string;

10+

mediaUrls?: string[];

11+

};

12+513

const { dispatchReplyWithBufferedBlockDispatcherMock } = vi.hoisted(() => ({

614

dispatchReplyWithBufferedBlockDispatcherMock: vi.fn(async (params: { ctx: unknown }) => {

715

capturedDispatchParams = params;

@@ -36,10 +44,20 @@ vi.mock("./runtime-api.js", () => ({

3644

},

3745

resolveInboundLastRouteSessionKey: (params: { sessionKey: string }) => params.sessionKey,

3846

resolveMarkdownTableMode: () => undefined,

39-

resolveSendableOutboundReplyParts: (payload: { text?: string }) => ({

40-

text: payload.text ?? "",

41-

hasMedia: false,

42-

}),

47+

resolveSendableOutboundReplyParts: (payload: {

48+

text?: string;

49+

mediaUrls?: string[];

50+

mediaUrl?: string;

51+

}) => {

52+

const urls = [

53+

...(Array.isArray(payload.mediaUrls) ? payload.mediaUrls : []),

54+

...(payload.mediaUrl ? [payload.mediaUrl] : []),

55+

];

56+

return {

57+

text: payload.text ?? "",

58+

hasMedia: urls.length > 0,

59+

};

60+

},

4361

resolveTextChunkLimit: () => 4000,

4462

shouldLogVerbose: () => false,

4563

toLocationContext: () => ({}),

@@ -91,7 +109,7 @@ function getCapturedDeliver() {

91109

capturedDispatchParams as {

92110

dispatcherOptions?: {

93111

deliver?: (

94-

payload: { text?: string; isReasoning?: boolean; isCompactionNotice?: boolean },

112+

payload: CapturedReplyPayload,

95113

info: { kind: "tool" | "block" | "final" },

96114

) => Promise<void>;

97115

};

@@ -360,7 +378,7 @@ describe("whatsapp inbound dispatch", () => {

360378

expect(groupHistories.get("whatsapp:default:group:123@g.us") ?? []).toHaveLength(0);

361379

});

362380363-

it("delivers block and final WhatsApp payloads, but suppresses tool payloads", async () => {

381+

it("delivers block and final WhatsApp payloads; suppresses text-only tool payloads but delivers tool media", async () => {

364382

const deliverReply = vi.fn(async () => undefined);

365383

const rememberSentText = vi.fn();

366384

@@ -376,10 +394,27 @@ describe("whatsapp inbound dispatch", () => {

376394

expect(deliverReply).not.toHaveBeenCalled();

377395

expect(rememberSentText).not.toHaveBeenCalled();

378396397+

await deliver?.(

398+

{ text: "tool image", mediaUrls: ["/tmp/generated.jpg"] },

399+

{

400+

kind: "tool",

401+

},

402+

);

403+

expect(deliverReply).toHaveBeenCalledTimes(1);

404+

expect(rememberSentText).toHaveBeenCalledTimes(1);

405+

expect(deliverReply).toHaveBeenLastCalledWith(

406+

expect.objectContaining({

407+

replyResult: expect.objectContaining({

408+

mediaUrls: ["/tmp/generated.jpg"],

409+

text: undefined,

410+

}),

411+

}),

412+

);

413+379414

await deliver?.({ text: "block payload" }, { kind: "block" });

380415

await deliver?.({ text: "final payload" }, { kind: "final" });

381-

expect(deliverReply).toHaveBeenCalledTimes(2);

382-

expect(rememberSentText).toHaveBeenCalledTimes(2);

416+

expect(deliverReply).toHaveBeenCalledTimes(3);

417+

expect(rememberSentText).toHaveBeenCalledTimes(3);

383418

});

384419385420

it("suppresses reasoning and compaction payloads before WhatsApp delivery", async () => {

@@ -473,6 +508,65 @@ describe("whatsapp inbound dispatch", () => {

473508

expect(rememberSentText).toHaveBeenCalledTimes(1);

474509

});

475510511+

it("returns true for tool-only media turns after delivering media", async () => {

512+

const deliverReply = vi.fn(async () => undefined);

513+

const rememberSentText = vi.fn();

514+

dispatchReplyWithBufferedBlockDispatcherMock.mockImplementationOnce(

515+

async (params: {

516+

ctx: unknown;

517+

dispatcherOptions?: {

518+

deliver?: (

519+

payload: CapturedReplyPayload,

520+

info: { kind: "tool" | "block" | "final" },

521+

) => Promise<void>;

522+

};

523+

}) => {

524+

capturedDispatchParams = params;

525+

await params.dispatcherOptions?.deliver?.(

526+

{ text: "tool image", mediaUrls: ["/tmp/generated.jpg"] },

527+

{ kind: "tool" },

528+

);

529+

return { queuedFinal: false, counts: { tool: 1, block: 0, final: 0 } };

530+

},

531+

);

532+533+

await expect(

534+

dispatchWhatsAppBufferedReply({

535+

cfg: { channels: { whatsapp: { blockStreaming: true } } } as never,

536+

connectionId: "conn",

537+

context: { Body: "hi" },

538+

conversationId: "+1000",

539+

deliverReply,

540+

groupHistories: new Map(),

541+

groupHistoryKey: "+1000",

542+

maxMediaBytes: 1,

543+

msg: makeMsg(),

544+

rememberSentText,

545+

replyLogger: {

546+

info: () => {},

547+

warn: () => {},

548+

error: () => {},

549+

debug: () => {},

550+

} as never,

551+

replyPipeline: {},

552+

replyResolver: (async () => undefined) as never,

553+

route: makeRoute(),

554+

shouldClearGroupHistory: false,

555+

}),

556+

).resolves.toBe(true);

557+558+

expect(deliverReply).toHaveBeenCalledTimes(1);

559+

expect(deliverReply).toHaveBeenCalledWith(

560+

expect.objectContaining({

561+

replyResult: expect.objectContaining({

562+

mediaUrls: ["/tmp/generated.jpg"],

563+

text: undefined,

564+

}),

565+

}),

566+

);

567+

expect(rememberSentText).toHaveBeenCalledWith(undefined, expect.any(Object));

568+

});

569+476570

it("passes sendComposing through as the reply typing callback", async () => {

477571

const sendComposing = vi.fn(async () => undefined);

478572