Skip to content

Commit e172811

Browse files
sasha-gitgcopybara-github
authored andcommitted
fix: unbreak client closed errors when using vertexai session service
PiperOrigin-RevId: 811911528
1 parent da6f1d3 commit e172811

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ dependencies = [
3838
"google-cloud-spanner>=3.56.0, <4.0.0", # For Spanner database
3939
"google-cloud-speech>=2.30.0, <3.0.0", # For Audio Transcription
4040
"google-cloud-storage>=2.18.0, <3.0.0", # For GCS Artifact service
41-
# TODO: Modify genai version constraint after the connector/client session warning is fixed.
42-
"google-genai>=1.21.1, <1.37.0", # Google GenAI SDK
41+
"google-genai>=1.21.1, <=1.40.0, !=1.37.0, !=1.38.0, !=1.39.0", # Google GenAI SDK
4342
"graphviz>=0.20.2, <1.0.0", # Graphviz for graph rendering
4443
"mcp>=1.8.0, <2.0.0;python_version>='3.10'", # For MCP Toolset
4544
"opentelemetry-api>=1.37.0, <=1.37.0", # OpenTelemetry - limit upper version for sdk and api to not risk breaking changes from unstable _logs package.

src/google/adk/sessions/vertex_ai_session_service.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,15 +371,15 @@ def _api_client_http_options_override(
371371
) -> Optional[genai.types.HttpOptions]:
372372
return None
373373

374-
def _get_api_client(self):
374+
def _get_api_client(self) -> genai.client.BaseApiClient:
375375
"""Instantiates an API client for the given project and location.
376376
377377
It needs to be instantiated inside each request so that the event loop
378378
management can be properly propagated.
379379
"""
380-
api_client = genai.Client(
380+
api_client = genai.client.BaseApiClient(
381381
vertexai=True, project=self._project, location=self._location
382-
)._api_client
382+
)
383383

384384
if new_options := self._api_client_http_options_override():
385385
api_client._http_options = new_options

0 commit comments

Comments
 (0)