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

推荐订阅源

T
The Blog of Author Tim Ferriss
WordPress大学
WordPress大学
博客园 - Franky
The Cloudflare Blog
T
Tailwind CSS Blog
宝玉的分享
宝玉的分享
小众软件
小众软件
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
B
Blog
Y
Y Combinator Blog
V
V2EX
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
博客园 - 司徒正美
IT之家
IT之家
G
Google Developers Blog
C
Check Point Blog
Engineering at Meta
Engineering at Meta
Microsoft Security Blog
Microsoft Security Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
GbyAI
GbyAI
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(agent): default missing model cost metadata · opencla...
steipete · 2026-05-01 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -254,6 +254,38 @@ describe("resolveModel", () => {

254254

expect(result.model?.input).toEqual(["text"]);

255255

});

256256
257+

it("defaults missing model cost before handing models to PI", () => {

258+

const cfg = {

259+

models: {

260+

providers: {

261+

openai: {

262+

api: "openai-responses",

263+

models: [

264+

{

265+

id: "gpt-5.5",

266+

name: "GPT-5.5",

267+

api: "openai-responses",

268+

reasoning: true,

269+

input: ["text"],

270+

contextWindow: 400_000,

271+

maxTokens: 128_000,

272+

},

273+

],

274+

},

275+

},

276+

},

277+

} as unknown as OpenClawConfig;

278+
279+

const result = resolveModelForTest("openai", "gpt-5.5", "/tmp/agent", cfg);

280+
281+

expect(result.error).toBeUndefined();

282+

expect(result.model).toMatchObject({

283+

provider: "openai",

284+

id: "gpt-5.5",

285+

cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },

286+

});

287+

});

288+
257289

it("includes provider baseUrl in fallback model", () => {

258290

const cfg = {

259291

models: {

Original file line numberDiff line numberDiff line change

@@ -190,6 +190,40 @@ function normalizeResolvedModel(params: {

190190

agentDir?: string;

191191

runtimeHooks?: ProviderRuntimeHooks;

192192

}): Model<Api> {

193+

const normalizeModelCost = (cost: unknown): Model<Api>["cost"] => {

194+

if (!cost || typeof cost !== "object" || Array.isArray(cost)) {

195+

return { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };

196+

}

197+

const record = cost as Partial<Model<Api>["cost"]>;

198+

const input =

199+

typeof record.input === "number" && Number.isFinite(record.input) ? record.input : 0;

200+

const output =

201+

typeof record.output === "number" && Number.isFinite(record.output) ? record.output : 0;

202+

const cacheRead =

203+

typeof record.cacheRead === "number" && Number.isFinite(record.cacheRead)

204+

? record.cacheRead

205+

: 0;

206+

const cacheWrite =

207+

typeof record.cacheWrite === "number" && Number.isFinite(record.cacheWrite)

208+

? record.cacheWrite

209+

: 0;

210+

if (

211+

input === record.input &&

212+

output === record.output &&

213+

cacheRead === record.cacheRead &&

214+

cacheWrite === record.cacheWrite

215+

) {

216+

return record as Model<Api>["cost"];

217+

}

218+

return {

219+

...cost,

220+

input,

221+

output,

222+

cacheRead,

223+

cacheWrite,

224+

};

225+

};

226+
193227

const normalizedInputModel = {

194228

...params.model,

195229

input: resolveProviderModelInput({

@@ -198,6 +232,7 @@ function normalizeResolvedModel(params: {

198232

modelName: params.model.name,

199233

input: params.model.input,

200234

}),

235+

cost: normalizeModelCost((params.model as { cost?: unknown }).cost),

201236

} as Model<Api>;

202237

const runtimeHooks = params.runtimeHooks ?? DEFAULT_PROVIDER_RUNTIME_HOOKS;

203238

const pluginNormalized = runtimeHooks.normalizeProviderResolvedModelWithPlugin({