Repository navigation
Conversation
There was a problem hiding this comment.
3 issues found across 3 files
Confidence score: 3/5
- In
backend/utils/retrieval/tools/calendar_tools.py, partial reschedules are not fully time-validated, so a single-field update can still produce an invalid start/end pair and send a bad calendar update; add validation that checks resulting event order even when only one side (start or end) is changed before merging. - In
backend/utils/retrieval/tools/calendar_tools.py, the auth-refresh retry success path drops the reschedule start/end details, which can confuse callers that rely on confirmation payloads after a token refresh; align retry-path response formatting with the normal success output before merge. - In
backend/tests/unit/test_calendar_update_event_time.py, the source-string assertion is tightly coupled to implementation details and may pass or fail for the wrong reasons, reducing confidence in future refactors; replace it with a behavioral test that exercises the retry path and verifies returned reschedule fields.
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
…eschedule details
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/utils/retrieval/tools/calendar_tools.py">
<violation number="1" location="backend/utils/retrieval/tools/calendar_tools.py:285">
P1: `_parse_event_dt` can return naive datetimes for Google `dateTime` values without offsets, causing a naive/aware datetime comparison crash in partial reschedule validation.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
| return None | ||
| try: | ||
| if 'dateTime' in time_field: | ||
| return datetime.fromisoformat(time_field['dateTime'].replace('Z', '+00:00')) |
There was a problem hiding this comment.
P1: _parse_event_dt can return naive datetimes for Google dateTime values without offsets, causing a naive/aware datetime comparison crash in partial reschedule validation.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/utils/retrieval/tools/calendar_tools.py, line 285:
<comment>`_parse_event_dt` can return naive datetimes for Google `dateTime` values without offsets, causing a naive/aware datetime comparison crash in partial reschedule validation.</comment>
<file context>
@@ -272,6 +272,24 @@ async def get_google_calendar_event(access_token: str, event_id: str) -> dict:
+ return None
+ try:
+ if 'dateTime' in time_field:
+ return datetime.fromisoformat(time_field['dateTime'].replace('Z', '+00:00'))
+ if 'date' in time_field:
+ return datetime.fromisoformat(time_field['date'] + 'T00:00:00+00:00')
</file context>
| return datetime.fromisoformat(time_field['dateTime'].replace('Z', '+00:00')) | |
| parsed_dt = datetime.fromisoformat(time_field['dateTime'].replace('Z', '+00:00')) | |
| if parsed_dt.tzinfo is None: | |
| parsed_dt = parsed_dt.replace(tzinfo=timezone.utc) | |
| return parsed_dt |
|
Hi @ZachL111 — thank you for finding this and writing up a candidate fix. We reviewed it during the ZachL111 aggregate triage. This one needs a bit more product/API/design decision than we want to bundle into the current aggregate PRs (#8362, #8364, #8366, #8367), so we’re deferring rather than merging this exact patch. I’m closing the individual PR to keep the review queue manageable. The report is still appreciated and may be revisited as a more explicit follow-up. Thanks again for the contribution. |
|
Closing after aggregate triage: deferring this design/API decision rather than merging the one-off patch. Thanks @ZachL111 for surfacing it. |
|
Hey @ZachL111 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! 💜 |
Summary
update_calendar_event_toolis the agent tool that edits an existing Google Calendar event. Its docstring says it can change an event's title, description, location, time, or attendees, and the underlying writerupdate_google_calendar_eventacceptsstart_timeandend_time. But the tool never accepted new-time arguments and never passed any time through to the writer, so when a user asked to reschedule an event the tool returned a success message while the event's start and end time stayed exactly as they were. This PR addsnew_start_timeandnew_end_timeparameters, validates them the same waycreate_calendar_event_toolvalidates times, and threads them into bothupdate_google_calendar_eventcalls so a reschedule actually changes the event.Root cause
In
backend/utils/retrieval/tools/calendar_tools.py,update_calendar_event_toolhad no time parameters in its signature and built its update from title, description, location, and attendees only:The post-token-refresh retry in the same function had the same call with no time arguments.
update_google_calendar_eventdefaultsstart_timeandend_timetoNone, and aNonetime is treated as "leave unchanged," so the patch body sent to Google never carried a new start or end. There is no exception here; the call succeeds and returns the event, so the tool replied with "Successfully updated calendar event" while the time was untouched. A reschedule request silently did nothing. The only path that could change a time wasstart_date/end_date, but those are the search range used to find the event, not its new time, so there was no way to actually move an event.Fix
Add
new_start_timeandnew_end_timeparameters, validate them withparse_iso_with_tz(the same ISO plus timezone checkcreate_calendar_event_tooluses), reject an end that is not after the start, and pass the parsed datetimes into bothupdate_google_calendar_eventcalls:The success message now also reports the new start and end when they are set. A request that does not pass
new_start_timeornew_end_timeparses them asNone, so the call is byte-for-byte the same as before for every non-reschedule edit.Testing
Added
backend/tests/unit/test_calendar_update_event_time.py, registered inbackend/test.sh. The tool lives in a module with a heavy import graph, so the test loadscalendar_tools.pyfrom source under a stub meta-path finder that mocks the heavy leaf deps (database, firebase_admin, google, pinecone, redis, typesense, cachetools) while keepingparse_iso_with_tzand the google_utils chain real, then drives the tool coroutine withprepare_access,get_google_calendar_event, andupdate_google_calendar_eventpatched. Cases covered: a reschedule passes tz-awarestart_timeandend_timewith the requested hours through toupdate_google_calendar_event; supplying onlynew_start_timethreadsstart_timeand leavesend_timeasNone; a naive time with no offset returns an error and never calls the writer; and a source assertion that both update calls (primary and retry) receive the parsed new times. Verified red to green: the test fails on current main and passes with this change.PR status check
No open PR changes this logic. The pass-through of new times added here does not appear anywhere in this file's history, so this is not a previously reverted fix being resubmitted. No filed GitHub issue matches.