Skip to content

Inconsistent timezone handling for PostgreSQL between create_session and append_event in DatabaseSessionService #5354

Description

@zouyi100

🔴 Required Information

Describe the Bug:
Inconsistent timezone handling for PostgreSQL between create_session and append_event methods in DatabaseSessionService. The create_session method stores UTC time with timezone removed for PostgreSQL, while append_event method stores local time (no timezone parameter) for PostgreSQL. This inconsistency may cause StorageSession.update_time to have different time baselines depending on which method was called.

Steps to Reproduce:

  1. Set up ADK with PostgreSQL as the database backend
  2. Create a session using DatabaseSessionService.create_session()
  3. Append an event using DatabaseSessionService.append_event()
  4. Compare the create_time/update_time values in StorageSession table
  5. Observe that timestamps may have different time baselines (UTC vs local time)

Expected Behavior:

  • Both create_session and append_event should handle PostgreSQL timestamps consistently, storing UTC time with timezone information removed for both methods.

Observed Behavior:

  • create_session (L461-L465): PostgreSQL uses UTC time with tzinfo=None

  • append_event (L731-L737): PostgreSQL uses local time (no timezone parameter passed to datetime.fromtimestamp())

This can cause timestamps to be inconsistent when the server timezone differs from UTC.

Environment Details:

  • ADK Library Version (pip show google-adk): 1.29.0
  • Desktop OS:** Windows
  • Python Version (python -V): 3.13

Model Information:

  • Are you using LiteLLM: N/A
  • Which model is being used: N/A

Metadata

Metadata

Labels

request clarification[Status] The maintainer need clarification or more information from the authorservices[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions