fix: write overhead to dict-typed responses via key assignment

TypedDict responses (e.g. AnthropicMessagesResponse) are plain
dicts at runtime, so hasattr(response, "_hidden_params") returns
False. Also assign via response["_hidden_params"] for dict types.
This commit is contained in:
factnn 2026-07-04 15:54:07 +08:00
parent 321e98147f
commit faf9133ea3

View file

@ -1448,6 +1448,8 @@ class ProxyBaseLLMRequestProcessing:
_overhead_hidden_params["litellm_overhead_time_ms"] = overhead_ms
if hasattr(response, "_hidden_params"):
response._hidden_params = _overhead_hidden_params
elif isinstance(response, dict):
response["_hidden_params"] = _overhead_hidden_params
_exception_raised = False
try: