Commit d9a672e
fix(sessions): honor zero recent events in database service
Merge google#5965
## Summary
- honor `GetSessionConfig(num_recent_events=0)` in `DatabaseSessionService`
- add cross-backend regression coverage for zero recent events in `test_get_session_with_config`
- keep existing positive-limit and no-config behavior unchanged
## Motivation
`GetSessionConfig` documents `num_recent_events=0` as returning no events. InMemory and Sqlite already preserve that behavior, and ADK call sites use `num_recent_events=0` when they only need to check whether a session exists. `DatabaseSessionService` used a truthy check, so `0` skipped the SQL `LIMIT` and returned the full event history.
## Testing
- `uv run --extra test pytest tests/unittests/sessions/test_session_service.py::test_get_session_with_config -q`
- `uv run --extra test pytest tests/unittests/sessions -q`
- `uvx pyink --check src/google/adk/sessions/database_session_service.py tests/unittests/sessions/test_session_service.py`
- `uv run python -m py_compile src/google/adk/sessions/database_session_service.py tests/unittests/sessions/test_session_service.py`
- `git diff --check`
COPYBARA_INTEGRATE_REVIEW=google#5965 from White-Mouse:codex/adk-session-zero-events d64df8f
PiperOrigin-RevId: 9294381161 parent c11ac7d commit d9a672e
2 files changed
Lines changed: 8 additions & 1 deletion
File tree
- src/google/adk/sessions
- tests/unittests/sessions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
534 | | - | |
| 534 | + | |
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1058 | 1058 | | |
1059 | 1059 | | |
1060 | 1060 | | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
1061 | 1068 | | |
1062 | 1069 | | |
1063 | 1070 | | |
| |||
0 commit comments