@@ -951,3 +951,63 @@ async def test_fingerprint_only_metadata_transitions_to_active_cache(
951951 assert result_2 .contents_count == 3 # Preserved from prefix
952952 assert result_2 .invocations_used == 1
953953 self .manager .genai_client .aio .caches .create .assert_called_once ()
954+
955+ async def test_create_http_options_passthrough (self ):
956+ """Test that create_http_options is passed through to cache creation config."""
957+ mock_cached_content = AsyncMock ()
958+ mock_cached_content .name = (
959+ "projects/test/locations/us-central1/cachedContents/test123"
960+ )
961+ self .manager .genai_client .aio .caches .create = AsyncMock (
962+ return_value = mock_cached_content
963+ )
964+
965+ # Create config with http_options (e.g. 10s timeout)
966+ http_options = types .HttpOptions (timeout = 10000 )
967+ cache_config_with_timeout = ContextCacheConfig (
968+ cache_intervals = 10 ,
969+ ttl_seconds = 1800 ,
970+ min_tokens = 0 ,
971+ create_http_options = http_options ,
972+ )
973+
974+ llm_request = self .create_llm_request ()
975+ llm_request .cache_config = cache_config_with_timeout
976+
977+ cache_contents_count = max (0 , len (llm_request .contents ) - 1 )
978+
979+ with patch .object (
980+ self .manager , "_generate_cache_fingerprint" , return_value = "test_fp"
981+ ):
982+ await self .manager ._create_gemini_cache (llm_request , cache_contents_count )
983+
984+ # Verify cache creation call includes http_options
985+ create_call = self .manager .genai_client .aio .caches .create .call_args
986+ assert create_call is not None
987+ cache_config = create_call [1 ]["config" ]
988+ assert cache_config .http_options is not None
989+ assert cache_config .http_options .timeout == 10000
990+
991+ async def test_create_without_http_options (self ):
992+ """Test that cache creation works without create_http_options."""
993+ mock_cached_content = AsyncMock ()
994+ mock_cached_content .name = (
995+ "projects/test/locations/us-central1/cachedContents/test123"
996+ )
997+ self .manager .genai_client .aio .caches .create = AsyncMock (
998+ return_value = mock_cached_content
999+ )
1000+
1001+ llm_request = self .create_llm_request ()
1002+ cache_contents_count = max (0 , len (llm_request .contents ) - 1 )
1003+
1004+ with patch .object (
1005+ self .manager , "_generate_cache_fingerprint" , return_value = "test_fp"
1006+ ):
1007+ await self .manager ._create_gemini_cache (llm_request , cache_contents_count )
1008+
1009+ # Verify cache creation call does not include http_options
1010+ create_call = self .manager .genai_client .aio .caches .create .call_args
1011+ assert create_call is not None
1012+ cache_config = create_call [1 ]["config" ]
1013+ assert cache_config .http_options is None
0 commit comments