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

推荐订阅源

博客园 - Franky
云风的 BLOG
云风的 BLOG
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Engineering at Meta
Engineering at Meta
Vercel News
Vercel News
Y
Y Combinator Blog
B
Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Check Point Blog
M
MIT News - Artificial intelligence
Jina AI
Jina AI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Apple Machine Learning Research
Apple Machine Learning Research
Hugging Face - Blog
Hugging Face - Blog
阮一峰的网络日志
阮一峰的网络日志
罗磊的独立博客
Stack Overflow Blog
Stack Overflow Blog
F
Fortinet All Blogs
博客园 - 司徒正美
I
InfoQ
Google DeepMind News
Google DeepMind News
GbyAI
GbyAI
U
Unit 42

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
test: map turn validation merges · openclaw/openclaw@e9f7600
shakkernerd · 2026-05-12 · via Recent Commits to openclaw:main

@@ -102,11 +102,18 @@ describe("validateGeminiTurns", () => {

102102103103

const result = validateGeminiTurns(msgs);

104104105-

expect(result).toHaveLength(3);

106-

expect(result[0]).toEqual({ role: "user", content: "Hello" });

107-

expect(result[1].role).toBe("assistant");

108-

expect((result[1] as { content?: unknown[] }).content).toHaveLength(2);

109-

expect(result[2]).toEqual({ role: "user", content: "How are you?" });

105+

expect(result).toEqual([

106+

{ role: "user", content: "Hello" },

107+

{

108+

role: "assistant",

109+

content: [

110+

{ type: "text", text: "Part 1" },

111+

{ type: "text", text: "Part 2" },

112+

],

113+

stopReason: "end_turn",

114+

},

115+

{ role: "user", content: "How are you?" },

116+

]);

110117

});

111118112119

it("should preserve metadata from later message when merging", () => {

@@ -126,11 +133,17 @@ describe("validateGeminiTurns", () => {

126133127134

const result = validateGeminiTurns(msgs);

128135129-

expect(result).toHaveLength(1);

130-

const merged = result[0] as Extract<AgentMessage, { role: "assistant" }>;

131-

expect(merged.usage).toEqual({ input: 10, output: 10 });

132-

expect(merged.stopReason).toBe("end_turn");

133-

expect(merged.content).toHaveLength(2);

136+

expect(result).toEqual([

137+

{

138+

role: "assistant",

139+

content: [

140+

{ type: "text", text: "Part 1" },

141+

{ type: "text", text: "Part 2" },

142+

],

143+

usage: { input: 10, output: 10 },

144+

stopReason: "end_turn",

145+

},

146+

]);

134147

});

135148136149

it("should handle toolResult messages without merging", () => {

@@ -158,12 +171,26 @@ describe("validateGeminiTurns", () => {

158171159172

const result = validateGeminiTurns(msgs);

160173161-

// Should merge the consecutive assistants

162-

expect(result[0].role).toBe("user");

163-

expect(result[1].role).toBe("assistant");

164-

expect(result[2].role).toBe("toolResult");

165-

expect(result[3].role).toBe("assistant");

166-

expect(result[4].role).toBe("user");

174+

expect(result).toEqual([

175+

{ role: "user", content: "Use tool" },

176+

{

177+

role: "assistant",

178+

content: [{ type: "toolUse", id: "tool-1", name: "test", input: {} }],

179+

},

180+

{

181+

role: "toolResult",

182+

toolUseId: "tool-1",

183+

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

184+

},

185+

{

186+

role: "assistant",

187+

content: [

188+

{ type: "text", text: "Here's the answer" },

189+

{ type: "text", text: "Extra thoughts" },

190+

],

191+

},

192+

{ role: "user", content: "Request 2" },

193+

]);

167194

});

168195

});

169196

@@ -197,14 +224,16 @@ describe("validateAnthropicTurns", () => {

197224198225

const result = validateAnthropicTurns(msgs);

199226200-

expect(result).toHaveLength(1);

201-

expect(result[0].role).toBe("user");

202-

const content = (result[0] as { content: unknown[] }).content;

203-

expect(content).toHaveLength(2);

204-

expect(content[0]).toEqual({ type: "text", text: "First message" });

205-

expect(content[1]).toEqual({ type: "text", text: "Second message" });

206-

// Should take timestamp from the newer message

207-

expect((result[0] as { timestamp?: number }).timestamp).toBe(2000);

227+

expect(result).toEqual([

228+

{

229+

role: "user",

230+

content: [

231+

{ type: "text", text: "First message" },

232+

{ type: "text", text: "Second message" },

233+

],

234+

timestamp: 2000,

235+

},

236+

]);

208237

});

209238210239

it("should merge three consecutive user messages", () => {

@@ -216,9 +245,16 @@ describe("validateAnthropicTurns", () => {

216245217246

const result = validateAnthropicTurns(msgs);

218247219-

expect(result).toHaveLength(1);

220-

const content = (result[0] as { content: unknown[] }).content;

221-

expect(content).toHaveLength(3);

248+

expect(result).toEqual([

249+

{

250+

role: "user",

251+

content: [

252+

{ type: "text", text: "One" },

253+

{ type: "text", text: "Two" },

254+

{ type: "text", text: "Three" },

255+

],

256+

},

257+

]);

222258

});

223259224260

it("keeps newest metadata when merging consecutive users", () => {

@@ -295,8 +331,7 @@ describe("validateAnthropicTurns", () => {

295331296332

const result = validateAnthropicTurns(msgs);

297333298-

// validateAnthropicTurns only merges user messages, not assistant

299-

expect(result).toHaveLength(3);

334+

expect(result).toEqual(msgs);

300335

});

301336302337

it("should handle mixed scenario with steering messages", () => {

@@ -318,13 +353,22 @@ describe("validateAnthropicTurns", () => {

318353319354

const result = validateAnthropicTurns(msgs);

320355321-

// The two consecutive user messages at the end should be merged

322-

expect(result).toHaveLength(3);

323-

expect(result[0].role).toBe("user");

324-

expect(result[1].role).toBe("assistant");

325-

expect(result[2].role).toBe("user");

326-

const lastContent = (result[2] as { content: unknown[] }).content;

327-

expect(lastContent).toHaveLength(2);

356+

expect(result).toEqual([

357+

{ role: "user", content: [{ type: "text", text: "Original question" }] },

358+

{

359+

role: "assistant",

360+

content: [],

361+

stopReason: "error",

362+

errorMessage: "Overloaded",

363+

},

364+

expect.objectContaining({

365+

role: "user",

366+

content: [

367+

{ type: "text", text: "Steering: try again" },

368+

{ type: "text", text: "Another follow-up" },

369+

],

370+

}),

371+

]);

328372

});

329373

});

330374