Version: google-adk==2.3.0
Python: 3.12
Description:
DatabaseSessionService.get_session() raises TypeError: fromisoformat: argument must be str
on SQLite databases when reading back session or event rows.
Root cause:
PreciseTimestamp (in src/google/adk/sessions/schemas/shared.py) is a TypeDecorator
backed by SQLAlchemy DateTime. It does not define process_result_value. For SQLite,
DateTime columns are created with REAL affinity and written as Unix epoch floats
(e.g. StorageEvent.from_event calls datetime.fromtimestamp(event.timestamp) which
SQLite stores as REAL). On read, SQLAlchemy's C-extension str_to_datetime is invoked
and raises TypeError: fromisoformat: argument must be str because it receives a float.
Reproduce:
- Run any agent using
DatabaseSessionService with a SQLite URI.
- In a second process, open the same DB and call
get_session().
Expected: session and events returned correctly.
Actual: TypeError: fromisoformat: argument must be str
File "../sqlalchemy/cyextension/resultproxy.pyx", line 79, in _apply_processors
File "../sqlalchemy/cyextension/processors.pyx", line 40, in str_to_datetime
Fix:
Add process_result_value to PreciseTimestamp to handle the float→datetime conversion:
def process_result_value(self, value, dialect):
if value is None:
return None
if isinstance(value, (int, float)):
from datetime import datetime
return datetime.fromtimestamp(value)
return value # already a datetime (or str handled by base impl)
Version: google-adk==2.3.0
Python: 3.12
Description:
DatabaseSessionService.get_session()raisesTypeError: fromisoformat: argument must be stron SQLite databases when reading back session or event rows.
Root cause:
PreciseTimestamp(insrc/google/adk/sessions/schemas/shared.py) is aTypeDecoratorbacked by SQLAlchemy
DateTime. It does not defineprocess_result_value. For SQLite,DateTimecolumns are created withREALaffinity and written as Unix epoch floats(e.g.
StorageEvent.from_eventcallsdatetime.fromtimestamp(event.timestamp)whichSQLite stores as REAL). On read, SQLAlchemy's C-extension
str_to_datetimeis invokedand raises
TypeError: fromisoformat: argument must be strbecause it receives a float.Reproduce:
DatabaseSessionServicewith a SQLite URI.get_session().Expected: session and events returned correctly.
Actual:
TypeError: fromisoformat: argument must be strFile
"../sqlalchemy/cyextension/resultproxy.pyx", line 79, in_apply_processorsFile
"../sqlalchemy/cyextension/processors.pyx", line 40, instr_to_datetimeFix:
Add
process_result_valuetoPreciseTimestampto handle the float→datetime conversion: