Repository navigation
fix(session): backport session service fixes (#2100, #2089, #1930, #1774, #1919, #2189, #2285) - #2346
Merged
Merged
Conversation
wojtas000
approved these changes
Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Seven defects in the session services are present on 1.x.
temp:keys leak into Vertex AI sessions.CreateRequest.Statewas sent to Agent Engine as given, sotemp:keys were stored with the session and came back on every laterGet.AppendEventalready trims them from state deltas.Getreturns events older thanAfter.Getlocated the first event to keep with a binary search, which assumes the events are sorted by timestamp. They are kept in append order and carry their creation time, so when the two orders differ the search lands on an earlier event, contrary to the documented contract.Createloses user state on Postgres and MySQL.Createread the app and user state rows without a lock and wrote them back whole. Two sessions created at once for a new user both read no row and the later upsert replaced the earlier one'suser:keys.AppendEventhas locked these rows since#1743,Createdid not.Deleteleaves orphaned events.Deleterelied onON DELETE CASCADE, which SQLite enforces only when the connection enables foreign keys. On a default connection the session row went away and its events stayed.Listorder was undefined. Each backend returned its own: map order in memory, primary key order in the database, RPC order on Vertex AI.IsFinalResponsepanics on a nil part.hasFunctionCalls,hasFunctionResponsesandhasTrailingCodeExecutionResultdereferenced each entry ofContent.Partswithout a nil check. The method is public and called by the console launcher, the logging plugin and the LLM flow.IsFinalResponseignored the error code, so an error event that carried a function response made the LLM flow call the model again instead of ending the turn.Summary
Backports #2100, #2089, #1930, #1774, #1919, #2189 and #2285, one commit each, in the order they landed on main.
temp:keys from the initial state in the Vertex AICreate, as adk-python'screate_sessiondoes.Afterin the in-memoryGetinstead of binary-searching.Createthe same wayAppendEventdoes: insert if missing, readFOR UPDATE, app before user, only for the scopes the initial state changes.Delete, keyed on app name, user ID and session ID.Service.Listas last update time ascending, ties by user ID then session ID, and makes every backend produce it.IsFinalResponsehelpers.is_final_response.User-visible behavior changes:
Listnow returns sessions in last-update order on every backend.Createon the database service waits on the row lock when another session is writing the same app or user state.Adaptations for 1.x: the new tests use
session.NewEventWithContext(ctx, id)where main usessession.NewEvent(ctx, id), and the#1919tests uset.Context(). Nothing else differs from main.Not carried over:
raw_eventwrite path in the Vertex AI client andTestEventsSharingATimestampComeBackInAStableOrder.