test: tighten sanitize history assertions · openclaw/openclaw@bb241b2
steipete
·
2026-05-09
·
via Recent Commits to openclaw:main
File tree
src/agents/pi-embedded-runner
| Original file line number | Diff line number | Diff line change |
|---|
@@ -54,11 +54,9 @@ describe("sanitizeSessionHistory toolResult details stripping", () => {
|
54 | 54 | }); |
55 | 55 | |
56 | 56 | const toolResult = sanitized.find((m) => m && typeof m === "object" && m.role === "toolResult"); |
57 | | -expect(toolResult).toMatchObject({ |
58 | | -role: "toolResult", |
59 | | -toolCallId: "call1", |
60 | | -toolName: "web_fetch", |
61 | | -}); |
| 57 | +expect(toolResult?.role).toBe("toolResult"); |
| 58 | +expect(toolResult?.toolCallId).toBe("call1"); |
| 59 | +expect(toolResult?.toolName).toBe("web_fetch"); |
62 | 60 | expect(toolResult).not.toHaveProperty("details"); |
63 | 61 | |
64 | 62 | const serialized = JSON.stringify(sanitized); |
@@ -80,9 +78,10 @@ describe("sanitizeSessionHistory toolResult details stripping", () => {
|
80 | 78 | sessionId: "test", |
81 | 79 | }); |
82 | 80 | |
83 | | -expect(sanitized[0]).toMatchObject({ |
84 | | -role: "assistant", |
85 | | -content: [{ type: "text", text: "plain reply" }], |
86 | | -}); |
| 81 | +const assistant = sanitized[0]; |
| 82 | +if (!assistant || assistant.role !== "assistant") { |
| 83 | +throw new Error("Expected sanitized first message to be an assistant message"); |
| 84 | +} |
| 85 | +expect(assistant?.content).toEqual([{ type: "text", text: "plain reply" }]); |
87 | 86 | }); |
88 | 87 | }); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。