From e814f12995aa1f6f22d4a67fd8fca83a6a4fc20c Mon Sep 17 00:00:00 2001 From: Maycon Santos Date: Fri, 24 Jul 2026 02:59:22 +0000 Subject: [PATCH] [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. --- e2e/agentnetwork/chat_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/e2e/agentnetwork/chat_test.go b/e2e/agentnetwork/chat_test.go index 7d4c70dc6..36f5afc15 100644 --- a/e2e/agentnetwork/chat_test.go +++ b/e2e/agentnetwork/chat_test.go @@ -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