Render calendar event times in the user's timezone in chat (#4643)#8495
Render calendar event times in the user's timezone in chat (#4643)#8495ZachL111 wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
1 issue found across 3 files
Confidence score: 3/5
- In
backend/utils/retrieval/tools/calendar_tools.py, the unguardedrun_blocking(notification_db.get_user_time_zone)lookup can fail the whole tool path, causing users to get an error instead of calendar events even when fetch succeeds. Add defensive handling/fallback for timezone lookup (and continue with a default timezone or UTC) before merging.
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
Good catch, you are right. The timezone lookup (a Firestore read offloaded via |
|
Thanks @ZachL111 — nice, clean fix. The three helpers ( I verified the helpers directly and the 8 new unit tests pass. A couple of small notes for when this lands:
One process note: this looks like it builds on the still-open #8483 (same #4643 follow-up, action-item timestamps). I'm leaving a positive signal rather than approving so a maintainer can confirm the sequencing/merge order between the two. Not blocking on the code itself. |
|
Independent static review of the diff against
No code concerns from me. Holding off on formal approval only because this builds on the still-open #8483 (same #4643 follow-up) — leaving to a maintainer to confirm the merge order between the two. Tagging along with the existing |
Summary
Completes the #4643 follow-up I flagged in #8483. The agentic chat's calendar tool,
get_calendar_events_tool, rendered Google Calendar event Start and End times in raw UTC / the event's own zone (strftimewith%Z), not the user's timezone. So when the model answers "when is my meeting," it can read a UTC wall clock as the user's local time and mislabel the time of day, the same class of bug #8483 fixed for action items.Fix
Render event Start and End in the user's timezone with an explicit label, for example
Start: 2026-06-30 15:00:00 America/Los_Angelesinstead of a UTC time. Two small helpers do the work:_resolve_display_tz(tz): the user'sZoneInfoand a label, falling back to UTC on a missing or invalid zone._format_event_dt(dt, display_tz, label): convert a tz-aware event time to the user's zone (a naive value is treated as UTC) and append the label.get_calendar_events_toolis async, so the user's timezone is read off the event loop viarun_blocking(db_executor, get_user_time_zone, uid)before the events are formatted. All-day events (date only, no time) are left unchanged. This only touches the read tool the chat model uses to answer time questions.Testing
New
tests/unit/test_calendar_timezone.py(registered intest.sh): the helpers convert to the user's zone with a label, fall back to UTC for missing/invalid/empty zones, treat a naive time as UTC, and handle a day-boundary crossing (22:00 UTC is 07:00 the next day in Tokyo). Black and the async-blocker lint are clean (the timezone read is offloaded, so the event loop is not blocked).