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

推荐订阅源

Martin Fowler
Martin Fowler
有赞技术团队
有赞技术团队
博客园_首页
H
Help Net Security
GbyAI
GbyAI
aimingoo的专栏
aimingoo的专栏
V
Visual Studio Blog
The Cloudflare Blog
腾讯CDC
Jina AI
Jina AI
Last Week in AI
Last Week in AI
月光博客
月光博客
博客园 - 叶小钗
Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
Blog — PlanetScale
Blog — PlanetScale
人人都是产品经理
人人都是产品经理
Engineering at Meta
Engineering at Meta
Y
Y Combinator Blog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 聂微东
爱范儿
爱范儿
N
Netflix TechBlog - Medium
F
Fortinet All Blogs

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(cli-output): ignore cumulative usage from result even...
zhouhe-xydt · 2026-05-23 · via Recent Commits to openclaw:main

@@ -322,6 +322,48 @@ describe("parseCliJsonl", () => {

322322

});

323323

});

324324325+

it("does not let cumulative Claude result usage overwrite assistant usage", () => {

326+

const result = parseCliJsonl(

327+

[

328+

JSON.stringify({ type: "init", session_id: "session-stream" }),

329+

JSON.stringify({

330+

type: "assistant",

331+

message: {

332+

id: "msg-1",

333+

usage: { input_tokens: 10, output_tokens: 5, cache_read_input_tokens: 100 },

334+

},

335+

}),

336+

JSON.stringify({

337+

type: "assistant",

338+

message: {

339+

id: "msg-2",

340+

usage: { input_tokens: 11, output_tokens: 6, cache_read_input_tokens: 125 },

341+

},

342+

}),

343+

JSON.stringify({

344+

type: "result",

345+

session_id: "session-stream",

346+

result: "done",

347+

usage: { input_tokens: 30, output_tokens: 15, cache_read_input_tokens: 300 },

348+

}),

349+

].join("\n"),

350+

{

351+

command: "claude",

352+

output: "jsonl",

353+

sessionIdFields: ["session_id"],

354+

},

355+

"claude-cli",

356+

);

357+358+

expect(result?.usage).toEqual({

359+

input: 11,

360+

output: 6,

361+

cacheRead: 125,

362+

cacheWrite: undefined,

363+

total: undefined,

364+

});

365+

});

366+325367

it("preserves Claude session metadata even when the final result text is empty", () => {

326368

const result = parseCliJsonl(

327369

[

@@ -447,4 +489,52 @@ describe("createCliJsonlStreamingParser", () => {

447489

{ text: "hello", delta: "hello", sessionId: "session-stream", usage: undefined },

448490

]);

449491

});

492+493+

it("ignores cumulative usage from result events to avoid cache_read inflation", () => {

494+

const parser = createCliJsonlStreamingParser({

495+

backend: {

496+

command: "local-cli",

497+

output: "jsonl",

498+

jsonlDialect: "claude-stream-json",

499+

sessionIdFields: ["session_id"],

500+

},

501+

providerId: "local-cli",

502+

onAssistantDelta: () => {},

503+

});

504+505+

parser.push(

506+

[

507+

JSON.stringify({ type: "init", session_id: "session-stream" }),

508+

JSON.stringify({

509+

type: "assistant",

510+

message: {

511+

id: "msg-1",

512+

usage: { input_tokens: 10, output_tokens: 5, cache_read_input_tokens: 100 },

513+

},

514+

}),

515+

JSON.stringify({

516+

type: "assistant",

517+

message: {

518+

id: "msg-2",

519+

usage: { input_tokens: 11, output_tokens: 6, cache_read_input_tokens: 125 },

520+

},

521+

}),

522+

JSON.stringify({

523+

type: "result",

524+

result: "done",

525+

usage: { input_tokens: 30, output_tokens: 15, cache_read_input_tokens: 300 },

526+

}),

527+

].join("\n"),

528+

);

529+

parser.finish();

530+531+

const output = parser.getOutput();

532+

expect(output?.usage).toEqual({

533+

input: 11,

534+

output: 6,

535+

cacheRead: 125,

536+

cacheWrite: undefined,

537+

total: undefined,

538+

});

539+

});

450540

});