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

推荐订阅源

P
Proofpoint News Feed
V
V2EX
WordPress大学
WordPress大学
Google DeepMind News
Google DeepMind News
Martin Fowler
Martin Fowler
小众软件
小众软件
Blog — PlanetScale
Blog — PlanetScale
月光博客
月光博客
The Cloudflare Blog
T
Tailwind CSS Blog
H
Help Net Security
腾讯CDC
爱范儿
爱范儿
人人都是产品经理
人人都是产品经理
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The GitHub Blog
The GitHub Blog
Microsoft Security Blog
Microsoft Security Blog
Stack Overflow Blog
Stack Overflow Blog
D
DataBreaches.Net
C
Check Point Blog
量子位
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com

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): keep parallel Gemini tool responses in the t...
yetval · 2026-06-17 · via Recent Commits to openclaw:main
1+

import type { Part } from "@google/genai";

2+

import { describe, expect, it } from "vitest";

3+

import type { Context, Model } from "../types.js";

4+

import { convertMessages } from "./google-shared.js";

5+

import { makeGoogleAssistantMessage } from "./google-shared.test-helpers.js";

6+7+

const convertMessagesForTest = convertMessages as unknown as (

8+

model: Model<"google-generative-ai">,

9+

context: Context,

10+

) => ReturnType<typeof convertMessages>;

11+12+

const makeVisionModel = (id: string): Model<"google-generative-ai"> =>

13+

({

14+

id,

15+

name: id,

16+

api: "google-generative-ai",

17+

provider: "google",

18+

baseUrl: "https://example.invalid",

19+

reasoning: false,

20+

input: ["text", "image"],

21+

cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },

22+

contextWindow: 1,

23+

maxTokens: 1,

24+

}) as Model<"google-generative-ai">;

25+26+

function countFunctionResponses(parts: readonly Part[] | undefined): number {

27+

return (parts ?? []).filter((p) => p.functionResponse != null).length;

28+

}

29+30+

function functionResponseNames(parts: readonly Part[] | undefined): string[] {

31+

return (parts ?? []).flatMap((part) =>

32+

part.functionResponse?.name ? [part.functionResponse.name] : [],

33+

);

34+

}

35+36+

describe("google-shared convertMessages — parallel tool results with an image (Gemini < 3)", () => {

37+

it.each([

38+

["image first", ["screenshot", "weather"]],

39+

["image last", ["weather", "screenshot"]],

40+

] as const)(

41+

"keeps the response run immediate and retains a deferred %s result",

42+

(_label, resultOrder) => {

43+

const model = makeVisionModel("gemini-2.5-flash");

44+

const toolResults = {

45+

screenshot: {

46+

role: "toolResult",

47+

toolCallId: "call_1",

48+

toolName: "screenshot",

49+

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

50+

isError: false,

51+

timestamp: 0,

52+

},

53+

weather: {

54+

role: "toolResult",

55+

toolCallId: "call_2",

56+

toolName: "weather",

57+

content: [{ type: "text", text: "Sunny, 21C" }],

58+

isError: false,

59+

timestamp: 0,

60+

},

61+

} as const;

62+

const context = {

63+

messages: [

64+

{ role: "user", content: "Screenshot the page and check the weather." },

65+

makeGoogleAssistantMessage(model.id, [

66+

{ type: "toolCall", id: "call_1", name: "screenshot", arguments: {} },

67+

{ type: "toolCall", id: "call_2", name: "weather", arguments: {} },

68+

]),

69+

...resultOrder.map((name) => toolResults[name]),

70+

],

71+

} as unknown as Context;

72+73+

const contents = convertMessagesForTest(model, context);

74+75+

expect(contents.map((content) => content.role)).toEqual(["user", "model", "user", "user"]);

76+

expect(functionResponseNames(contents[2].parts)).toEqual(resultOrder);

77+

expect(contents[3]).toEqual({

78+

role: "user",

79+

parts: [

80+

{ text: "Tool result image:" },

81+

{ inlineData: { mimeType: "image/png", data: "AAAA" } },

82+

],

83+

});

84+

expect(contents.slice(3).some((c) => countFunctionResponses(c.parts) > 0)).toBe(false);

85+

},

86+

);

87+

});