From 6898b88439f2032224acc734f94595f47aa5d1ca Mon Sep 17 00:00:00 2001 From: michelligabriele Date: Mon, 9 Mar 2026 18:11:58 +0100 Subject: [PATCH] fix(proxy): use class identity for signature cache key Key the _CALLBACK_ACCEPTS_CALL_INFO cache by id(type(cb)) instead of id(cb) to avoid stale entries from Python address reuse after GC. All instances of the same callback class share the same method signature, so class identity is both safer and more cache-efficient. --- litellm/proxy/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index 6421d2ca704..2cd2b1d93bd 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -292,7 +292,7 @@ _CALLBACK_ACCEPTS_CALL_INFO: Dict[int, bool] = {} def _accepts_litellm_call_info(cb: CustomLogger) -> bool: - key = id(cb) + key = id(type(cb)) if key not in _CALLBACK_ACCEPTS_CALL_INFO: sig = inspect.signature(cb.async_post_call_response_headers_hook) _CALLBACK_ACCEPTS_CALL_INFO[key] = "litellm_call_info" in sig.parameters