Skip to content

fix(sessions): prevent VertexAiSessionService from dropping latest events under clock skew#1174

Open
merra3012 wants to merge 1 commit intogoogle:mainfrom
merra3012:fix/issue-1173-vertex-session-events
Open

fix(sessions): prevent VertexAiSessionService from dropping latest events under clock skew#1174
merra3012 wants to merge 1 commit intogoogle:mainfrom
merra3012:fix/issue-1173-vertex-session-events

Conversation

@merra3012
Copy link
Copy Markdown

Summary

  • Fix VertexAiSessionService.getSession() to stop pre-filtering events against session updateTime.
  • Preserve all events returned by listEvents() and only apply explicit GetSessionConfig filters.
  • Add regression coverage for clock-skew behavior where event timestamps can be newer than server updateTime.

Why

Issue #1173 reports that getSession() can silently drop the most recent event(s) (notably in HITL resume flows) because it compared:

  • server-side session updateTime
  • client-side Event.timestamp()

Those clocks can drift, so valid latest events were filtered out.

What changed

  • In core/src/main/java/com/google/adk/sessions/VertexAiSessionService.java:

    • Removed the updateTime-based pre-filter in filterEvents(...).
    • Kept deterministic sorting by event timestamp.
    • Kept config-based filtering:
      • numRecentEvents
      • afterTimestamp (inclusive behavior via !isBefore).
  • In core/src/test/java/com/google/adk/sessions/VertexAiSessionServiceTest.java:

    • Added getSession_clockSkewWithUpdateTime_doesNotDropRecentEvents
    • Added getSession_afterTimestamp_filtersAtOrAfterThreshold
    • Added getSession_numRecentEvents_returnsLatestEvents
    • Added dedicated mock session/event fixtures reproducing skew (event.timestamp > session.updateTime).

Validation

  • ./mvnw -pl core -Dtest=VertexAiSessionServiceTest test
  • ./mvnw test fails due to existing unrelated test/build issues outside the files changed in this PR.

Issue

Closes #1173

Stop filtering getSession events by session updateTime because updateTime is server-side and Event.timestamp is client-side, which can silently drop valid latest events. Add regression coverage for skewed timestamps and explicit getSession config filtering behavior.

Made-with: Cursor
@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 30, 2026

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VertexAiSessionService.getSession() silently drops last event(s) due to strict isBefore() timestamp filtering

1 participant