From 0f36b8afc2ffbdc6854a83462480be586be6b3c8 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 22 Mar 2025 17:36:22 -0700 Subject: [PATCH] chat_completion_response_includes_annotations --- .../llm_cost_calc/tool_call_cost_tracking.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/litellm/litellm_core_utils/llm_cost_calc/tool_call_cost_tracking.py b/litellm/litellm_core_utils/llm_cost_calc/tool_call_cost_tracking.py index 93e5be63110..594b59989ae 100644 --- a/litellm/litellm_core_utils/llm_cost_calc/tool_call_cost_tracking.py +++ b/litellm/litellm_core_utils/llm_cost_calc/tool_call_cost_tracking.py @@ -104,7 +104,12 @@ class StandardBuiltInToolCostTracking: ) -> bool: for _choice in response_object.choices: message = getattr(_choice, "message", None) - if message is not None and hasattr(message, "annotations"): + if ( + message is not None + and hasattr(message, "annotations") + and message.annotations is not None + and len(message.annotations) > 0 + ): return True return False