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

推荐订阅源

P
Proofpoint News Feed
Martin Fowler
Martin Fowler
The GitHub Blog
The GitHub Blog
B
Blog RSS Feed
U
Unit 42
阮一峰的网络日志
阮一峰的网络日志
量子位
GbyAI
GbyAI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
云风的 BLOG
云风的 BLOG
小众软件
小众软件
博客园 - 三生石上(FineUI控件)
L
LangChain Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园_首页
IT之家
IT之家
V
Visual Studio Blog
Y
Y Combinator Blog
Blog — PlanetScale
Blog — PlanetScale
宝玉的分享
宝玉的分享
Apple Machine Learning Research
Apple Machine Learning Research
I
InfoQ
D
Docker
V
V2EX

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(sessions): recover empty preflight compaction · openc...
TurboTheTurt · 2026-05-29 · via Recent Commits to openclaw:main

@@ -976,6 +976,123 @@ describe("updateSessionStoreAfterAgentRun", () => {

976976

});

977977

});

978978979+

it("prefers fresh CLI usage over zero compaction tokensAfter", async () => {

980+

await withTempSessionStore(async ({ storePath }) => {

981+

const cfg = {} as OpenClawConfig;

982+

const sessionKey = "agent:main:explicit:test-zero-compaction-with-usage";

983+

const sessionId = "test-zero-compaction-with-usage-session";

984+

const sessionStore: Record<string, SessionEntry> = {

985+

[sessionKey]: {

986+

sessionId,

987+

updatedAt: 1,

988+

totalTokens: 1_794_391,

989+

totalTokensFresh: true,

990+

inputTokens: 20,

991+

outputTokens: 10_855,

992+

cacheRead: 1_761_324,

993+

cacheWrite: 33_047,

994+

},

995+

};

996+

await fs.writeFile(storePath, JSON.stringify(sessionStore, null, 2));

997+998+

await updateSessionStoreAfterAgentRun({

999+

cfg,

1000+

sessionId,

1001+

sessionKey,

1002+

storePath,

1003+

sessionStore,

1004+

defaultProvider: "claude-cli",

1005+

defaultModel: "claude-opus-4-7",

1006+

result: {

1007+

meta: {

1008+

durationMs: 500,

1009+

agentMeta: {

1010+

sessionId,

1011+

provider: "claude-cli",

1012+

model: "claude-opus-4-7",

1013+

usage: {

1014+

input: 20,

1015+

output: 10_855,

1016+

cacheRead: 1_761_324,

1017+

cacheWrite: 33_047,

1018+

},

1019+

lastCallUsage: {

1020+

input: 20,

1021+

output: 10_855,

1022+

cacheRead: 1_761_324,

1023+

cacheWrite: 33_047,

1024+

},

1025+

compactionCount: 1,

1026+

compactionTokensAfter: 0,

1027+

},

1028+

},

1029+

} as EmbeddedAgentRunResult,

1030+

});

1031+1032+

expect(sessionStore[sessionKey]?.totalTokens).toBe(1_794_391);

1033+

expect(sessionStore[sessionKey]?.totalTokensFresh).toBe(true);

1034+

expect(sessionStore[sessionKey]?.inputTokens).toBe(20);

1035+

expect(sessionStore[sessionKey]?.outputTokens).toBe(10_855);

1036+

expect(sessionStore[sessionKey]?.cacheRead).toBe(1_761_324);

1037+

expect(sessionStore[sessionKey]?.cacheWrite).toBe(33_047);

1038+

});

1039+

});

1040+1041+

