Skip to content

Incorrect delta AI credits (and therefore running total AI Credits) shown in token usage #43034

Description

@cknight

Possibly related to #39837, the AI credits shown in the Token Usage output do not take into account the cached tokens. Below is a real example.

On turn 1, it correctly computes the cost of the turn, which uses 0 cached tokens obviously, as 6.57 AI Credits.

On turn 2, it computes the delta AI credits as per follows:
27369 Input tokens ($2.5/million): 6.84 AIC
264 Output tokens ($15/million): 0.396 AIC
22528 cached read tokens ($0.25/million): 0.563 AIC

If we add the three together we get the 7.8 AIC shown in the delta in the screenshot, however a majority of those inputs tokens were cached and so were double counted (both as fresh input tokens and again as cached tokens). I believe the correct calculation for turn 2 delta should be, the new inputs tokens, plus cached tokens, plus output tokens. In this case, 4640 new input tokens (27369 turn 2 input tokens - 22528 cached tokens) which is 1.21 AIC, plus cached read tokens which is 0.563 AIC, plus output tokens which is 0.396 AIC for a total delta of 2.1 AIC, not the 7.8 shown.

This double counting compounds down the way on every turn to give a much higher AI Credit spend than was actually incurred.

Copilot v1.0.65
AWF version v0.27.11
CLI version v0.81.6

Image

Metadata

Metadata

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions