Repository navigation
fix(sessions): skip state and timestamp updates for partial events in InMemorySessionService - #1990
chjpooh2002 wants to merge 1 commit into
Conversation
… InMemorySessionService
|
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. |
| Objects.requireNonNull(session.userId(), "session.userId cannot be null"); | ||
| Objects.requireNonNull(session.id(), "session.id cannot be null"); | ||
|
|
||
| if (event.partial().orElse(false)) { |
There was a problem hiding this comment.
FYI: VertexAiSessionService.appendEvent and FirestoreSessionService.appendEvent have the same partial-event gap. VertexAiSessionService delegates to BaseSessionService.super.appendEvent (which returns Single.just(event) early), then still chains .flatMap(...) into client.appendEvent(...), and FirestoreSessionService writes stateDelta before checking partial(). Fine to keep this PR scoped to InMemorySessionService, just flagging the other two in case you want them consistent.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
2. Summary of Change:
InMemorySessionService.appendEventmutatedappState,userState,session.state(), andsession.lastUpdateTime(and re-stored the session) even whenevent.partial()wastrue, whileBaseSessionService.super.appendEventskipped appending the event itself.Single.just(event)early immediately after the null checks whenevent.partial().orElse(false)istrue, matchingBaseSessionService.appendEvent(BaseSessionService.java:217-235) andadk-python'sInMemorySessionService.append_event.Testing Plan
Unit Tests:
Added
InMemorySessionServiceTest#appendEvent_partialEvent_doesNotMutateStateOrTimestamp:expected not to contain: sessionKey, but was: [app:appKey, sessionKey, user:userKey];Tests run: 19, Failures: 1, Errors: 0, Skipped: 0)../mvnw -pl core -Dtest=InMemorySessionServiceTest test-compile surefire:test@default-test->Tests run: 19, Failures: 0, Errors: 0, Skipped: 0,BUILD SUCCESS).Manual End-to-End (E2E) Tests:
N/A (pure in-memory session unit behavior covered by unit tests).
Checklist