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

推荐订阅源

WordPress大学
WordPress大学
MyScale Blog
MyScale Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
人人都是产品经理
人人都是产品经理
C
Check Point Blog
宝玉的分享
宝玉的分享
B
Blog RSS Feed
博客园 - 三生石上(FineUI控件)
量子位
Martin Fowler
Martin Fowler
酷 壳 – CoolShell
酷 壳 – CoolShell
Jina AI
Jina AI
IT之家
IT之家
阮一峰的网络日志
阮一峰的网络日志
博客园 - 叶小钗
J
Java Code Geeks
The Cloudflare Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
腾讯CDC
P
Proofpoint News Feed
美团技术团队
H
Help Net Security
B
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(codex): normalize cached harness input tokens · openc...
vincentkoc · 2026-04-27 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -167,7 +167,7 @@ describe("CodexAppServerEventProjector", () => {

167167

outputTokens: 100_000,

168168

},

169169

last: {

170-

totalTokens: 14,

170+

totalTokens: 12,

171171

inputTokens: 5,

172172

cachedInputTokens: 2,

173173

outputTokens: 7,

@@ -186,12 +186,12 @@ describe("CodexAppServerEventProjector", () => {

186186

expect(result.assistantTexts).toEqual(["hello"]);

187187

expect(result.messagesSnapshot.map((message) => message.role)).toEqual(["user", "assistant"]);

188188

expect(result.lastAssistant?.content).toEqual([{ type: "text", text: "hello" }]);

189-

expect(result.attemptUsage).toMatchObject({ input: 5, output: 7, cacheRead: 2, total: 14 });

189+

expect(result.attemptUsage).toMatchObject({ input: 3, output: 7, cacheRead: 2, total: 12 });

190190

expect(result.lastAssistant?.usage).toMatchObject({

191-

input: 5,

191+

input: 3,

192192

output: 7,

193193

cacheRead: 2,

194-

totalTokens: 14,

194+

totalTokens: 12,

195195

});

196196

expect(result.replayMetadata.replaySafe).toBe(true);

197197

});

@@ -289,7 +289,7 @@ describe("CodexAppServerEventProjector", () => {

289289

tokenUsage: {

290290

total: { total_tokens: 1_000_000 },

291291

last_token_usage: {

292-

total_tokens: 20,

292+

total_tokens: 17,

293293

input_tokens: 8,

294294

cached_input_tokens: 3,

295295

output_tokens: 9,

@@ -300,12 +300,12 @@ describe("CodexAppServerEventProjector", () => {

300300
301301

const result = projector.buildResult(buildEmptyToolTelemetry());

302302
303-

expect(result.attemptUsage).toMatchObject({ input: 8, output: 9, cacheRead: 3, total: 20 });

303+

expect(result.attemptUsage).toMatchObject({ input: 5, output: 9, cacheRead: 3, total: 17 });

304304

expect(result.lastAssistant?.usage).toMatchObject({

305-

input: 8,

305+

input: 5,

306306

output: 9,

307307

cacheRead: 3,

308-

totalTokens: 20,

308+

totalTokens: 17,

309309

});

310310

});

311311
Original file line numberDiff line numberDiff line change

@@ -61,6 +61,13 @@ const CURRENT_TOKEN_USAGE_KEYS = [

6161

"last_token_usage",

6262

] as const;

6363
64+

const CODEX_PROMPT_TOTAL_INPUT_KEYS = [

65+

"inputTokens",

66+

"input_tokens",

67+

"promptTokens",

68+

"prompt_tokens",

69+

] as const;

70+
6471

const MAX_TOOL_OUTPUT_DELTA_MESSAGES_PER_ITEM = 20;

6572
6673

export class CodexAppServerEventProjector {

@@ -910,17 +917,24 @@ function readNumberAlias(record: JsonObject, keys: readonly string[]): number |

910917

}

911918
912919

function normalizeCodexTokenUsage(record: JsonObject): ReturnType<typeof normalizeUsage> {

920+

const promptTotalInput = readNumberAlias(record, CODEX_PROMPT_TOTAL_INPUT_KEYS);

921+

const cacheRead = readNumberAlias(record, [

922+

"cachedInputTokens",

923+

"cached_input_tokens",

924+

"cacheRead",

925+

"cache_read",

926+

"cache_read_input_tokens",

927+

"cached_tokens",

928+

]);

929+

const input =

930+

promptTotalInput !== undefined && cacheRead !== undefined

931+

? Math.max(0, promptTotalInput - cacheRead)

932+

: (promptTotalInput ?? readNumber(record, "input"));

933+
913934

return normalizeUsage({

914-

input: readNumberAlias(record, ["inputTokens", "input_tokens", "input", "promptTokens"]),

935+

input,

915936

output: readNumberAlias(record, ["outputTokens", "output_tokens", "output"]),

916-

cacheRead: readNumberAlias(record, [

917-

"cachedInputTokens",

918-

"cached_input_tokens",

919-

"cacheRead",

920-

"cache_read",

921-

"cache_read_input_tokens",

922-

"cached_tokens",

923-

]),

937+

cacheRead,

924938

cacheWrite: readNumberAlias(record, [

925939

"cacheWrite",

926940

"cache_write",