Commit f628094
fix: consistent UTC timestamp handling for PostgreSQL in DatabaseSessionService
Fixes two timestamp inconsistencies that cause stale session detection
failures when using PostgreSQL with asyncpg:
1. append_event() now strips timezone info for PostgreSQL (matching
create_session() behavior). Previously, PostgreSQL got a local-time
naive datetime via datetime.fromtimestamp(), while create_session()
stored a UTC-based naive datetime. This mismatch caused
get_update_timestamp() to return incorrect values when the server
timezone differs from UTC.
2. get_update_timestamp() now uses tzinfo-awareness to decide whether
to interpret a naive datetime as UTC, rather than checking only for
SQLite. This correctly handles both SQLite and PostgreSQL naive
datetimes without requiring callers to pass dialect flags.
Fixes #4366
Related: #1848
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 4b677e7 commit f628094
File tree
2 files changed
+15
-12
lines changed- src/google/adk/sessions
- schemas
2 files changed
+15
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
683 | 683 | | |
684 | 684 | | |
685 | 685 | | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
690 | | - | |
691 | | - | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
692 | 692 | | |
693 | 693 | | |
694 | 694 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
128 | 131 | | |
129 | 132 | | |
130 | 133 | | |
| |||
0 commit comments