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

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
爱范儿
爱范儿
WordPress大学
WordPress大学
博客园 - 三生石上(FineUI控件)
J
Java Code Geeks
Vercel News
Vercel News
aimingoo的专栏
aimingoo的专栏
T
Tailwind CSS Blog
罗磊的独立博客
B
Blog
博客园_首页
A
About on SuperTechFans
有赞技术团队
有赞技术团队
V
V2EX
U
Unit 42
I
InfoQ
IT之家
IT之家
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
博客园 - 叶小钗
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
The Cloudflare Blog
H
Help Net Security

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: add placeholder transcript for silent voice notes (#...
eulicesl · 2026-04-26 · via Recent Commits to openclaw:main

@@ -459,8 +459,7 @@ describe("applyMediaUnderstanding", () => {

459459

expect(ctx.Body).toBe("[Audio]\nTranscript:\nwhatsapp transcript");

460460

});

461461462-

it("skips URL-only audio when remote file is too small", async () => {

463-

// Override the default mock to return a tiny buffer (below MIN_AUDIO_FILE_BYTES)

462+

it("injects a placeholder transcript when URL-only audio is too small", async () => {

464463

mockedFetchRemoteMedia.mockResolvedValueOnce({

465464

buffer: Buffer.alloc(100),

466465

contentType: "audio/ogg",

@@ -499,7 +498,66 @@ describe("applyMediaUnderstanding", () => {

499498

});

500499501500

expect(transcribeAudio).not.toHaveBeenCalled();

502-

expect(result.appliedAudio).toBe(false);

501+

expect(result.appliedAudio).toBe(true);

502+

expect(result.outputs).toEqual([

503+

expect.objectContaining({

504+

kind: "audio.transcription",

505+

text: "[Voice note could not be transcribed because the audio attachment was too small]",

506+

provider: "openclaw",

507+

model: "synthetic-empty-audio",

508+

}),

509+

]);

510+

expect(ctx.Transcript).toBe(

511+

"[Voice note could not be transcribed because the audio attachment was too small]",

512+

);

513+

expect(ctx.Body).toBe(

514+

"[Audio]\nTranscript:\n[Voice note could not be transcribed because the audio attachment was too small]",

515+

);

516+

});

517+518+

it("injects a placeholder transcript when local-path audio is too small", async () => {

519+

const ctx = await createAudioCtx({

520+

fileName: "tiny.ogg",

521+

mediaType: "audio/ogg",

522+

content: Buffer.alloc(100),

523+

});

524+

const transcribeAudio = vi.fn(async () => ({ text: "should-not-run" }));

525+

const cfg: OpenClawConfig = {

526+

tools: {

527+

media: {

528+

audio: {

529+

enabled: true,

530+

maxBytes: 1024 * 1024,

531+

models: [{ provider: "groq" }],

532+

},

533+

},

534+

},

535+

};

536+537+

const result = await applyMediaUnderstanding({

538+

ctx,

539+

cfg,

540+

providers: {

541+

groq: { id: "groq", transcribeAudio },

542+

},

543+

});

544+545+

expect(transcribeAudio).not.toHaveBeenCalled();

546+

expect(result.appliedAudio).toBe(true);

547+

expect(result.outputs).toEqual([

548+

expect.objectContaining({

549+

kind: "audio.transcription",

550+

text: "[Voice note could not be transcribed because the audio attachment was too small]",

551+

provider: "openclaw",

552+

model: "synthetic-empty-audio",

553+

}),

554+

]);

555+

expect(ctx.Transcript).toBe(

556+

"[Voice note could not be transcribed because the audio attachment was too small]",

557+

);

558+

expect(ctx.Body).toBe(

559+

"[Audio]\nTranscript:\n[Voice note could not be transcribed because the audio attachment was too small]",

560+

);

503561

});

504562505563

it("skips audio transcription when attachment exceeds maxBytes", async () => {

@@ -969,6 +1027,56 @@ describe("applyMediaUnderstanding", () => {

9691027

);

9701028

});

97110291030+

it("adds placeholder for tooSmall audio while preserving real transcript for valid audio", async () => {

1031+

const dir = await createTempMediaDir();

1032+

const validAudio = createSafeAudioFixtureBuffer(2048);

1033+

const tinyAudio = Buffer.alloc(100);

1034+

const validPath = path.join(dir, "valid.ogg");

1035+

const tinyPath = path.join(dir, "tiny.ogg");

1036+

await fs.writeFile(validPath, validAudio);

1037+

await fs.writeFile(tinyPath, tinyAudio);

1038+1039+

const ctx: MsgContext = {

1040+

Body: "<media:audio>",

1041+

MediaPaths: [validPath, tinyPath],

1042+

MediaTypes: ["audio/ogg", "audio/ogg"],

1043+

};

1044+

const cfg: OpenClawConfig = {

1045+

tools: {

1046+

media: {

1047+

audio: {

1048+

enabled: true,

1049+

attachments: { mode: "all", maxAttachments: 2 },

1050+

models: [{ provider: "groq" }],

1051+

},

1052+

},

1053+

},

1054+

};

1055+1056+

const result = await applyMediaUnderstanding({

1057+

ctx,

1058+

cfg,

1059+

providers: {

1060+

groq: {

1061+

id: "groq",

1062+

transcribeAudio: async (req) => ({ text: `transcribed ${req.fileName ?? "unknown"}` }),

1063+

},

1064+

},

1065+

});

1066+1067+

expect(result.appliedAudio).toBe(true);

1068+

expect(ctx.Transcript).toContain("transcribed valid.ogg");

1069+

expect(ctx.Transcript).toContain(

1070+

"[Voice note could not be transcribed because the audio attachment was too small]",

1071+

);

1072+

expect(ctx.Body).toContain("[Audio 1/2]");

1073+

expect(ctx.Body).toContain("transcribed valid.ogg");

1074+

expect(ctx.Body).toContain("[Audio 2/2]");

1075+

expect(ctx.Body).toContain(

1076+

"[Voice note could not be transcribed because the audio attachment was too small]",

1077+

);

1078+

});

1079+9721080

it("orders mixed media outputs as image, audio, video", async () => {

9731081

const dir = await createTempMediaDir();

9741082

const imagePath = path.join(dir, "photo.jpg");

@@ -1028,6 +1136,68 @@ describe("applyMediaUnderstanding", () => {

10281136

expect(ctx.BodyForCommands).toBe("audio ok");

10291137

});

103011381139+

it("orders synthetic too-small audio output between image and video", async () => {

1140+

const dir = await createTempMediaDir();

1141+

const imagePath = path.join(dir, "photo.jpg");

1142+

const audioPath = path.join(dir, "silent.ogg");

1143+

const videoPath = path.join(dir, "clip.mp4");

1144+

await fs.writeFile(imagePath, "image-bytes");

1145+

await fs.writeFile(audioPath, Buffer.alloc(100));

1146+

await fs.writeFile(videoPath, "video-bytes");

1147+1148+

const ctx: MsgContext = {

1149+

Body: "<media:mixed>",

1150+

MediaPaths: [imagePath, audioPath, videoPath],

1151+

MediaTypes: ["image/jpeg", "audio/ogg", "video/mp4"],

1152+

};

1153+

const cfg: OpenClawConfig = {

1154+

tools: {

1155+

media: {

1156+

image: { enabled: true, models: [{ provider: "openai", model: "gpt-5.4" }] },

1157+

audio: { enabled: true, models: [{ provider: "groq" }] },

1158+

video: { enabled: true, models: [{ provider: "google", model: "gemini-3" }] },

1159+

},

1160+

},

1161+

};

1162+1163+

const result = await applyMediaUnderstanding({

1164+

ctx,

1165+

cfg,

1166+

agentDir: dir,

1167+

providers: {

1168+

openai: {

1169+

id: "openai",

1170+

describeImage: async () => ({ text: "image ok" }),

1171+

},

1172+

groq: {

1173+

id: "groq",

1174+

transcribeAudio: async () => ({ text: "audio should not run" }),

1175+

},

1176+

google: {

1177+

id: "google",

1178+

describeVideo: async () => ({ text: "video ok" }),

1179+

},

1180+

},

1181+

});

1182+1183+

const placeholder =

1184+

"[Voice note could not be transcribed because the audio attachment was too small]";

1185+1186+

expect(result.appliedImage).toBe(true);

1187+

expect(result.appliedAudio).toBe(true);

1188+

expect(result.appliedVideo).toBe(true);

1189+

expect(ctx.Body).toBe(

1190+

[

1191+

"[Image]\nDescription:\nimage ok",

1192+

`[Audio]\nTranscript:\n${placeholder}`,

1193+

"[Video]\nDescription:\nvideo ok",

1194+

].join("\n\n"),

1195+

);

1196+

expect(ctx.Transcript).toBe(placeholder);

1197+

expect(ctx.CommandBody).toBe(placeholder);

1198+

expect(ctx.BodyForCommands).toBe(placeholder);

1199+

});

1200+10311201

it("treats text-like attachments as CSV (comma wins over tabs)", async () => {

10321202

const csvText = '"a","b"\t"c"\n"1","2"\t"3"';

10331203

const csvPath = await createTempMediaFile({