Skip to content

fix(backend): keep task reminders in sync when MCP creates, completes, reschedules or deletes a task - #15029

Merged
kodjima33 merged 1 commit into
BasedHardware:mainfrom
singhharsh1708:fix/backend-mcp-task-reminders
Sep 20, 2026
Merged

kodjima33 merged 1 commit into
BasedHardware:mainfrom
singhharsh1708:fix/backend-mcp-task-reminders

Conversation

@singhharsh1708

@singhharsh1708 singhharsh1708 commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #15028

utils/mcp_action_items.py, which both routers/mcp.py and routers/mcp_sse.py use for task writes, never reconciled the phone's local reminders. A task an agent created with a due date never reminded, a task it completed or deleted still reminded, and a due date it moved still fired at the old time. routers/action_items.py calls sync_action_item_reminder for each of these writes.

Each write now calls sync_action_item_reminder through a small _sync_reminder helper:

  • create, when the new task is open and has a due date
  • complete and reopen
  • update, when the due date changed
  • delete, as completed, which sends the cancel

The helper logs and swallows a send failure, so a notification problem never fails the write. sync_action_item_reminder is not a transport entry point, and the notification dispatch boundary check still holds.

Six tests added to tests/unit/test_mcp_action_item_writes.py. On main the create, complete, reschedule and delete cases fail because sync_action_item_reminder is never called. With the fix all 49 tests in the file pass, including a no-due-date create that sends nothing and a send failure that does not fail the delete.

cd backend
python -m pytest tests/unit/test_mcp_action_item_writes.py -q                       # 49 passed
BACKEND_UNIT_TEST_FILE_LIST=<that file> bash test.sh                                 # passed
python3 ../.github/scripts/check_notification_dispatch_boundary.py --base origin/main # ratchet held

Failure-Class: none

Review in cubic

@Git-on-my-level

Copy link
Copy Markdown
Member

Verified this end to end against #15028 — the fix is correct and the PR description matches the code exactly.

backend/utils/mcp_action_items.py

  • The four sync call sites mirror the REST Tasks API semantics from BUG: Receiving Notifications for Already-Completed Tasks #5085: create arms a reminder only for an open task with a due date (same guard as request.due_at and not request.completed in routers/action_items.py), set_completed always reconciles (cancel on complete, re-arm on reopen), update_action_item reconciles when due_at is in the update payload — which matches REST's 'completed' in update_data or 'due_at' in update_data since the MCP update path can't change completion — and delete sends the cancel through the completed=True sentinel, i.e. the same action_item_delete message the REST delete sends.
  • _sync_reminder swallows send failures with logger.exception, so a push problem can never fail the task write — same best-effort posture as the vector upserts around it.
  • Confirmed sync_action_item_reminder is not a derived transport entry point in check_notification_dispatch_boundary.py (it routes through the public wrappers), and ran the checker at this head: 32 legacy direct calls (ratchet held).

backend/tests/unit/test_mcp_action_item_writes.py

  • Ran the file at this head: 49 passed. Then reverted only mcp_action_items.py to main and re-ran: exactly the create/complete/reschedule/delete cases fail (4 failed, 45 passed), so the new tests genuinely pin the behavior. The no-due-date and send-failure cases passing on main is expected — no sync call happens there.
  • Two tiny notes, neither blocking: the create=True on the sync_action_item_reminder patches is unnecessary at this head (the import exists), and on an idempotent-create dedupe (same description retried with a different due date) the reminder syncs to the persisted item's state rather than the rejected request — consistent with what a reload would show, and recoverable with a follow-up update_action_item if a client ever hits it.

No concerns from my side; leaving for maintainer merge consideration.

🤖 Automated review on behalf of the maintainers.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added the backend Backend Task (python) label Sep 20, 2026
@aryanorastar

Copy link
Copy Markdown
Collaborator

Verified on current main (1ef3b91). utils/mcp_action_items.py (used by routers/mcp.py and mcp_sse.py) never calls sync_action_item_reminder. REST Tasks API does on create/complete/reschedule/delete. An MCP-created dated task never reminds; a completed or deleted one still does.

The four call sites match that REST contract, and a send failure is swallowed so the write still succeeds. New tests in test_mcp_action_item_writes.py fail on main for create/complete/reschedule/delete.

I am not merging.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Confirmed sync_action_item_reminder never called from mcp_action_items.py on main; fixes #15028, 49 tests added, CI green. 5/5 confidence.

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

Labels

backend Backend Task (python)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bounty proposal] fix(backend): MCP task writes never create, cancel or move phone reminders ($25 proposed)

4 participants