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

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tailwind CSS Blog
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
GbyAI
GbyAI
爱范儿
爱范儿
量子位
Martin Fowler
Martin Fowler
V
V2EX
博客园 - 三生石上(FineUI控件)
I
InfoQ
MongoDB | Blog
MongoDB | Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
N
Netflix TechBlog - Medium
D
DataBreaches.Net
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Last Week in AI
Last Week in AI
U
Unit 42
Apple Machine Learning Research
Apple Machine Learning Research
H
Help Net Security
T
The Blog of Author Tim Ferriss
Hugging Face - Blog
Hugging Face - Blog
美团技术团队
Engineering at Meta
Engineering at Meta

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): count stream deltas incrementally · openclaw...
vincentkoc · 2026-06-01 · via Recent Commits to openclaw:main

@@ -346,6 +346,110 @@ describe("wrapStreamFnWithDiagnosticModelCallEvents", () => {

346346

expect(JSON.stringify(events)).not.toContain("sk-original-secret");

347347

});

348348349+

it("counts text deltas without serializing full partial snapshots", async () => {

350+

const serializedPartial = vi.fn(() => {

351+

throw new Error("partial snapshot should not be serialized for text deltas");

352+

});

353+

async function* stream() {

354+

yield {

355+

type: "text_delta",

356+

contentIndex: 0,

357+

delta: "a",

358+

partial: {

359+

toJSON: serializedPartial,

360+

role: "assistant",

361+

content: [{ type: "text", text: "a".repeat(200_000) }],

362+

},

363+

};

364+

yield {

365+

type: "text_delta",

366+

contentIndex: 0,

367+

delta: "bc",

368+

partial: {

369+

toJSON: serializedPartial,

370+

role: "assistant",

371+

content: [{ type: "text", text: "abc".repeat(200_000) }],

372+

},

373+

};

374+

}

375+

const wrapped = wrapStreamFnWithDiagnosticModelCallEvents(

376+

(() => stream()) as unknown as StreamFn,

377+

{

378+

runId: "run-1",

379+

provider: "openai",

380+

model: "gpt-5.4",

381+

trace: createDiagnosticTraceContext(),

382+

nextCallId: () => "call-delta-bytes",

383+

},

384+

);

385+386+

const events = await collectModelCallEvents(async () => {

387+

await drain(wrapped({} as never, {} as never, {} as never) as AsyncIterable<unknown>);

388+

});

389+390+

const completedEvent = getEvent(events, 1);

391+

expect(completedEvent.type).toBe("model.call.completed");

392+

expect(completedEvent.responseStreamBytes).toBe(

393+

Buffer.byteLength(

394+

JSON.stringify({ type: "text_delta", contentIndex: 0, delta: "a" }),

395+

"utf8",

396+

) +

397+

Buffer.byteLength(

398+

JSON.stringify({ type: "text_delta", contentIndex: 0, delta: "bc" }),

399+

"utf8",

400+

),

401+

);

402+

expect(serializedPartial).not.toHaveBeenCalled();

403+

});

404+405+

it("keeps streams alive when diagnostic byte inspection cannot read a chunk", async () => {

406+

const opaqueChunk = new Proxy(

407+

{},

408+

{

409+

get(_target, property) {

410+

if (property === "then") {

411+

return undefined;

412+

}

413+

throw new Error("chunk should not be inspected");

414+

},

415+

},

416+

);

417+

async function* stream() {

418+

yield opaqueChunk;

419+

yield { type: "text_delta", delta: "ok" };

420+

}

421+

const wrapped = wrapStreamFnWithDiagnosticModelCallEvents(

422+

(() => stream()) as unknown as StreamFn,

423+

{

424+

runId: "run-1",

425+

provider: "openai",

426+

model: "gpt-5.4",

427+

trace: createDiagnosticTraceContext(),

428+

nextCallId: () => "call-opaque-chunk",

429+

},

430+

);

431+432+

const chunks: unknown[] = [];

433+

const events = await collectModelCallEvents(async () => {

434+

for await (const chunk of wrapped(

435+

{} as never,

436+

{} as never,

437+

{} as never,

438+

) as AsyncIterable<unknown>) {

439+

chunks.push(chunk);

440+

}

441+

});

442+443+

expect(chunks).toHaveLength(2);

444+

expect(chunks[0]).toBe(opaqueChunk);

445+

expect(chunks[1]).toEqual({ type: "text_delta", delta: "ok" });

446+

const completedEvent = getEvent(events, 1);

447+

expect(completedEvent.type).toBe("model.call.completed");

448+

expect(completedEvent.responseStreamBytes).toBe(

449+

Buffer.byteLength(JSON.stringify({ type: "text_delta", delta: "ok" }), "utf8"),

450+

);

451+

});

452+349453

it("captures model input, tools, and output only when content capture is enabled", async () => {

350454

const assistant = {

351455

role: "assistant",