Skip to content

fix(tools): only require a timezone where one is actually needed - #277

Open
marcelklehr wants to merge 1 commit into
mainfrom
fix/timezone-regressions
Open

marcelklehr wants to merge 1 commit into
mainfrom
fix/timezone-regressions

Conversation

@marcelklehr

Copy link
Copy Markdown
Member

Follow-up to #257, from a post-merge review.

Fixes

  • update_scheduled_task overwrote the task's timezone. Every update sent timezone (falling back to the profile timezone), so a prompt-only edit of a task stored in Asia/Tokyo silently moved it to the user's profile zone. For users without a profile timezone, every update raised. It now sends a timezone only when one is passed explicitly, as before fix(tools): require timezone on time tools, inject user timezone into the prompt #257. A naive starts_at is still interpreted in the explicit timezone, or the profile timezone otherwise.
  • create_scheduled_task failed for users without a profile timezone, even when starts_at was omitted. starts_at_timestamp now only resolves a timezone for a starts_at without a UTC offset, so the error only fires when a timezone is actually needed.
  • update_task swallowed the new timezone error. get_timezone() was called inside the bare except: continue, so an invalid or missing timezone came back as False ("task not found"). The timezone is now resolved before the loop.
  • The starts_at docs still used the example 2025-01-01T09:00:00Z after fix(tools): require timezone on time tools, inject user timezone into the prompt #257 removed "use the user's timezone". Since offset-aware values ignore timezone, this pushed the model to send local times as UTC. The example is now naive local time.

Tests

tests/test_timezone_resolution.py, which runs standalone or under pytest. 5 of its 11 tests fail on current main and all pass here. tests/test_schedule_event_payload.py still passes.

Other findings from the review, not addressed here

  • user_timezone_async caches a failed lookup (None) per user for 300s (lib/tz.py).
  • When the user has no email, schedule_event writes the organizer as mailto: (calendar.py).
  • All-day events now use DTEND = end_date + 1, which adds a day for callers that already pass an exclusive end date.
  • schedule_event_sync fetches /cloud/user twice per event. The first fetch has no retry.
  • Timezone validation is written three ways with different fallbacks (agent.py, datetime_info.py, calendar.py).
  • tests/test_schedule_event_payload.py replaces cal.NextcloudApp without restoring it, and has an unused _FakeNc class. assignments.py has an unused pytz import.

🤖 Generated with Claude Code

Follow-up to #257:

- update_scheduled_task sent the profile timezone on every update,
  silently moving tasks stored in another timezone, and failed for
  users without a profile timezone. It now only sends a timezone
  when one is given explicitly.
- create_scheduled_task failed for users without a profile timezone
  even when no starts_at was given. A timezone is now only required
  to interpret a starts_at without UTC offset.
- update_task resolved the timezone inside a bare except, so an
  invalid or missing timezone was swallowed and reported as "task
  not found". It is now resolved before the loop.
- The starts_at docs no longer show a UTC example, which made the
  model send local times with a Z suffix.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
@marcelklehr
marcelklehr requested a review from WSHAPER October 20, 2026 09:48

@WSHAPER WSHAPER left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, however one judgment call to confirm: empty-string timezone now raises where main fell back to the profile. I think the raise is right per the documented contract, but it's a small behavior change beyond the fixes and has no test. Wdyt?

@marcelklehr

Copy link
Copy Markdown
Member Author

I think the raise is right per the documented contract

i agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants