Skip to content

fix(sessions): preserve original Event.id from raw_event in VertexAiSessionService (v1) - #6545

Open
chelsealong wants to merge 1 commit into
google:v1from
chelsealong:fix-vertex-session-event-id-6530-v1
Open

fix(sessions): preserve original Event.id from raw_event in VertexAiSessionService (v1)#6545
chelsealong wants to merge 1 commit into
google:v1from
chelsealong:fix-vertex-session-event-id-6530-v1

Conversation

@chelsealong

Copy link
Copy Markdown

Ports #6531 to the v1 line, as requested by @ashubham there ("The fix works, can we please port to 1.x as well").

Problem

_from_api_event overwrote the ADK Event.id with the last segment of the Vertex event resource name, so the same logical event reported a different id depending on how it was observed — one value while streaming, another after a reload. Anything keyed on Event.id across a reload boundary saw them as two distinct events.

Fix

Stop clobbering id in the event_dict.update({...}) call and fall back to the resource name only when raw_event carries no id:

event_dict.setdefault('id', api_event_obj.name.split('/')[-1])

Older data without a raw_event id keeps the previous behaviour.

Evidence

Identical source change to #6531 (verified with a diff of both patches). Added the same regression test, test_get_session_preserves_original_event_id_from_raw_event, which puts a distinct id in raw_event and asserts get_session returns it rather than the resource name.

$ pytest tests/unittests/sessions/test_vertex_ai_session_service.py::test_get_session_preserves_original_event_id_from_raw_event
1 passed

# with the source change reverted (git stash), to show the test actually proves the fix:
1 failed

$ pytest tests/unittests/sessions/test_vertex_ai_session_service.py
33 passed

Branch is cut from current upstream/v1.


Prepared with the help of Claude Code (Anthropic's AI coding assistant); I reviewed the diff and the test output before pushing.

…essionService

_from_api_event overwrote the ADK event id with the Vertex resource name, so
the same logical event reported a different id depending on whether it was seen
via streaming or via a reload. Fall back to the resource name only when
raw_event carries no id, which keeps older data working.

Port of google#6531 to the v1 line, requested by @ashubham on that PR.
@adk-bot adk-bot added the services [Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc label Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

services [Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants