Skip to content

fix(redis): omit events from RedisSessionService.list_sessions - #8227

Open
abhishekacharya200 wants to merge 1 commit into
google:mainfrom
abhishekacharya200:fix-redis-list-sessions-events
Open

abhishekacharya200 wants to merge 1 commit into
google:mainfrom
abhishekacharya200:fix-redis-list-sessions-events

Conversation

@abhishekacharya200

Copy link
Copy Markdown

Link to Issue or Description of Change

2. Or, if no issue exists, describe the change:

Problem:
ListSessionsResponse documents that listed sessions carry no events, and every other session service (InMemorySessionService, DatabaseSessionService, SqliteSessionService, VertexAiSessionService, FirestoreSessionService, the MongoDB session service) returns listed sessions with events=[]. RedisSessionService stores each session, events included, as one JSON value and list_sessions returns the parsed value unchanged, so a listing returns the full event history of every matching session. Callers such as the API server's list-sessions endpoint then send every transcript, and the result differs from every other backend.

Repro:

session = await svc.create_session(app_name="app1", user_id="u1", session_id="s1")
await svc.append_event(session, Event(invocation_id="i", author="user",
    content=types.Content(role="user", parts=[types.Part(text="hi")])))
resp = await svc.list_sessions(app_name="app1", user_id="u1")
assert resp.sessions[0].events == []  # fails: holds the appended event

Solution:
Clear events on each listed session after its state is merged, the same as InMemorySessionService._list_sessions_impl. State merging, ordering and ownership filtering are unchanged; get_session still returns the full history.

Testing Plan

Unit Tests:

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

test_list_sessions_omits_events (with and without user_id) fails on main and passes with the fix. pytest tests/unittests/integrations/redis: 42 passed.

Manual End-to-End (E2E) Tests:

Not run against a live Redis; covered by the unit test against the fake Redis client used by the existing tests.

Checklist

  • I have read the CONTRIBUTING.md document.
  • 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

Open PRs #7799 (pagination) and #7563 (versioned Redis keys) touch list_sessions but neither changes how events are handled; this one-line change is independent of both.

ListSessionsResponse documents that listed sessions carry no events, and
every other session service returns them with events=[]. RedisSessionService
parsed each stored session value, which holds the full event history, and
returned it unchanged, so a listing shipped every transcript of every
matching session.
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.

2 participants