Skip to content

Commit 2b3613f

Browse files
author
Andrew Brookins
committed
Fix datetime parsing for Unix timestamp strings in vectorstore_adapter
The parse_datetime function was failing when receiving Unix timestamps as strings (e.g., '1765388915.12') because it tried to parse them as ISO format strings. This fix tries to parse string values as floats first before falling back to ISO format parsing.
1 parent 6907645 commit 2b3613f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

agent_memory_server/vectorstore_adapter.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,12 @@ def parse_datetime(dt_val: str | float | None) -> datetime | None:
403403
# Unix timestamp from Redis
404404
return datetime.fromtimestamp(dt_val, tz=UTC)
405405
if isinstance(dt_val, str):
406+
# Try to parse as float first (Unix timestamp as string)
407+
try:
408+
timestamp = float(dt_val)
409+
return datetime.fromtimestamp(timestamp, tz=UTC)
410+
except ValueError:
411+
pass
406412
# ISO string from other backends
407413
return datetime.fromisoformat(dt_val)
408414
return None

0 commit comments

Comments
 (0)