fix(sessions): return empty events when num_recent_events=0 in DatabaseSessionService#5736
fix(sessions): return empty events when num_recent_events=0 in DatabaseSessionService#5736mangod12 wants to merge 2 commits into
Conversation
|
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. |
|
I have signed the Google CLA. Please re-check. |
e07d40a to
e7cfd1c
Compare
|
Hi @mangod12 , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Please fix formatting errors by running autoformat.sh |
4e821cb to
0bbba77
Compare
|
Rebased on latest Test results (local, Python 3.12, Windows)The 3 failures are pre-existing on
All session service tests relevant to this fix pass, including the new |
Summary
DatabaseSessionService.get_sessionreturning all events whennum_recent_events=0if config.num_recent_events:) treats0as falsy, skipping theLIMITclauseif config.num_recent_events is not None:, consistent withInMemorySessionServiceandSqliteSessionServiceLIMIT 0in SQL correctly returns zero rows across all dialects (PostgreSQL, MySQL, SQLite)Changes
src/google/adk/sessions/database_session_service.py— one-line fix (line 523)tests/unittests/sessions/test_session_service.py— added regression test fornum_recent_events=0Fixes #5730
Test plan
num_recent_events=0assertion totest_get_session_with_confignum_recent_events=3andnum_recent_events=Nonetest cases unchangedInMemorySessionService(line 205) andSqliteSessionService(line 264) which both useis not None🤖 Generated with Claude Code