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

推荐订阅源

Stack Overflow Blog
Stack Overflow Blog
Vercel News
Vercel News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
J
Java Code Geeks
M
MIT News - Artificial intelligence
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
MongoDB | Blog
MongoDB | Blog
G
Google Developers Blog
Engineering at Meta
Engineering at Meta
量子位
S
SegmentFault 最新的问题
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
A
About on SuperTechFans
P
Proofpoint News Feed
Last Week in AI
Last Week in AI
Recent Announcements
Recent Announcements
腾讯CDC
I
InfoQ
F
Fortinet All Blogs
Hugging Face - Blog
Hugging Face - Blog
Blog — PlanetScale
Blog — PlanetScale
H
Help Net Security
爱范儿
爱范儿

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: ignore compaction checkpoints in session usage · ope...
steipete · 2026-04-26 · via Recent Commits to openclaw:main

@@ -5,9 +5,11 @@ import path from "node:path";

55

import type { AssistantMessage, UserMessage } from "@mariozechner/pi-ai";

66

import { SessionManager } from "@mariozechner/pi-coding-agent";

77

import { afterEach, describe, expect, test } from "vitest";

8+

import type { OpenClawConfig } from "../config/types.openclaw.js";

89

import {

910

captureCompactionCheckpointSnapshot,

1011

cleanupCompactionCheckpointSnapshot,

12+

persistSessionCompactionCheckpoint,

1113

} from "./session-compaction-checkpoints.js";

12141315

const tempDirs: string[] = [];

@@ -81,4 +83,83 @@ describe("session-compaction-checkpoints", () => {

8183

expect(fsSync.existsSync(snapshot!.sessionFile)).toBe(false);

8284

expect(fsSync.existsSync(sessionFile!)).toBe(true);

8385

});

86+87+

test("persist trims old checkpoint metadata and removes trimmed snapshot files", async () => {

88+

const dir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-checkpoint-trim-"));

89+

tempDirs.push(dir);

90+91+

const storePath = path.join(dir, "sessions.json");

92+

const sessionId = "sess";

93+

const sessionKey = "agent:main:main";

94+

const now = Date.now();

95+

const existingCheckpoints = Array.from({ length: 26 }, (_, index) => {

96+

const uuid = `${String(index + 1).padStart(8, "0")}-1111-4111-8111-111111111111`;

97+

const sessionFile = path.join(dir, `sess.checkpoint.${uuid}.jsonl`);

98+

fsSync.writeFileSync(sessionFile, `checkpoint ${index}`, "utf-8");

99+

return {

100+

checkpointId: `old-${index}`,

101+

sessionKey,

102+

sessionId,

103+

createdAt: now + index,

104+

reason: "manual" as const,

105+

preCompaction: {

106+

sessionId,

107+

sessionFile,

108+

leafId: `old-leaf-${index}`,

109+

},

110+

postCompaction: { sessionId },

111+

};

112+

});

113+

await fs.writeFile(

114+

storePath,

115+

JSON.stringify(

116+

{

117+

[sessionKey]: {

118+

sessionId,

119+

updatedAt: now,

120+

compactionCheckpoints: existingCheckpoints,

121+

},

122+

},

123+

null,

124+

2,

125+

),

126+

"utf-8",

127+

);

128+129+

const currentSnapshotFile = path.join(

130+

dir,

131+

"sess.checkpoint.99999999-9999-4999-8999-999999999999.jsonl",

132+

);

133+

await fs.writeFile(currentSnapshotFile, "current", "utf-8");

134+135+

const stored = await persistSessionCompactionCheckpoint({

136+

cfg: {

137+

session: { store: storePath },

138+

agents: { list: [{ id: "main", default: true }] },

139+

} as OpenClawConfig,

140+

sessionKey: "main",

141+

sessionId,

142+

reason: "manual",

143+

snapshot: {

144+

sessionId,

145+

sessionFile: currentSnapshotFile,

146+

leafId: "current-leaf",

147+

},

148+

createdAt: now + 100,

149+

});

150+151+

expect(stored).not.toBeNull();

152+

expect(fsSync.existsSync(existingCheckpoints[0].preCompaction.sessionFile)).toBe(false);

153+

expect(fsSync.existsSync(existingCheckpoints[1].preCompaction.sessionFile)).toBe(false);

154+

expect(fsSync.existsSync(existingCheckpoints[2].preCompaction.sessionFile)).toBe(true);

155+

expect(fsSync.existsSync(currentSnapshotFile)).toBe(true);

156+157+

const nextStore = JSON.parse(await fs.readFile(storePath, "utf-8")) as Record<

158+

string,

159+

{ compactionCheckpoints?: unknown[] }

160+

>;

161+

expect(

162+

Object.values(nextStore).find((entry) => entry.compactionCheckpoints)?.compactionCheckpoints,

163+

).toHaveLength(25);

164+

});

84165

});