From a14daf18d6ebbe399ec271207a9ea7f9124155b8 Mon Sep 17 00:00:00 2001 From: shivam Date: Thu, 27 Aug 2026 23:19:17 +0000 Subject: [PATCH] refactor(agentic-loop): narrow logging_obj before building the fake stream wrapper Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/litellm_core_utils/chat_completion_agentic_loop.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/litellm/litellm_core_utils/chat_completion_agentic_loop.py b/litellm/litellm_core_utils/chat_completion_agentic_loop.py index a5f5c6ac68f..c8e9e2583ba 100644 --- a/litellm/litellm_core_utils/chat_completion_agentic_loop.py +++ b/litellm/litellm_core_utils/chat_completion_agentic_loop.py @@ -10,6 +10,8 @@ from litellm.litellm_core_utils.agentic_loop_settings import ( DEFAULT_MAX_AGENTIC_LOOPS, validated_max_agentic_loops, ) +from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObject +from litellm.llms.base_llm.base_model_iterator import MockResponseIterator from litellm.types.integrations.custom_logger import ( CHAT_COMPLETION_AGENTIC_SURFACE, HEADROOM_CONVERTED_STREAM_KEY, @@ -104,9 +106,8 @@ def _wrap_response_as_fake_stream( ) -> object: if isinstance(response, CustomStreamWrapper): return response - if not isinstance(response, ModelResponse): + if not isinstance(response, ModelResponse) or not isinstance(logging_obj, LiteLLMLoggingObject): return response - from litellm.llms.base_llm.base_model_iterator import MockResponseIterator return CustomStreamWrapper( completion_stream=MockResponseIterator(model_response=response),