Skip to content

Commit 7479e9c

Browse files
committed
test(usage): assert worker monetary result metadata
1 parent 5343211 commit 7479e9c

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

‎src/gateway/worker-environments/worker-turn-launcher-terminal-results.test.ts‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,11 @@ describe("worker turn launcher terminal results", () => {
133133
visibleText?: string;
134134
rawText?: string;
135135
terminalReply: AgentRunTerminalReplySnapshot;
136+
costs?: { first: number; last: number; total: number };
136137
}>([
137138
{
138139
name: "visible final answer",
140+
costs: { first: 0.125, last: 0.25, total: 0.375 },
139141
content: [
140142
{ type: "thinking", thinking: "Private reasoning" },
141143
{
@@ -184,7 +186,13 @@ describe("worker turn launcher terminal results", () => {
184186
},
185187
])(
186188
"reports canonical usage and $name",
187-
async ({ content, visibleText, rawText, terminalReply }) => {
189+
async ({
190+
content,
191+
visibleText,
192+
rawText,
193+
terminalReply,
194+
costs = { first: 0, last: 0, total: 0 },
195+
}) => {
188196
seedActivePlacement();
189197
const environments: WorkerTurnEnvironmentService = {
190198
get: vi.fn(() => attachedEnvironment()),
@@ -215,7 +223,7 @@ describe("worker turn launcher terminal results", () => {
215223
cacheRead: 20,
216224
cacheWrite: 5,
217225
totalTokens: 135,
218-
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
226+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: costs.first },
219227
},
220228
}),
221229
);
@@ -244,7 +252,7 @@ describe("worker turn launcher terminal results", () => {
244252
totalTokens: 270,
245253
},
246254
totalTokens: 270,
247-
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
255+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: costs.last },
248256
},
249257
}),
250258
);
@@ -309,12 +317,14 @@ describe("worker turn launcher terminal results", () => {
309317
sessionFile,
310318
provider: "anthropic",
311319
model: "claude-reported",
320+
costUsd: costs.total,
312321
usage: {
313322
input: 300,
314323
output: 40,
315324
cacheRead: 60,
316325
cacheWrite: 5,
317326
total: 405,
327+
cost: { total: costs.total },
318328
},
319329
lastCallUsage: {
320330
input: 200,
@@ -327,6 +337,7 @@ describe("worker turn launcher terminal results", () => {
327337
totalTokens: 270,
328338
},
329339
total: 270,
340+
cost: { total: costs.last },
330341
},
331342
promptTokens: 240,
332343
});

0 commit comments

Comments
 (0)