fix(sessions): Accept Vertex session resource names
Summary
- Normalize fully qualified Vertex/Gemini Enterprise session resource names to plain session IDs before
get_sessionanddelete_sessionbuild Agent Engine paths. - Keep strict session ID validation after normalization so malformed IDs and path-traversal-style values still fail.
- Add coverage for Gemini Enterprise-style
collections/.../engines/.../sessions/...names, VertexreasoningEngines/.../sessions/...names, and invalid path inputs.
Why
Fixes #6036. Gemini Enterprise can pass a fully qualified session resource name into hosted ADK session lookups. The previous validation rejected those names before extracting the actual session ID.
Verification
uv run pytest tests/unittests/sessions/test_vertex_ai_session_service.py -k 'fully_qualified or path_traversal'uv run pytest tests/unittests/sessions/test_vertex_ai_session_service.pyuv run pytest tests/unittests/sessionsuv run pyink src/google/adk/sessions/vertex_ai_session_service.py tests/unittests/sessions/test_vertex_ai_session_service.py --checkuv run pre-commit run --files src/google/adk/sessions/vertex_ai_session_service.py tests/unittests/sessions/test_vertex_ai_session_service.pyuv run pytest tests/unittests(7052 passed, 18 skipped, 31 xfailed, 9 xpassed)
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
Response from ADK Triaging Agent
Hello @RaghunandanKumar, thank you for creating this PR!
It looks like this PR is not fully following the contribution guidelines:
- Contributor License Agreement (CLA): The CLA check currently shows a failure status. Please make sure you have signed the Google CLA at https://cla.developers.google.com/ so that we can proceed with reviewing your pull request.
This information will help reviewers to review your PR more efficiently. Thanks!
Hi @RaghunandanKumar, thanks for the fix here.
I ran into the same error and noticed one related auto-create-session path: when get_session(...) returns None for a missing session, Runner can call create_session(..., session_id=session_id) with the same original session ID. If that value is a fully qualified GE / Agentspace session resource name, it may still hit validation in **create_session**.
I opened a small PR against your branch with that one-line follow-up and a unit test: https://github.com/RaghunandanKumar/adk-python/pull/1
Thanks for this! The same fix has already landed on main — _extract_short_session_id now strips full Agent Engine / Gemini Enterprise resource names before validation in get_session/delete_session (commit 60c55ad7). Closing as already-resolved. Appreciate the contribution.