Skip to content

fix(session): backport session service fixes (#2100, #2089, #1930, #1774, #1919, #2189, #2285) - #2346

Merged
wolo-lab merged 7 commits into
v1from
wolo/v1-backport-01-session
Nov 16, 2026
Merged

wolo-lab merged 7 commits into
v1from
wolo/v1-backport-01-session

Conversation

@wolo-lab

Copy link
Copy Markdown
Contributor

Problem

Seven defects in the session services are present on 1.x.

  • temp: keys leak into Vertex AI sessions. CreateRequest.State was sent to Agent Engine as given, so temp: keys were stored with the session and came back on every later Get. AppendEvent already trims them from state deltas.
  • In-memory Get returns events older than After. Get located 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.
  • Concurrent Create loses user state on Postgres and MySQL. Create read 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's user: keys. AppendEvent has locked these rows since #1743, Create did not.
  • SQLite Delete leaves orphaned events. Delete relied on ON 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.
  • List order was undefined. Each backend returned its own: map order in memory, primary key order in the database, RPC order on Vertex AI.
  • IsFinalResponse panics on a nil part. hasFunctionCalls, hasFunctionResponses and hasTrailingCodeExecutionResult dereferenced each entry of Content.Parts without a nil check. The method is public and called by the console launcher, the logging plugin and the LLM flow.
  • A final error event was not final. IsFinalResponse ignored 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.

User-visible behavior changes:

  • List now returns sessions in last-update order on every backend.
  • Create on the database service waits on the row lock when another session is writing the same app or user state.
  • An error event ends the turn instead of triggering another model call.

Adaptations for 1.x: the new tests use session.NewEventWithContext(ctx, id) where main uses session.NewEvent(ctx, id), and the #1919 tests use t.Context(). Nothing else differs from main.

Not carried over:

@wolo-lab wolo-lab added the v1 PR targeting v1 branch. label Nov 16, 2026
@wolo-lab
wolo-lab requested a review from wojtas000 November 16, 2026 09:39
@wolo-lab
wolo-lab merged commit 31f05d2 into v1 Nov 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v1 PR targeting v1 branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants