diff --git a/litellm/responses/mcp/chat_completions_handler.py b/litellm/responses/mcp/chat_completions_handler.py index 73dba5ba441..b914bb1e4aa 100644 --- a/litellm/responses/mcp/chat_completions_handler.py +++ b/litellm/responses/mcp/chat_completions_handler.py @@ -453,9 +453,7 @@ async def acompletion_with_mcp( ) # Make follow-up call with streaming - follow_up_call_args: Final = LiteLLM_Proxy_MCP_Handler._prepare_follow_up_call_params( - self.base_call_args - ) + follow_up_call_args: Final = LiteLLM_Proxy_MCP_Handler._prepare_chained_call_params(self.base_call_args) follow_up_call_args["messages"] = follow_up_messages follow_up_call_args["stream"] = True # Ensure follow-up call doesn't trigger MCP handler again @@ -627,7 +625,7 @@ async def acompletion_with_mcp( ) # Make follow-up call with original stream setting - follow_up_call_args: Final = LiteLLM_Proxy_MCP_Handler._prepare_follow_up_call_params(base_call_args) + follow_up_call_args: Final = LiteLLM_Proxy_MCP_Handler._prepare_chained_call_params(base_call_args) follow_up_call_args["messages"] = follow_up_messages follow_up_call_args["stream"] = stream diff --git a/litellm/responses/mcp/litellm_proxy_mcp_handler.py b/litellm/responses/mcp/litellm_proxy_mcp_handler.py index 46bb067eeeb..d72f335e89c 100644 --- a/litellm/responses/mcp/litellm_proxy_mcp_handler.py +++ b/litellm/responses/mcp/litellm_proxy_mcp_handler.py @@ -72,7 +72,7 @@ class LiteLLM_Proxy_MCP_Handler: """ @staticmethod - def _prepare_follow_up_call_params(params: Mapping[str, Any]) -> dict[str, Any]: + def _prepare_chained_call_params(params: Mapping[str, Any]) -> dict[str, Any]: """Copy request params without state owned by the previous LLM call. MCP auto-execution keeps the trace identifier so chained rounds remain diff --git a/litellm/responses/mcp/mcp_streaming_iterator.py b/litellm/responses/mcp/mcp_streaming_iterator.py index 69e698f7f65..1e1cbd34ce2 100644 --- a/litellm/responses/mcp/mcp_streaming_iterator.py +++ b/litellm/responses/mcp/mcp_streaming_iterator.py @@ -782,7 +782,7 @@ class MCPEnhancedStreamingIterator(BaseResponsesAPIStreamingIterator): ) # Make follow-up call with streaming - follow_up_params: Final = LiteLLM_Proxy_MCP_Handler._prepare_follow_up_call_params( + follow_up_params: Final = LiteLLM_Proxy_MCP_Handler._prepare_chained_call_params( self.original_request_params ) follow_up_params.update( diff --git a/tests/test_litellm/responses/mcp/test_litellm_proxy_mcp_handler.py b/tests/test_litellm/responses/mcp/test_litellm_proxy_mcp_handler.py index 429adb2962d..c552170a599 100644 --- a/tests/test_litellm/responses/mcp/test_litellm_proxy_mcp_handler.py +++ b/tests/test_litellm/responses/mcp/test_litellm_proxy_mcp_handler.py @@ -444,7 +444,7 @@ async def test_execute_tool_calls_uses_unique_call_ids_and_preserves_parent_cont assert all(item["metadata"]["parent_litellm_call_id"] == "cid" for item in captured) -def test_prepare_follow_up_call_params_resets_per_call_logging_state(): +def test_prepare_chained_call_params_resets_per_call_logging_state(): original = { "model": "gpt-4", "litellm_call_id": "parent-call", @@ -457,7 +457,7 @@ def test_prepare_follow_up_call_params_resets_per_call_logging_state(): }, } - follow_up = LiteLLM_Proxy_MCP_Handler._prepare_follow_up_call_params(original) + follow_up = LiteLLM_Proxy_MCP_Handler._prepare_chained_call_params(original) assert "litellm_call_id" not in follow_up assert "litellm_logging_obj" not in follow_up