adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

fix(sessions): Accept Vertex session resource names

Open RaghunandanKumar opened this issue 5 months ago • 3 comments

Summary

  • Normalize fully qualified Vertex/Gemini Enterprise session resource names to plain session IDs before get_session and delete_session build 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, Vertex reasoningEngines/.../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.py
  • uv run pytest tests/unittests/sessions
  • uv run pyink src/google/adk/sessions/vertex_ai_session_service.py tests/unittests/sessions/test_vertex_ai_session_service.py --check
  • uv run pre-commit run --files src/google/adk/sessions/vertex_ai_session_service.py tests/unittests/sessions/test_vertex_ai_session_service.py
  • uv run pytest tests/unittests (7052 passed, 18 skipped, 31 xfailed, 9 xpassed)

RaghunandanKumar avatar Jun 10 '26 02:06 RaghunandanKumar

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.

google-cla[bot] avatar Jun 10 '26 02:06 google-cla[bot]

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:

  1. 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!

adk-bot avatar Jun 10 '26 02:06 adk-bot

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

devyulbae avatar Jun 11 '26 05:06 devyulbae

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.

GWeale avatar Jun 16 '26 22:06 GWeale