Repository navigation
Description
🔴 Required Information
Describe the Bug:
Follow-up to #1987 (flagged by @sahuadarsh0 in #1990): VertexAiSessionService.appendEvent and FirestoreSessionService.appendEvent also do not return early when event.partial() is true, diverging from BaseSessionService.appendEvent (BaseSessionService.java:217-235) and adk-python.
VertexAiSessionService.appendEvent(core/src/main/java/com/google/adk/sessions/VertexAiSessionService.java:339-350):
Delegates toBaseSessionService.super.appendEvent(session, event)(which returnsSingle.just(event)early without mutating local session state/events), but still chains.flatMap(...)and sends the partial event toclient.appendEvent(...).FirestoreSessionService.appendEvent(contrib/firestore-session-service/src/main/java/com/google/adk/sessions/FirestoreSessionService.java:685-789):
Never checksevent.partial(), so partial events mutatesession.state()/appState/userState, updatesession.lastUpdateTime, append the event tosession.events(), and persist both state and event writes to Firestore.
Steps to Reproduce:
- Construct a
VertexAiSessionService(with a mockVertexAiClient) orFirestoreSessionService(with a mockFirestore). - Build an
Eventwithpartial(true)and a non-emptystateDelta. - Call
appendEvent(session, partialEvent).blockingGet().
Expected Behavior:
Matching BaseSessionService.appendEvent (BaseSessionService.java:217-235) and adk-python, both services should return Single.just(event) immediately when event.partial().orElse(false) is true, without invoking remote persistence (VertexAiClient.appendEvent / Firestore writes) or mutating session state, events, or lastUpdateTime.
Observed Behavior:
VertexAiSessionService.appendEventstill callsclient.appendEvent(...)for partial events.FirestoreSessionService.appendEventstill writesstateDelta, appends the event, updateslastUpdateTime, and commits Firestore writes for partial events.
Environment Details:
- ADK Library Version:
main(13ce6e3d96ebaa9b9ad84198e50ed81e6aab14f3,1.16.1-SNAPSHOT) - OS: Windows
- Java Version: OpenJDK 21.0.10 (Temurin-21.0.10+7)
Model Information:
- Which model is being used: N/A
🟡 Optional Information
Regression:
Unknown.
Logs:
N/A
Screenshots / Video:
N/A
Additional Context:
- Related to InMemorySessionService.appendEvent mutates state and lastUpdateTime for partial events #1987 and fix(sessions): skip state and timestamp updates for partial events in InMemorySessionService #1990 (which fixes
InMemorySessionService.appendEvent). - Credit to @sahuadarsh0 for pointing out these two implementations during the review of fix(sessions): skip state and timestamp updates for partial events in InMemorySessionService #1990.
Minimal Reproduction Code:
// VertexAiSessionService:
Event partialEvent = Event.builder().partial(true).build();
vertexAiSessionService.appendEvent(session, partialEvent).blockingGet();
// Expected: verify(mockClient, never()).appendEvent(any(), any(), any());
// Observed: mockClient.appendEvent(...) is invoked.How often has this issue occurred?:
- Always (100%)
Activity