Skip to content

fix(sessions): skip partial events in VertexAiSessionService and FirestoreSessionService - #1994

Open
chjpooh2002 wants to merge 1 commit into
google:mainfrom
chjpooh2002:fix/vertex-firestore-partial-event
Open

chjpooh2002 wants to merge 1 commit into
google:mainfrom
chjpooh2002:fix/vertex-firestore-partial-event

Conversation

@chjpooh2002

Copy link
Copy Markdown

Link to Issue or Description of Change

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

2. Summary of Change:

  • Problem: Neither VertexAiSessionService.appendEvent nor FirestoreSessionService.appendEvent returned early for partial events (event.partial().orElse(false)). VertexAiSessionService still chained .flatMap(...) into client.appendEvent(...) after BaseSessionService.super.appendEvent returned early, and FirestoreSessionService never checked event.partial(), mutating session state/timestamp and persisting partial events to Firestore.
  • Solution: Return Single.just(event) (or event inside Single.fromCallable) immediately after argument validation when event.partial().orElse(false) is true, matching BaseSessionService.appendEvent (BaseSessionService.java:217-235) and adk-python.

Testing Plan

Unit Tests:

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

Added unit tests:

  • VertexAiSessionServiceTest#appendEvent_partialEvent_doesNotCallBackendOrMutateSession
    • Before fix: failed (mockApiClient.request(...) was invoked with POST reasoningEngines/123/sessions/1:appendEvent carrying "partial":true).
    • After fix: Tests run: 42, Failures: 0, Errors: 0, Skipped: 0.
  • FirestoreSessionServiceTest#appendEvent_partialEvent_doesNotMutateStateOrPersistToFirestore
    • Before fix: failed (attempted to write stateDelta to Firestore via DocumentReference.update).
    • After fix: Tests run: 42, Failures: 0, Errors: 0, Skipped: 0.

Command run:

./mvnw -pl contrib/firestore-session-service -am -Dtest=VertexAiSessionServiceTest,FirestoreSessionServiceTest -Dsurefire.failIfNoSpecifiedTests=false test-compile surefire:test@default-test

Result: BUILD SUCCESS (all 42 + 42 tests passed).

Manual End-to-End (E2E) Tests:

N/A (mock-backed unit tests cover both backend persistence skipping and local session immutability).

Checklist

  • I have read the CONTRIBUTING.md document.
  • My pull request contains a single commit.
  • 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.

Additional context

Thanks to @sahuadarsh0 for pointing out these two implementations in #1990!

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 and FirestoreSessionService appendEvent do not skip partial events

1 participant