From be596c3babff171c316bb0e0394f40ed93fff7b9 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Wed, 28 Oct 2026 21:11:33 -0700 Subject: [PATCH] fix(responses): unwrap nested comparison ids in a loop instead of recursion --- litellm/proxy/hooks/responses_id_security.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/hooks/responses_id_security.py b/litellm/proxy/hooks/responses_id_security.py index 1f2ca61b14c..14a870bfd12 100644 --- a/litellm/proxy/hooks/responses_id_security.py +++ b/litellm/proxy/hooks/responses_id_security.py @@ -130,8 +130,10 @@ def _with_comparison_response_id(options: object, comparison_response_id: str) - def _innermost_response_id(response_id: str) -> str: - decoded: Final = ResponsesAPIRequestUtils.decode_exact_responses_api_response_id(response_id) - return response_id if decoded is None else _innermost_response_id(decoded.get("response_id", response_id)) + innermost = response_id # rebind-ok: peels one wrapper layer per pass instead of recursing + while (decoded := ResponsesAPIRequestUtils.decode_exact_responses_api_response_id(innermost)) is not None: + innermost = decoded.get("response_id", innermost) + return innermost def _is_responses_api_create_route(request_route: str | None) -> bool: