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

推荐订阅源

博客园 - 三生石上(FineUI控件)
博客园 - Franky
GbyAI
GbyAI
B
Blog
WordPress大学
WordPress大学
D
Docker
小众软件
小众软件
月光博客
月光博客
博客园 - 【当耐特】
T
The Blog of Author Tim Ferriss
IT之家
IT之家
腾讯CDC
Engineering at Meta
Engineering at Meta
Vercel News
Vercel News
H
Help Net Security
M
MIT News - Artificial intelligence
L
LangChain Blog
云风的 BLOG
云风的 BLOG
S
SegmentFault 最新的问题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
美团技术团队
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V
V2EX
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

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): bound OpenRouter model catalog response read...
Alix-007 · 2026-06-23 · via Recent Commits to openclaw:main

@@ -312,6 +312,104 @@ describe("openrouter-model-capabilities", () => {

312312

});

313313

});

314314315+

it("bounds an oversized streamed OpenRouter catalog instead of buffering it whole", async () => {

316+

await withOpenRouterStateDir(async () => {

317+

// First pull emits a chunk larger than the cap; a well-behaved bounded read

318+

// must cancel before requesting the (effectively infinite) second chunk.

319+

let pullCount = 0;

320+

const cancel = vi.fn(async () => undefined);

321+

const stream = new ReadableStream<Uint8Array>({

322+

pull(controller) {

323+

pullCount += 1;

324+

controller.enqueue(new Uint8Array(pullCount === 1 ? 16 * 1024 * 1024 + 1 : 1));

325+

},

326+

cancel,

327+

});

328+

const fetchSpy = vi.fn(

329+

async () =>

330+

new Response(stream, {

331+

status: 200,

332+

headers: { "content-type": "application/json" },

333+

}),

334+

);

335+

vi.stubGlobal("fetch", fetchSpy);

336+337+

const module = await importOpenRouterModelCapabilities("oversized-stream");

338+

await module.loadOpenRouterModelCapabilities("acme/anything");

339+340+

// The body was cancelled after the first oversized chunk rather than read

341+

// to completion, and the overflow left no poisoned cache entry behind.

342+

expect(fetchSpy).toHaveBeenCalledTimes(1);

343+

expect(pullCount).toBeLessThanOrEqual(2);

344+

expect(cancel).toHaveBeenCalledOnce();

345+

expect(module.getOpenRouterModelCapabilities("acme/anything")).toBeUndefined();

346+

expect(fetchSpy).toHaveBeenCalledTimes(1);

347+

});

348+

});

349+350+

it("round-trips a chunked under-cap catalog through the SQLite cache", async () => {

351+

await withOpenRouterStateDir(async () => {

352+

// Stream the payload across several small chunks so the bounded reader has to

353+

// reassemble it; the reassembled bytes must parse and survive a cross-import

354+

// SQLite read-back identical to the source catalog.

355+

const payload = JSON.stringify({

356+

data: [

357+

{

358+

id: "acme/chunked-model",

359+

name: "Chunked Model",

360+

architecture: { modality: "text+image->text" },

361+

supported_parameters: ["reasoning", "tools"],

362+

context_length: 13579,

363+

max_completion_tokens: 2468,

364+

pricing: { prompt: "0.000007", completion: "0.000008" },

365+

},

366+

],

367+

});

368+

const encoded = new TextEncoder().encode(payload);

369+

const fetchSpy = vi.fn(async () => {

370+

let offset = 0;

371+

const stream = new ReadableStream<Uint8Array>({

372+

pull(controller) {

373+

if (offset >= encoded.length) {

374+

controller.close();

375+

return;

376+

}

377+

const end = Math.min(offset + 8, encoded.length);

378+

controller.enqueue(encoded.subarray(offset, end));

379+

offset = end;

380+

},

381+

});

382+

return new Response(stream, {

383+

status: 200,

384+

headers: { "content-type": "application/json" },

385+

});

386+

});

387+

vi.stubGlobal("fetch", fetchSpy);

388+389+

const writer = await importOpenRouterModelCapabilities("chunked-sqlite-writer");

390+

await writer.loadOpenRouterModelCapabilities("acme/chunked-model");

391+

expect(fetchSpy).toHaveBeenCalledTimes(1);

392+

expect(writer.getOpenRouterModelCapabilities("acme/chunked-model")).toMatchObject({

393+

input: ["text", "image"],

394+

reasoning: true,

395+

supportsTools: true,

396+

contextWindow: 13579,

397+

maxTokens: 2468,

398+

});

399+400+

// Fresh import reads only from the SQLite cache the bounded read populated.

401+

const reader = await importOpenRouterModelCapabilities("chunked-sqlite-reader");

402+

expect(reader.getOpenRouterModelCapabilities("acme/chunked-model")).toMatchObject({

403+

input: ["text", "image"],

404+

reasoning: true,

405+

supportsTools: true,

406+

contextWindow: 13579,

407+

maxTokens: 2468,

408+

});

409+

expect(fetchSpy).toHaveBeenCalledTimes(1);

410+

});

411+

});

412+315413

it("does not refetch immediately after an awaited miss for the same model id", async () => {

316414

await withOpenRouterStateDir(async () => {

317415

const fetchSpy = vi.fn(