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

推荐订阅源

博客园_首页
C
Check Point Blog
B
Blog RSS Feed
G
Google Developers Blog
H
Help Net Security
博客园 - Franky
Blog — PlanetScale
Blog — PlanetScale
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Recent Announcements
Recent Announcements
B
Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
DataBreaches.Net
小众软件
小众软件
T
The Blog of Author Tim Ferriss
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
MongoDB | Blog
MongoDB | Blog
Y
Y Combinator Blog
T
Tailwind CSS Blog
J
Java Code Geeks
MyScale Blog
MyScale Blog
雷峰网
雷峰网
有赞技术团队
有赞技术团队
博客园 - 聂微东

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(agents): remove transient session-repair backups · op...
2026-05-16 · via Recent Commits to openclaw:main

@@ -30,11 +30,14 @@ async function createTempSessionPath() {

3030

return { dir, file: path.join(dir, "session.jsonl") };

3131

}

323233-

function requireBackupPath(result: { backupPath?: string }): string {

34-

if (!result.backupPath) {

35-

throw new Error("expected session repair backup path");

36-

}

37-

return result.backupPath;

33+

async function expectNoRetainedBackup(

34+

file: string,

35+

result: { backupPath?: string },

36+

): Promise<void> {

37+

expect(result.backupPath).toBeUndefined();

38+

const siblings = await fs.readdir(path.dirname(file));

39+

const leftover = siblings.filter((name) => name.includes(".bak-"));

40+

expect(leftover).toEqual([]);

3841

}

39424043

function requireFirstLogMessage(log: ReturnType<typeof vi.fn>): string {

@@ -60,7 +63,6 @@ describe("repairSessionFileIfNeeded", () => {

6063

const result = await repairSessionFileIfNeeded({ sessionFile: file });

6164

expect(result.repaired).toBe(true);

6265

expect(result.droppedLines).toBe(1);

63-

const backupPath = requireBackupPath(result);

64666567

const repaired = await fs.readFile(file, "utf-8");

6668

const repairedLines = repaired

@@ -69,8 +71,26 @@ describe("repairSessionFileIfNeeded", () => {

6971

.map((line) => JSON.parse(line));

7072

expect(repairedLines).toEqual([header, message]);

717372-

const backup = await fs.readFile(backupPath, "utf-8");

73-

expect(backup).toBe(content);

74+

await expectNoRetainedBackup(file, result);

75+

});

76+77+

it("does not accumulate backups across repeated repairs of a persistently corrupted file", async () => {

78+

// Regression for #80960: a stuck session with a writer that keeps

79+

// appending a malformed line caused every repair invocation to leave a

80+

// ~1.8 MB `.bak-<pid>-<ts>` snapshot, accumulating 2,180 files / 2.1 GB

81+

// on a single agent over ~25 hours.

82+

const { file } = await createTempSessionPath();

83+

const { header, message } = buildSessionHeaderAndMessage();

84+

const malformedTail = '{"type":"message"';

85+86+

for (let i = 0; i < 5; i++) {

87+

const content = `${JSON.stringify(header)}\n${JSON.stringify(message)}\n${malformedTail}`;

88+

await fs.writeFile(file, content, "utf-8");

89+

const result = await repairSessionFileIfNeeded({ sessionFile: file });

90+

expect(result.repaired).toBe(true);

91+

expect(result.droppedLines).toBe(1);

92+

await expectNoRetainedBackup(file, result);

93+

}

7494

});

75957696

it("does not drop CRLF-terminated JSONL lines", async () => {

@@ -151,7 +171,7 @@ describe("repairSessionFileIfNeeded", () => {

151171

expect(result.repaired).toBe(true);

152172

expect(result.droppedLines).toBe(0);

153173

expect(result.rewrittenAssistantMessages).toBe(1);

154-

await expect(fs.readFile(requireBackupPath(result), "utf-8")).resolves.toBe(original);

174+

await expectNoRetainedBackup(file, result);

155175

expect(debug).toHaveBeenCalledTimes(1);

156176

const debugMessage = requireFirstLogMessage(debug);

157177

expect(debugMessage).toContain("rewrote 1 assistant message(s)");

@@ -528,8 +548,7 @@ describe("repairSessionFileIfNeeded", () => {

528548529549

expect(result.repaired).toBe(true);

530550

expect(result.insertedToolResults).toBe(1);

531-

const backup = await fs.readFile(requireBackupPath(result), "utf-8");

532-

expect(backup).toBe(original);

551+

await expectNoRetainedBackup(file, result);

533552534553

const lines = (await fs.readFile(file, "utf-8")).trimEnd().split("\n");

535554

expect(lines).toHaveLength(5);

@@ -773,7 +792,7 @@ describe("repairSessionFileIfNeeded", () => {

773792774793

expect(result.repaired).toBe(true);

775794

expect(result.droppedLines).toBe(3);

776-

await expect(fs.readFile(requireBackupPath(result), "utf-8")).resolves.toBe(`${content}\n`);

795+

await expectNoRetainedBackup(file, result);

777796778797

const after = await fs.readFile(file, "utf-8");

779798

const lines = after.trimEnd().split("\n");