mirror of
https://github.com/netbirdio/netbird.git
synced 2026-07-28 02:12:33 -04:00
[e2e] allow zero input_tokens on cache-heavy providers in cost validation
Run 30061545790 validated 7/8 providers exactly; the kimi subtest failed only on the test's own input_tokens>0 precondition. Moonshot's Anthropic-compatible endpoint reports the whole prompt under the cache-read bucket (input_tokens=0, 90 cache tokens riding total_tokens), and the stored cost was exactly right: 64 out x $15/M + 90 cache-read x $0.30/M = $0.000987. Require positive output/total tokens instead and let the existing cache-aware bounds cover the zero-input shape.
This commit is contained in:
@@ -64,8 +64,12 @@ func validateAccessLogCost(t *testing.T, pc providerCase, row api.AgentNetworkAc
|
||||
return
|
||||
}
|
||||
|
||||
require.Positive(t, row.InputTokens, "priced row must carry input tokens")
|
||||
// input_tokens may legitimately be 0: providers that cache aggressively
|
||||
// (Moonshot/Kimi reports the whole prompt under the cache-read bucket)
|
||||
// leave the non-cached input at zero, with the prompt riding total_tokens.
|
||||
// Output and total must always be present on a priced row.
|
||||
require.Positive(t, row.OutputTokens, "priced row must carry output tokens")
|
||||
require.Positive(t, row.TotalTokens, "priced row must carry total tokens")
|
||||
|
||||
base := float64(row.InputTokens)/1000*rates.in + float64(row.OutputTokens)/1000*rates.out
|
||||
|
||||
|
||||
Reference in New Issue
Block a user