Skip to content

Commit dc9a5da

Browse files
yeesiancopybara-github
authored andcommitted
fix: Update definition of async_add_session_to_memory to not depend on Session
This avoids issues with the generation of the schema when deploying PiperOrigin-RevId: 808304051
1 parent c1c2fe6 commit dc9a5da

File tree

3 files changed

+10
-43
lines changed

3 files changed

+10
-43
lines changed

vertexai/_genai/_agent_engines_utils.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,6 @@
9191
_SpecifierSet: type[Any] = Any
9292

9393

94-
try:
95-
# For the registration of the AdkApp.async_add_session_to_memory method to
96-
# avoid errors of the form:
97-
# failed to generate schema for async_add_session_to_memory:
98-
# `async_add_session_to_memory` is not fully defined; you should define
99-
# `Session`, then call `async_add_session_to_memory.model_rebuild()`
100-
from google.adk.sessions.session import Session
101-
102-
Session = Session
103-
except (ImportError, AttributeError):
104-
# For agent engine templates that do not depend on ADK, we do not need to
105-
# worry about registering the AdkApp.async_add_session_to_memory method.
106-
Session = Any
107-
108-
10994
try:
11095
from a2a.types import (
11196
AgentCard,

vertexai/agent_engines/templates/adk.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,6 @@
5353
except (ImportError, AttributeError):
5454
BaseSessionService = Any
5555

56-
try:
57-
from google.adk.sessions.session import Session
58-
59-
Session = Session
60-
except (ImportError, AttributeError):
61-
Session = Any
62-
6356
try:
6457
from google.adk.artifacts import BaseArtifactService
6558

@@ -842,16 +835,14 @@ async def async_delete_session(
842835
**kwargs,
843836
)
844837

845-
async def async_add_session_to_memory(
846-
self,
847-
*,
848-
session: Union["Session", Dict[str, Any]],
849-
):
838+
async def async_add_session_to_memory(self, *, session: Dict[str, Any]):
850839
"""Generates memories.
851840
852841
Args:
853-
session (Union[Session, Dict[str, Any]]):
854-
Required. The session to use for generating memories.
842+
session (Dict[str, Any]):
843+
Required. The session to use for generating memories. It should
844+
be a dictionary representing an ADK Session object, e.g.
845+
session.model_dump(mode="json").
855846
"""
856847
from google.adk.sessions.session import Session
857848

vertexai/preview/reasoning_engines/templates/adk.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,6 @@
5858
except (ImportError, AttributeError):
5959
BaseSessionService = Any
6060

61-
try:
62-
from google.adk.sessions.session import Session
63-
64-
Session = Session
65-
except (ImportError, AttributeError):
66-
Session = Any
67-
6861
try:
6962
from google.adk.artifacts import BaseArtifactService
7063

@@ -1135,16 +1128,14 @@ def _asyncio_thread_main():
11351128
if isinstance(outcome, RuntimeError):
11361129
raise outcome from None
11371130

1138-
async def async_add_session_to_memory(
1139-
self,
1140-
*,
1141-
session: Union["Session", Dict[str, Any]],
1142-
):
1131+
async def async_add_session_to_memory(self, *, session: Dict[str, Any]):
11431132
"""Generates memories.
11441133
11451134
Args:
1146-
session (Union[Session, Dict[str, Any]]):
1147-
Required. The session to use for generating memories.
1135+
session (Dict[str, Any]):
1136+
Required. The session to use for generating memories. It should
1137+
be a dictionary representing an ADK Session object, e.g.
1138+
session.model_dump(mode="json").
11481139
"""
11491140
from google.adk.sessions.session import Session
11501141

0 commit comments

Comments
 (0)