Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/google/adk/sessions/vertex_ai_session_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ async def list_sessions(
config=config,
)

for api_session in sessions_iterator:
async for api_session in sessions_iterator:
sessions.append(
Session(
app_name=app_name,
Expand Down
20 changes: 14 additions & 6 deletions tests/unittests/sessions/test_vertex_ai_session_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,14 @@ async def to_async_iterator(data):
yield item


class AsyncIterableList(list):
"""A list that also supports async iteration, mimicking AsyncPager behavior."""

async def __aiter__(self):
for item in self:
yield item


class MockAsyncClient:
"""Mocks the API Client."""

Expand Down Expand Up @@ -300,20 +308,20 @@ async def _list_sessions(self, name: str, config: dict[str, Any]):
if user_id_match:
user_id = user_id_match.group(1)
if user_id == 'user_with_pages':
return [
return AsyncIterableList([
_convert_to_object(MOCK_SESSION_JSON_PAGE1),
_convert_to_object(MOCK_SESSION_JSON_PAGE2),
]
return [
])
return AsyncIterableList([
_convert_to_object(session)
for session in self.session_dict.values()
if session['user_id'] == user_id
]
])

# No user filter, return all sessions
return [
return AsyncIterableList([
_convert_to_object(session) for session in self.session_dict.values()
]
])

async def _delete_session(self, name: str):
session_id = name.split('/')[-1]
Expand Down