From 067ded1af4f9f52184644b3f76b42255e44afa95 Mon Sep 17 00:00:00 2001 From: shin-bot-litellm Date: Sat, 31 Jan 2026 21:45:44 +0000 Subject: [PATCH] fix(test): correct prompt_tokens in test_string_cost_values to match token details The test was failing because prompt_tokens (1000) didn't match the sum of detail tokens (700 + 100 + 200 + 150 = 1150). This triggered the double-counting detection in generic_cost_per_token, which recalculated text_tokens as 550 instead of 700, causing the cost assertion to fail. Fix: - prompt_tokens: 1000 -> 1150 - total_tokens: 1500 -> 1650 - Added comment explaining the token sum requirement Fixes: litellm_mapped_tests_litellm_core_utils CI failure --- .../llm_cost_calc/test_llm_cost_calc_utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_litellm/litellm_core_utils/llm_cost_calc/test_llm_cost_calc_utils.py b/tests/test_litellm/litellm_core_utils/llm_cost_calc/test_llm_cost_calc_utils.py index 5ba78d9eed1..b2442307a95 100644 --- a/tests/test_litellm/litellm_core_utils/llm_cost_calc/test_llm_cost_calc_utils.py +++ b/tests/test_litellm/litellm_core_utils/llm_cost_calc/test_llm_cost_calc_utils.py @@ -313,10 +313,12 @@ def test_string_cost_values(): } # Test usage with various token types + # Note: prompt_tokens must equal the sum of all detail tokens to avoid double-counting adjustment + # text_tokens(700) + audio_tokens(100) + cached_tokens(200) + cache_creation_tokens(150) = 1150 usage = Usage( - prompt_tokens=1000, + prompt_tokens=1150, completion_tokens=500, - total_tokens=1500, + total_tokens=1650, prompt_tokens_details=PromptTokensDetailsWrapper( audio_tokens=100, cached_tokens=200, text_tokens=700, image_tokens=None, cache_creation_tokens=150 ),