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

推荐订阅源

Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Vercel News
Vercel News
F
Fortinet All Blogs
月光博客
月光博客
G
Google Developers Blog
博客园 - Franky
GbyAI
GbyAI
The Cloudflare Blog
I
InfoQ
雷峰网
雷峰网
WordPress大学
WordPress大学
罗磊的独立博客
大猫的无限游戏
大猫的无限游戏
T
The Blog of Author Tim Ferriss
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 聂微东
小众软件
小众软件
腾讯CDC
B
Blog
量子位
V
V2EX
S
SegmentFault 最新的问题
Google DeepMind News
Google DeepMind News

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
test: tighten cli session history assertions · openclaw/o...
steipete · 2026-05-10 · via Recent Commits to openclaw:main

@@ -59,6 +59,27 @@ function createSessionTranscript(params: {

5959

return sessionFile;

6060

}

616162+

function requireRecord(value: unknown, label: string): Record<string, unknown> {

63+

if (!value || typeof value !== "object") {

64+

throw new Error(`expected ${label}`);

65+

}

66+

return value as Record<string, unknown>;

67+

}

68+69+

function expectMessageFields(value: unknown, expected: { role: string; content?: string }) {

70+

const message = requireRecord(value, "message");

71+

expect(message.role).toBe(expected.role);

72+

if ("content" in expected) {

73+

expect(message.content).toBe(expected.content);

74+

}

75+

}

76+77+

function expectCompactionSummary(value: unknown, summary: string) {

78+

const message = requireRecord(value, "compaction summary");

79+

expect(message.role).toBe("compactionSummary");

80+

expect(message.summary).toBe(summary);

81+

}

82+6283

describe("loadCliSessionHistoryMessages", () => {

6384

afterEach(() => {

6485

vi.unstubAllEnvs();

@@ -81,14 +102,14 @@ describe("loadCliSessionHistoryMessages", () => {

81102

});

8210383104

try {

84-

expect(

85-

await loadCliSessionHistoryMessages({

86-

sessionId: "session-test",

87-

sessionFile: outsideFile,

88-

sessionKey: "agent:main:main",

89-

agentId: "main",

90-

}),

91-

).toMatchObject([{ role: "user", content: "expected history" }]);

105+

const history = await loadCliSessionHistoryMessages({

106+

sessionId: "session-test",

107+

sessionFile: outsideFile,

108+

sessionKey: "agent:main:main",

109+

agentId: "main",

110+

});

111+

expect(history).toHaveLength(1);

112+

expectMessageFields(history[0], { role: "user", content: "expected history" });

92113

} finally {

93114

fs.rmSync(stateDir, { recursive: true, force: true });

94115

fs.rmSync(outsideDir, { recursive: true, force: true });

@@ -115,8 +136,8 @@ describe("loadCliSessionHistoryMessages", () => {

115136

agentId: "main",

116137

});

117138

expect(history).toHaveLength(MAX_CLI_SESSION_HISTORY_MESSAGES);

118-

expect(history[0]).toMatchObject({ role: "user", content: "msg-25" });

119-

expect(history.at(-1)).toMatchObject({

139+

expectMessageFields(history[0], { role: "user", content: "msg-25" });

140+

expectMessageFields(history.at(-1), {

120141

role: "user",

121142

content: `msg-${MAX_CLI_SESSION_HISTORY_MESSAGES + 24}`,

122143

});

@@ -201,19 +222,19 @@ describe("loadCliSessionHistoryMessages", () => {

201222

});

202223203224

try {

204-

expect(

205-

await loadCliSessionHistoryMessages({

206-

sessionId: "session-custom-store",

207-

sessionFile,

208-

sessionKey: "agent:main:main",

209-

agentId: "main",

210-

config: {

211-

session: {

212-

store: storePath,

213-

},

225+

const history = await loadCliSessionHistoryMessages({

226+

sessionId: "session-custom-store",

227+

sessionFile,

228+

sessionKey: "agent:main:main",

229+

agentId: "main",

230+

config: {

231+

session: {

232+

store: storePath,

214233

},

215-

}),

216-

).toMatchObject([{ role: "user", content: "custom store history" }]);

234+

},

235+

});

236+

expect(history).toHaveLength(1);

237+

expectMessageFields(history[0], { role: "user", content: "custom store history" });

217238

} finally {

218239

fs.rmSync(stateDir, { recursive: true, force: true });

219240

fs.rmSync(customStoreDir, { recursive: true, force: true });

@@ -271,8 +292,8 @@ describe("loadCliSessionReseedMessages", () => {

271292

rawTranscriptReseedReason: "missing-transcript",

272293

});

273294

expect(reseed).toHaveLength(MAX_CLI_SESSION_HISTORY_MESSAGES);

274-

expect(reseed[0]).toMatchObject({ role: "user", content: "raw-25" });

275-

expect(reseed.at(-1)).toMatchObject({

295+

expectMessageFields(reseed[0], { role: "user", content: "raw-25" });

296+

expectMessageFields(reseed.at(-1), {

276297

role: "user",

277298

content: `raw-${MAX_CLI_SESSION_HISTORY_MESSAGES + 24}`,

278299

});

@@ -363,10 +384,9 @@ describe("loadCliSessionReseedMessages", () => {

363384

sessionKey: "agent:main:main",

364385

agentId: "main",

365386

});

366-

expect(reseed).toMatchObject([

367-

{ role: "compactionSummary", summary: "safe compacted summary" },

368-

{ role: "user", content: "post-compaction ask" },

369-

]);

387+

expect(reseed).toHaveLength(2);

388+

expectCompactionSummary(reseed[0], "safe compacted summary");

389+

expectMessageFields(reseed[1], { role: "user", content: "post-compaction ask" });

370390

expect(buildCliSessionHistoryPrompt({ messages: reseed, prompt: "next" })).toContain(

371391

"Compaction summary: safe compacted summary",

372392

);