From f46396fa9855804563eb081e667c9c0ff14930cb Mon Sep 17 00:00:00 2001 From: Shangjie Chen Date: Tue, 22 Jul 2025 09:34:59 -0700 Subject: [PATCH] chore: Allow httpoptions override in VertexAiSessionService PiperOrigin-RevId: 785886180 --- .../adk/sessions/vertex_ai_session_service.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/google/adk/sessions/vertex_ai_session_service.py b/src/google/adk/sessions/vertex_ai_session_service.py index 3a53b669..12f5312e 100644 --- a/src/google/adk/sessions/vertex_ai_session_service.py +++ b/src/google/adk/sessions/vertex_ai_session_service.py @@ -13,7 +13,6 @@ # limitations under the License. from __future__ import annotations -import asyncio import json import logging import os @@ -351,16 +350,24 @@ class VertexAiSessionService(BaseSessionService): return match.groups()[-1] + def _api_client_http_options_override( + self, + ) -> Optional[genai.types.HttpOptions]: + return None + def _get_api_client(self): """Instantiates an API client for the given project and location. It needs to be instantiated inside each request so that the event loop management can be properly propagated. """ - client = genai.Client( + api_client = genai.Client( vertexai=True, project=self._project, location=self._location - ) - return client._api_client + )._api_client + + if new_options := self._api_client_http_options_override(): + api_client._http_options = new_options + return api_client def _is_vertex_express_mode(