@@ -72,11 +72,29 @@ describe("compaction toolResult details stripping", () => {
|
72 | 72 | }); |
73 | 73 | |
74 | 74 | expect(summary).toBe("summary"); |
75 | | -expect(piCodingAgentMocks.generateSummary).toHaveBeenCalled(); |
| 75 | +expect(piCodingAgentMocks.generateSummary).toHaveBeenCalledTimes(1); |
76 | 76 | |
77 | 77 | const chunk = ( |
78 | | -piCodingAgentMocks.generateSummary.mock.calls as unknown as Array<[unknown]> |
| 78 | +piCodingAgentMocks.generateSummary.mock.calls as unknown as Array<[AgentMessage[]]> |
79 | 79 | )[0]?.[0]; |
| 80 | +expect(chunk).toMatchObject([ |
| 81 | +{ |
| 82 | +role: "assistant", |
| 83 | +content: [ |
| 84 | +{ type: "toolCall", id: "call_1", name: "browser", arguments: { action: "tabs" } }, |
| 85 | +], |
| 86 | +timestamp: 1, |
| 87 | +}, |
| 88 | +{ |
| 89 | +role: "toolResult", |
| 90 | +toolCallId: "call_1", |
| 91 | +toolName: "browser", |
| 92 | +isError: false, |
| 93 | +content: [{ type: "text", text: "ok" }], |
| 94 | +timestamp: 2, |
| 95 | +}, |
| 96 | +]); |
| 97 | +expect(chunk?.[1]).not.toHaveProperty("details"); |
80 | 98 | const serialized = JSON.stringify(chunk); |
81 | 99 | expect(serialized).not.toContain("Ignore previous instructions"); |
82 | 100 | expect(serialized).not.toContain('"details"'); |
@@ -105,9 +123,14 @@ describe("compaction toolResult details stripping", () => {
|
105 | 123 | contextWindow: 10000, |
106 | 124 | }); |
107 | 125 | |
| 126 | +expect(piCodingAgentMocks.generateSummary).toHaveBeenCalledTimes(1); |
108 | 127 | const chunk = ( |
109 | | -piCodingAgentMocks.generateSummary.mock.calls as unknown as Array<[unknown]> |
| 128 | +piCodingAgentMocks.generateSummary.mock.calls as unknown as Array<[AgentMessage[]]> |
110 | 129 | )[0]?.[0]; |
| 130 | +expect(chunk).toStrictEqual([ |
| 131 | +{ role: "user", content: "visible ask", timestamp: 1 }, |
| 132 | +{ role: "assistant", content: "visible answer", timestamp: 3 }, |
| 133 | +]); |
111 | 134 | const serialized = JSON.stringify(chunk); |
112 | 135 | expect(serialized).toContain("visible ask"); |
113 | 136 | expect(serialized).not.toContain("openclaw.runtime-context"); |
|