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

推荐订阅源

WordPress大学
WordPress大学
L
LangChain Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
罗磊的独立博客
J
Java Code Geeks
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 叶小钗
小众软件
小众软件
博客园 - Franky
D
Docker
Google DeepMind News
Google DeepMind News
Microsoft Azure Blog
Microsoft Azure Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
U
Unit 42
宝玉的分享
宝玉的分享
C
Check Point Blog
B
Blog
V
V2EX
博客园 - 三生石上(FineUI控件)
MyScale Blog
MyScale Blog
The Cloudflare 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(gateway): bound pricing catalog streams · openclaw/op...
vincentkoc · 2026-06-20 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -1305,6 +1305,71 @@ describe("model-pricing-cache", () => {

13051305

cacheWrite: 0,

13061306

});

13071307

});

1308+
1309+

it("bounds streamed LiteLLM catalog responses without content-length", async () => {

1310+

const config = {

1311+

agents: {

1312+

defaults: {

1313+

model: { primary: "kimi/kimi-k2.6" },

1314+

},

1315+

},

1316+

} as unknown as OpenClawConfig;

1317+
1318+

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

1319+

let liteLLMPullCount = 0;

1320+

const fetchImpl = withFetchPreconnect(async (input: RequestInfo | URL) => {

1321+

const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;

1322+

if (url.includes("openrouter.ai")) {

1323+

return new Response(

1324+

JSON.stringify({

1325+

data: [

1326+

{

1327+

id: "moonshotai/kimi-k2.6",

1328+

pricing: {

1329+

prompt: "0.00000095",

1330+

completion: "0.000004",

1331+

input_cache_read: "0.00000016",

1332+

},

1333+

},

1334+

],

1335+

}),

1336+

{

1337+

status: 200,

1338+

headers: { "Content-Type": "application/json" },

1339+

},

1340+

);

1341+

}

1342+

return new Response(

1343+

new ReadableStream({

1344+

pull(controller) {

1345+

liteLLMPullCount += 1;

1346+

controller.enqueue(new Uint8Array(liteLLMPullCount === 1 ? 5 * 1024 * 1024 : 1));

1347+

},

1348+

cancel: liteLLMCancel,

1349+

}),

1350+

{

1351+

status: 200,

1352+

headers: { "Content-Type": "application/json" },

1353+

},

1354+

);

1355+

});

1356+
1357+

await refreshGatewayModelPricingCache({ config, fetchImpl });

1358+
1359+

expect(liteLLMPullCount).toBeGreaterThanOrEqual(2);

1360+

expect(liteLLMCancel).toHaveBeenCalledOnce();

1361+

const health = getGatewayModelPricingHealth();

1362+

expect(health.sources[0]?.source).toBe("litellm");

1363+

expect(health.sources[0]?.detail).toContain(

1364+

"LiteLLM pricing response too large: 5242881 bytes",

1365+

);

1366+

expect(getCachedGatewayModelPricing({ provider: "kimi", model: "kimi-k2.6" })).toEqual({

1367+

input: 0.95,

1368+

output: 4,

1369+

cacheRead: 0.16,

1370+

cacheWrite: 0,

1371+

});

1372+

});

13081373

});

13091374
13101375

function createManifestRecord(overrides: Partial<PluginManifestRecord>): PluginManifestRecord {

Original file line numberDiff line numberDiff line change

@@ -1,6 +1,7 @@

11

// Gateway model-pricing refresh and normalization.

22

// Fetches, normalizes, and schedules cached pricing for model usage estimates.

33

import type { ModelCatalogCost } from "@openclaw/model-catalog-core/model-catalog-types";

4+

import { readResponseWithLimit } from "@openclaw/media-core/read-response-with-limit";

45

import {

56

normalizeOptionalString,

67

resolvePrimaryStringValue,

@@ -289,13 +290,12 @@ async function readPricingJsonObject(

289290

if (contentLength !== null && contentLength > MAX_PRICING_CATALOG_BYTES) {

290291

throw new Error(`${source} pricing response too large: ${contentLength} bytes`);

291292

}

292-

const buffer = await response.arrayBuffer();

293-

if (buffer.byteLength > MAX_PRICING_CATALOG_BYTES) {

294-

throw new Error(`${source} pricing response too large: ${buffer.byteLength} bytes`);

295-

}

293+

const buffer = await readResponseWithLimit(response, MAX_PRICING_CATALOG_BYTES, {

294+

onOverflow: ({ size }) => new Error(`${source} pricing response too large: ${size} bytes`),

295+

});

296296

let payload: unknown;

297297

try {

298-

payload = JSON.parse(Buffer.from(buffer).toString("utf8")) as unknown;

298+

payload = JSON.parse(buffer.toString("utf8")) as unknown;

299299

} catch {

300300

throw new Error(`${source} pricing response is malformed JSON`);

301301

}