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

推荐订阅源

aimingoo的专栏
aimingoo的专栏
雷峰网
雷峰网
博客园 - 叶小钗
V
V2EX
博客园 - Franky
博客园_首页
小众软件
小众软件
Microsoft Security Blog
Microsoft Security Blog
The GitHub Blog
The GitHub Blog
A
About on SuperTechFans
H
Hackread – Cybersecurity News, Data Breaches, AI and More
阮一峰的网络日志
阮一峰的网络日志
WordPress大学
WordPress大学
Blog — PlanetScale
Blog — PlanetScale
J
Java Code Geeks
T
The Blog of Author Tim Ferriss
U
Unit 42
Microsoft Azure Blog
Microsoft Azure Blog
月光博客
月光博客
S
SegmentFault 最新的问题
B
Blog RSS Feed
博客园 - 【当耐特】
D
Docker
N
Netflix TechBlog - Medium

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(ui): scope usage by agent filter · openclaw/openclaw@...
Alix-007 · 2026-05-29 · via Recent Commits to openclaw:main

@@ -12,13 +12,25 @@ vi.mock("../../infra/session-cost-usage.js", async () => {

1212

startDate: "2026-02-01",

1313

endDate: "2026-02-02",

1414

daily: [],

15-

totals: { totalTokens: 1, input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalCost: 0 },

15+

totals: {

16+

input: 0,

17+

output: 0,

18+

cacheRead: 0,

19+

cacheWrite: 0,

20+

totalTokens: 1,

21+

totalCost: 0,

22+

inputCost: 0,

23+

outputCost: 0,

24+

cacheReadCost: 0,

25+

cacheWriteCost: 0,

26+

missingCostEntries: 0,

27+

},

1628

})),

1729

};

1830

});

19312032

import { loadCostUsageSummaryFromCache } from "../../infra/session-cost-usage.js";

21-

import { testApi } from "./usage.js";

33+

import { testApi, usageHandlers } from "./usage.js";

22342335

describe("gateway usage helpers", () => {

2436

const dayMs = 24 * 60 * 60 * 1000;

@@ -161,4 +173,78 @@ describe("gateway usage helpers", () => {

161173

"background",

162174

);

163175

});

176+177+

it("keeps cost usage cache entries scoped by agentId", async () => {

178+

const config = {} as OpenClawConfig;

179+180+

await testApi.loadCostUsageSummaryCached({

181+

startMs: 1,

182+

endMs: 2,

183+

config,

184+

agentId: "main",

185+

});

186+

await testApi.loadCostUsageSummaryCached({

187+

startMs: 1,

188+

endMs: 2,

189+

config,

190+

agentId: "research",

191+

});

192+

await testApi.loadCostUsageSummaryCached({

193+

startMs: 1,

194+

endMs: 2,

195+

config,

196+

agentId: "research",

197+

});

198+199+

expect(vi.mocked(loadCostUsageSummaryFromCache)).toHaveBeenCalledTimes(2);

200+

expect(vi.mocked(loadCostUsageSummaryFromCache).mock.calls.at(0)?.[0]).toMatchObject({

201+

agentId: "main",

202+

});

203+

expect(vi.mocked(loadCostUsageSummaryFromCache).mock.calls.at(1)?.[0]).toMatchObject({

204+

agentId: "research",

205+

});

206+

});

207+208+

it("passes usage.cost agentId through to the cost summary loader", async () => {

209+

const respond = vi.fn();

210+211+

await usageHandlers["usage.cost"]({

212+

respond,

213+

params: { startDate: "2026-02-01", endDate: "2026-02-02", agentId: "research" },

214+

context: { getRuntimeConfig: () => ({}) },

215+

} as unknown as Parameters<(typeof usageHandlers)["usage.cost"]>[0]);

216+217+

expect(respond).toHaveBeenCalledWith(true, expect.any(Object), undefined);

218+

expect(vi.mocked(loadCostUsageSummaryFromCache)).toHaveBeenCalledWith(

219+

expect.objectContaining({ agentId: "research" }),

220+

);

221+

});

222+223+

it("passes usage.cost all-agent scope through to all configured agent loaders", async () => {

224+

const respond = vi.fn();

225+226+

await usageHandlers["usage.cost"]({

227+

respond,

228+

params: { startDate: "2026-02-01", endDate: "2026-02-02", agentScope: "all" },

229+

context: {

230+

getRuntimeConfig: () => ({

231+

agents: { list: [{ id: "main" }, { id: "research" }] },

232+

}),

233+

},

234+

} as unknown as Parameters<(typeof usageHandlers)["usage.cost"]>[0]);

235+236+

expect(respond).toHaveBeenCalledWith(

237+

true,

238+

expect.objectContaining({

239+

totals: expect.objectContaining({ totalTokens: 2 }),

240+

}),

241+

undefined,

242+

);

243+

expect(vi.mocked(loadCostUsageSummaryFromCache)).toHaveBeenCalledWith(

244+

expect.objectContaining({ agentId: "main" }),

245+

);

246+

expect(vi.mocked(loadCostUsageSummaryFromCache)).toHaveBeenCalledWith(

247+

expect.objectContaining({ agentId: "research" }),

248+

);

249+

});

164250

});