Repository navigation
Render action item timestamps in the user's local timezone in chat (#4643) - #8483
Conversation
There was a problem hiding this comment.
1 issue found across 5 files
Confidence score: 3/5
- In
backend/utils/retrieval/tools/action_item_tools.py, the post-retrieval timezone lookup/conversion is unguarded, so a timezone resolution error can fail the entire action-item tool instead of gracefully formatting in UTC; this creates a concrete reliability risk for user-facing retrievals — add exception handling around timezone conversion and explicitly fall back to UTC before merging.
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
Thanks for this, @ZachL111 — clean fix. Promoting The defensive handling looks solid:
Rendering |
Problem
Issue #4643: AI chat refers to event times with the wrong time of day ("tonight" when it was the afternoon, "this afternoon" when it was the morning).
The agentic chat already injects the current time in the user's timezone and renders retrieved conversations in local time (
utils/conversations/render.py). But the action items tool the chat agent calls,get_action_items_tool, formatted timestamps with a barestrftimeand no timezone:The model reads that UTC wall clock as the user's local time. For a user in
America/Los_Angeles, 22:00 UTC is actually 15:00 local, so an item due in mid afternoon gets described as "due tonight."Fix
Render
created_at,due_at, andcompleted_atin the user's timezone with an explicit label, reusing the same helper conversations already use:_resolve_display_tzinrender.pyto a publicresolve_display_tzso conversations and the action items tool share one timezone resolver (falls back to UTC on a missing or invalid zone).get_action_items_toolfetches the user's timezone withnotification_db.get_user_time_zone(the same callconversation_toolsmakes) and formats each timestamp through a small naive-safe helper.This is the live path (
utils/retrieval/graph.pyto the agentic chat toget_action_items_tool), so it directly changes what users see.Tests
tests/unit/test_action_items_timezone.py: timestamps render in the user's zone with a label; UTC, empty, and invalid zones fall back to UTC without crashing; naive timestamps are treated as UTC. Verified red against the prior code and green with the fix.database.notificationsand the render helper, sotest_action_item_date_validation.pystubs those. While there I also restored autils.llm.conversation_folderstub that a recent refactor left out, so that file runs fully green again.Scope and follow-up
The calendar tool (
get_calendar_events_tool) has the same class of issue, but it is an async tool so the timezone read needs an executor offload. I left it for a separate change to keep this one small and obviously correct.