Skip to content
Open
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 @@ -164,7 +164,7 @@ async def create_session(

config = {'session_state': state} if state else {}
if session_id:
_validate_session_id(session_id)
session_id = _normalize_session_id(session_id)
config['session_id'] = session_id
config.update(kwargs)
async with self._get_api_client() as api_client:
Expand Down
33 changes: 33 additions & 0 deletions tests/unittests/sessions/test_vertex_ai_session_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,39 @@ async def test_create_session_with_custom_session_id(
)


@pytest.mark.asyncio
@pytest.mark.usefixtures('mock_get_api_client')
@pytest.mark.parametrize(
'resource_name',
[
(
'projects/my-project/locations/global/collections/'
'default_collection/engines/my-app/sessions/custom_1'
),
(
'projects/my-project/locations/us-central1/'
'reasoningEngines/123/sessions/custom_1'
),
],
)
async def test_create_session_accepts_fully_qualified_resource_name(
mock_api_client_instance: MockAsyncClient, resource_name: str
):
session_service = mock_vertex_ai_session_service()

session = await session_service.create_session(
app_name='123', user_id='user', session_id=resource_name
)

assert session.id == 'custom_1'
assert session.app_name == '123'
assert session.user_id == 'user'
assert (
mock_api_client_instance.last_create_session_config['session_id']
== 'custom_1'
)


@pytest.mark.asyncio
@pytest.mark.usefixtures('mock_get_api_client')
async def test_create_session_with_custom_config(mock_api_client_instance):
Expand Down
Loading