\fix(logging): keep uncomputed hidden cost silent while falling through to calculator"

This commit is contained in:
onatozmenn 2026-09-23 11:55:52 +03:00
parent 59c53898da
commit e4da6304f2
No known key found for this signature in database

View file

@ -2405,7 +2405,16 @@ class Logging(LiteLLMLoggingBaseClass):
# Do not preserve 0 from failure_handler on intermediate router retries.
pass
else:
self.model_call_details["response_cost"] = self._response_cost_calculator(result=logging_result)
if "response_cost" in hidden_params:
warned = self.zero_cost_warned
self.zero_cost_warned = True
try:
self.model_call_details["response_cost"] = self._response_cost_calculator(result=logging_result)
finally:
self.model_call_details["zero_cost_diagnostic"] = None
self.zero_cost_warned = warned
else:
self.model_call_details["response_cost"] = self._response_cost_calculator(result=logging_result)
if not build_logging_payload:
return