Skip to content

fix(sessions): update session last update time on vertex append event - #7404

Closed
AbQaadir wants to merge 1 commit into
google:mainfrom
AbQaadir:fix/vertex-session-last-update-time
Closed

AbQaadir wants to merge 1 commit into
google:mainfrom
AbQaadir:fix/vertex-session-last-update-time

Conversation

@AbQaadir

@AbQaadir AbQaadir commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

Problem:
In VertexAiSessionService.append_event, session.last_update_time was not updated when an event was appended to a session, unlike InMemorySessionService, SqliteSessionService, and DatabaseSessionService which keep session.last_update_time synchronized with event.timestamp. As a result, the in-memory Session object retained its initial creation time after events were added, drifting from the remote API state (which updates update_time) and other session implementations.

Solution:
In VertexAiSessionService.append_event, set session.last_update_time = event.timestamp when committing non-partial events to the session. Also added comprehensive unit tests covering:

  • Verifying session.last_update_time advances on non-partial append and matches the retrieved remote session.
  • Verifying multiple sequential appends continuously advance session.last_update_time.
  • Verifying partial/streaming events (partial=True) do not update session.last_update_time or commit to session.events.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Summary of passed tests:

  • tests/unittests/sessions/test_vertex_ai_session_service.py: 57 passed
  • tests/unittests/sessions/: 523 passed
  • tests/unittests/events/ tests/unittests/runners/ tests/unittests/agents/: 1094 passed
  • Static pre-commit checks (pyink, ruff, isort, addlicense, compliance checks): all passed
  • mypy: 0 issues found in source

Manual End-to-End (E2E) Tests:

Run pytest with uv:

uv run --all-extras pytest tests/unittests/sessions/test_vertex_ai_session_service.py -k "test_append_event"

Verify all append event tests (test_append_event, test_append_event_updates_session_last_update_time, test_append_event_partial_does_not_update_session_last_update_time, test_append_multiple_events_advances_last_update_time) pass.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

In VertexAiSessionService.append_event, session.last_update_time was not
updated when an event was appended, unlike InMemorySessionService,
SqliteSessionService, and DatabaseSessionService which synchronize
session.last_update_time = event.timestamp.

Now update session.last_update_time on non-partial event commits, ensuring
consistency across session service backends.

Closes google#7338
copybara-service Bot pushed a commit that referenced this pull request Oct 6, 2026
@adk-bot

adk-bot commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Thank you @AbQaadir for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit 11d92d7.

Closing this PR as the changes are now in the main branch.

@adk-bot adk-bot added the merged [Status] This PR is merged label Oct 6, 2026
@adk-bot adk-bot closed this Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged [Status] This PR is merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clarify Vertex append_event Session.last_update_time after append

3 participants