Q73: agent cost counts each call once, for the agent that made it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
90b7306aee
commit
844607eae9
4 files changed
+45
-26
No files matched your search
@@ -0,0 +1,18 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { buildAgentSpend } from "../../src/renderer/src/pages/settings/billing-helpers";
|
||||
import type { AgentRecord, ProviderRequestRecord } from "../../src/shared/domain";
|
||||
|
||||
const agent = (id: string, modelProviderId: string) => ({ id, name: id, modelProviderId, budgetCents: 1000 }) as AgentRecord;
|
||||
const call = (agentId: string | null, providerId: string, costCents: number | null) =>
|
||||
({ agentId, providerId, inputTokens: 100, outputTokens: 50, costCents }) as ProviderRequestRecord;
|
||||
|
||||
describe("billing attribution", () => {
|
||||
test("each call counts once for the agent that made it, not for everyone on the same provider", () => {
|
||||
const rows = buildAgentSpend([agent("ada", "prv_a"), agent("bo", "prv_a"), agent("cy", "prv_b")], [
|
||||
call("ada", "prv_a", 10), call("ada", "prv_a", 5), call("bo", "prv_a", 1), call("cy", "prv_a", 2), call(null, "prv_a", 99),
|
||||
]);
|
||||
expect(rows.map((row) => [row.agent.id, row.requestCount, row.tokens, row.spentCents])).toEqual([
|
||||
["ada", 2, 300, 15], ["cy", 1, 150, 2], ["bo", 1, 150, 1],
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user