it("prefers fresh usage over positive compaction tokensAfter", async () => {

1042+

await withTempSessionStore(async ({ storePath }) => {

1043+

const cfg = {} as OpenClawConfig;

1044+

const sessionKey = "agent:main:explicit:test-positive-compaction-with-usage";

1045+

const sessionId = "test-positive-compaction-with-usage-session";

1046+

const sessionStore: Record<string, SessionEntry> = {

1047+

[sessionKey]: {

1048+

sessionId,

1049+

updatedAt: 1,

1050+

totalTokens: 180_000,

1051+

totalTokensFresh: true,

1052+

},

1053+

};

1054+

await fs.writeFile(storePath, JSON.stringify(sessionStore, null, 2));

1055+1056+

await updateSessionStoreAfterAgentRun({

1057+

cfg,

1058+

sessionId,

1059+

sessionKey,

1060+

storePath,

1061+

sessionStore,

1062+

defaultProvider: "openai",

1063+

defaultModel: "gpt-5.5",

1064+

result: {

1065+

meta: {

1066+

durationMs: 500,

1067+

agentMeta: {

1068+

sessionId,

1069+

provider: "openai",

1070+

model: "gpt-5.5",

1071+

usage: {

1072+

input: 100_000,

1073+

output: 3_000,

1074+

cacheRead: 20_000,

1075+

},

1076+

lastCallUsage: {

1077+

input: 91_000,

1078+

output: 1_000,

1079+

cacheRead: 4_000,

1080+

},

1081+

compactionCount: 1,

1082+

compactionTokensAfter: 80_000,

1083+

},

1084+

},

1085+

} as EmbeddedAgentRunResult,

1086+

});

1087+1088+

expect(sessionStore[sessionKey]?.totalTokens).toBe(120_000);

1089+

expect(sessionStore[sessionKey]?.totalTokensFresh).toBe(true);

1090+

expect(sessionStore[sessionKey]?.inputTokens).toBe(100_000);

1091+

expect(sessionStore[sessionKey]?.outputTokens).toBe(3_000);

1092+

expect(sessionStore[sessionKey]?.cacheRead).toBe(20_000);

1093+

});

1094+

});

1095+9791096

it("accepts zero compaction tokensAfter when provider usage is unavailable", async () => {

9801097

await withTempSessionStore(async ({ storePath }) => {

9811098

const cfg = {} as OpenClawConfig;

@@ -987,6 +1104,29 @@ describe("updateSessionStoreAfterAgentRun", () => {

9871104

updatedAt: 1,

9881105

totalTokens: 12_000,

9891106

totalTokensFresh: true,

1107+

inputTokens: 20,

1108+

outputTokens: 10_855,

1109+

cacheRead: 1_761_324,

1110+

cacheWrite: 33_047,

1111+

contextBudgetStatus: {

1112+

schemaVersion: 1,

1113+

source: "pre-prompt-estimate",

1114+

updatedAt: 1,

1115+

provider: "claude-cli",

1116+

model: "claude-opus-4-7",

1117+

route: "compact_only",

1118+

shouldCompact: true,

1119+

estimatedPromptTokens: 1_794_391,

1120+

contextTokenBudget: 1_048_576,

1121+

promptBudgetBeforeReserve: 1_044_480,

1122+

reserveTokens: 4_096,

1123+

effectiveReserveTokens: 4_096,

1124+

remainingPromptBudgetTokens: 0,

1125+

overflowTokens: 749_911,

1126+

toolResultReducibleChars: 0,

1127+

messageCount: 0,

1128+

unwindowedMessageCount: 0,

1129+

},

9901130

},

9911131

};

9921132

await fs.writeFile(storePath, JSON.stringify(sessionStore, null, 2));

@@ -1016,6 +1156,11 @@ describe("updateSessionStoreAfterAgentRun", () => {

10161156

expect(sessionStore[sessionKey]?.totalTokens).toBe(0);

10171157

expect(sessionStore[sessionKey]?.totalTokensFresh).toBe(true);

10181158

expect(sessionStore[sessionKey]?.compactionCount).toBe(1);

1159+

expect(sessionStore[sessionKey]?.inputTokens).toBeUndefined();

1160+

expect(sessionStore[sessionKey]?.outputTokens).toBeUndefined();

1161+

expect(sessionStore[sessionKey]?.cacheRead).toBeUndefined();

1162+

expect(sessionStore[sessionKey]?.cacheWrite).toBeUndefined();

1163+

expect(sessionStore[sessionKey]?.contextBudgetStatus).toBeUndefined();

10191164

});

10201165

});

10211166