




















@@ -92,10 +92,27 @@ test("sessions.compaction.* lists checkpoints and branches or restores from pre-
9292expect(listedCheckpoints.ok).toBe(true);
9393expect(listedCheckpoints.payload?.key).toBe("agent:main:main");
9494expect(listedCheckpoints.payload?.checkpoints).toHaveLength(1);
95-expect(listedCheckpoints.payload?.checkpoints[0]).toMatchObject({
95+expect(listedCheckpoints.payload?.checkpoints[0]).toEqual({
9696checkpointId: "checkpoint-1",
97+sessionKey: "agent:main:main",
98+sessionId: fixture.sessionId,
99+createdAt: checkpointCreatedAt,
100+reason: "manual",
97101summary: "checkpoint summary",
98102tokensBefore: 123,
103+tokensAfter: 45,
104+firstKeptEntryId: fixture.preCompactionLeafId,
105+preCompaction: {
106+sessionId: fixture.preCompactionSession.getSessionId(),
107+sessionFile: fixture.preCompactionSessionFile,
108+leafId: fixture.preCompactionLeafId,
109+},
110+postCompaction: {
111+sessionId: fixture.sessionId,
112+sessionFile: fixture.sessionFile,
113+leafId: fixture.postCompactionLeafId,
114+entryId: fixture.postCompactionLeafId,
115+},
99116});
100117101118const checkpoint = await rpcReq<{
@@ -245,19 +262,33 @@ test("sessions.compact without maxLines runs embedded manual compaction for chec
245262expect(compacted.payload?.key).toBe("agent:main:main");
246263expect(compacted.payload?.compacted).toBe(true);
247264expect(embeddedRunMock.compactEmbeddedPiSession).toHaveBeenCalledTimes(1);
248-expect(embeddedRunMock.compactEmbeddedPiSession).toHaveBeenCalledWith(
249-expect.objectContaining({
250-sessionId: "sess-main",
251-sessionKey: "agent:main:main",
252-sessionFile: expect.stringMatching(/sess-main\.jsonl$/),
253-config: expect.any(Object),
254-provider: expect.any(String),
255-model: expect.any(String),
256-thinkLevel: "medium",
257-reasoningLevel: "stream",
258-trigger: "manual",
259-}),
265+const compactionCall = embeddedRunMock.compactEmbeddedPiSession.mock.calls[0]?.[0];
266+if (!compactionCall) {
267+throw new Error("expected embedded compaction call");
268+}
269+const callConfig = compactionCall.config as {
270+agents?: { defaults?: { model?: { primary?: unknown }; workspace?: unknown } };
271+};
272+expect(compactionCall.sessionId).toBe("sess-main");
273+expect(compactionCall.sessionKey).toBe("agent:main:main");
274+expect(path.basename(compactionCall.sessionFile)).toBe("sess-main.jsonl");
275+expect(compactionCall.workspaceDir).toBe(path.join(os.tmpdir(), "openclaw-gateway-test"));
276+expect(callConfig.agents?.defaults?.model?.primary).toBe("anthropic/claude-opus-4-6");
277+expect(callConfig.agents?.defaults?.workspace).toBe(
278+path.join(os.tmpdir(), "openclaw-gateway-test"),
260279);
280+expect(compactionCall.provider).toBe("anthropic");
281+expect(compactionCall.model).toBe("claude-opus-4-6");
282+expect(compactionCall.allowGatewaySubagentBinding).toBe(true);
283+expect(compactionCall.agentHarnessId).toBeUndefined();
284+expect(compactionCall.thinkLevel).toBe("medium");
285+expect(compactionCall.reasoningLevel).toBe("stream");
286+expect(compactionCall.bashElevated).toEqual({
287+enabled: false,
288+allowed: false,
289+defaultLevel: "off",
290+});
291+expect(compactionCall.trigger).toBe("manual");
261292262293const store = JSON.parse(await fs.readFile(storePath, "utf-8")) as Record<
263294string,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。