feat(core): update Copilot for token-based billing (#30181)

This commit is contained in:
Aiden Cline
2026-06-01 14:55:23 -05:00
committed by GitHub
parent fa23fb5d38
commit ae92f3158f
10 changed files with 340 additions and 77 deletions

View File

@@ -1674,6 +1674,20 @@ describe("SessionNs.getUsage", () => {
expect(result.cost).toBe(3 + 1.5)
})
test("uses authoritative Copilot billed cost when provided", () => {
const result = SessionNs.getUsage({
model: createModel({
context: 100_000,
output: 32_000,
cost: { input: 3, output: 15, cache: { read: 0.3, write: 0.3 } },
}),
usage: usage({ inputTokens: 11_774, outputTokens: 39, totalTokens: 11_813 }),
metadata: { copilot: { totalNanoAiu: 4_473_525_000 } },
})
expect(result.cost).toBe(0.04473525)
})
test("uses matching context cost tier before over-200k fallback", () => {
const model = createModel({
context: 1_000_000,