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

推荐订阅源

D
DataBreaches.Net
F
Fortinet All Blogs
D
Docker
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
罗磊的独立博客
Y
Y Combinator Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
J
Java Code Geeks
T
The Blog of Author Tim Ferriss
U
Unit 42
N
Netflix TechBlog - Medium
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
云风的 BLOG
云风的 BLOG
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
Stack Overflow Blog
Stack Overflow Blog
爱范儿
爱范儿
酷 壳 – CoolShell
酷 壳 – CoolShell
P
Proofpoint News Feed
G
Google Developers 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(google): prevent empty contents error for gemini (#74...
CaoYuhaoCarl · 2026-04-30 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -23,6 +23,7 @@ Docs: https://docs.openclaw.ai

2323

### Fixes

2424
2525

- Exec: reject invalid per-call `host` values instead of silently falling back to the default target, so hostname-like values fail before commands run. Fixes #74426. Thanks @scr00ge-00 and @vyctorbrzezowski.

26+

- Google/Gemini: send non-empty placeholder content when a Gemini run is triggered with empty or filtered user content, avoiding `contents is not specified` API errors. Thanks @CaoYuhaoCarl.

2627

- Build/Gateway: route restart, shutdown, respawn, diagnostics, command-queue cleanup, and runtime cleanup through one stable gateway lifecycle runtime entry so rebuilt packages do not strand long-running gateways on stale hashed chunks. Carries forward #73964. Thanks @pashpashpash.

2728

- Memory/wiki: keep broad shared-source and generated related-link blocks from turning every page into a search hit, cap noisy backlinks, support all-term searches such as people-routing queries, and prefer readable page body snippets over generated metadata. Thanks @vincentkoc.

2829

- Cron/Gateway: abort and bounded-clean up timed-out isolated agent turns before recording the timeout, so stale cron sessions cannot leave Discord or other chat lanes stuck in `processing` after a timeout. Thanks @vincentkoc.

Original file line numberDiff line numberDiff line change

@@ -514,4 +514,54 @@ describe("google transport stream", () => {

514514
515515

expect(params.cachedContent).toBe("cachedContents/prebuilt-context");

516516

});

517+
518+

it("uses a non-empty text placeholder for empty user text", () => {

519+

const params = buildGoogleGenerativeAiParams(buildGeminiModel(), {

520+

messages: [

521+

{ role: "user", content: "", timestamp: 0 },

522+

{

523+

role: "user",

524+

content: [{ type: "text", text: "" }],

525+

timestamp: 1,

526+

},

527+

],

528+

} as never);

529+
530+

expect(params.contents).toEqual([

531+

{ role: "user", parts: [{ text: " " }] },

532+

{ role: "user", parts: [{ text: " " }] },

533+

]);

534+

});

535+
536+

it("uses a text placeholder when user parts are filtered out for text-only models", () => {

537+

const params = buildGoogleGenerativeAiParams(buildGeminiModel({ input: ["text"] }), {

538+

messages: [

539+

{

540+

role: "user",

541+

content: [{ type: "image", mimeType: "image/png", data: "png-bytes" }],

542+

timestamp: 0,

543+

},

544+

],

545+

} as never);

546+
547+

expect(params.contents).toEqual([{ role: "user", parts: [{ text: " " }] }]);

548+

});

549+
550+

it("uses a user placeholder when converted Gemini contents would otherwise be empty", () => {

551+

const params = buildGoogleGenerativeAiParams(buildGeminiModel(), {

552+

messages: [

553+

{

554+

role: "assistant",

555+

provider: "google",

556+

api: "google-generative-ai",

557+

model: "gemini-2.5-pro",

558+

stopReason: "stop",

559+

timestamp: 0,

560+

content: [{ type: "text", text: " " }],

561+

},

562+

],

563+

} as never);

564+
565+

expect(params.contents).toEqual([{ role: "user", parts: [{ text: " " }] }]);

566+

});

517567

});

Original file line numberDiff line numberDiff line change

@@ -315,14 +315,14 @@ function convertGoogleMessages(model: GoogleTransportModel, context: Context) {

315315

if (typeof msg.content === "string") {

316316

contents.push({

317317

role: "user",

318-

parts: [{ text: sanitizeTransportPayloadText(msg.content) }],

318+

parts: [{ text: sanitizeTransportPayloadText(msg.content) || " " }],

319319

});

320320

continue;

321321

}

322322

const parts = msg.content

323323

.map((item) =>

324324

item.type === "text"

325-

? { text: sanitizeTransportPayloadText(item.text) }

325+

? { text: sanitizeTransportPayloadText(item.text) || " " }

326326

: {

327327

inlineData: {

328328

mimeType: item.mimeType,

@@ -331,9 +331,10 @@ function convertGoogleMessages(model: GoogleTransportModel, context: Context) {

331331

},

332332

)

333333

.filter((item) => model.input.includes("image") || !("inlineData" in item));

334-

if (parts.length > 0) {

335-

contents.push({ role: "user", parts });

334+

if (parts.length === 0) {

335+

parts.push({ text: " " });

336336

}

337+

contents.push({ role: "user", parts });

337338

continue;

338339

}

339340

@@ -437,6 +438,9 @@ function convertGoogleMessages(model: GoogleTransportModel, context: Context) {

437438

}

438439

}

439440

}

441+

if (contents.length === 0) {

442+

contents.push({ role: "user", parts: [{ text: " " }] });

443+

}

440444

return contents;

441445

}

442446