fix(backend): ground proactive insights and memory extraction in the current date#8501
fix(backend): ground proactive insights and memory extraction in the current date#8501ZachL111 wants to merge 11 commits into
Conversation
There was a problem hiding this comment.
2 issues found across 7 files
Confidence score: 3/5
- In
backend/utils/llm/memories.py, grounding relative time expressions against processing time instead of source-content time can misresolve phrases like “tomorrow” for delayed/retried/backfilled items, producing incorrect stored memories and downstream behavior—anchor extraction to the content/event timestamp (or pass an explicit reference datetime) before merging. - In
backend/utils/llm/temporal.py, the module-level dependency ondatabase.notificationsintroduces DB-layer side effects into a low-level temporal helper, which can trigger unwanted Firestore client initialization and make non-DB usage/tests brittle—decouple this import (e.g., move to call sites or inject the formatter dependency) before merging.
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
Both findings were valid and are now fixed. P2, temporal.py coupling: moved the P2, memory extraction date: |
kodjima33
left a comment
There was a problem hiding this comment.
Backend: ground proactive insights/memory extraction in current date — broad prompt change, approve only (>300 lines, leave merge for maintainer).
|
Thanks @ZachL111 — this is a clean, well-scoped fix for a real bug. The root-cause analysis is spot on: the proactive insight and memory-extraction prompts asked the model to reason about dates and deadlines without ever anchoring "today," so it fell back to its training-cutoff year and produced hallucinated clock/calendar warnings. Grounding them in the current date is the right fix and matches the pattern already used in the chat pipeline. A few things that stand out as solid:
The 12 new tests (helper behavior, per-prompt grounding, Leaving the merge call to a human maintainer given the breadth of the prompt change across several user-facing generators, but this looks good to land. |
Summary
Proactive insight notifications and extracted memories sometimes claim that a user's correctly dated content is in the future or that their system clock is wrong, for example "Your system clock is logging as 2026, not 2024. Check your OS date/time settings." or "The schedule is for 5/21/2026. This date is two years in the future." The user's clock is correct. The generators never told the model what today is, so it fell back to its training-cutoff year and treated every real future-year date as an anomaly. This injects the current date into those prompts.
Root cause
The chat and conversation-structuring prompts already ground the model in the present (utils/llm/chat.py and conversation_processing.py inject "Current date time in {tz}" and "today is {date}"). The proactive insight and memory generators did not:
With nothing establishing "now", the model uses its own sense of the year (around its training cutoff), so a correctly recorded 2026 date reads as two years in the future.
Fix
Additive only: every new parameter is optional, and the date lives in the dynamic part of the prompt, so the static prefix used for caching is unchanged.
Testing