fix(calendar): route read requests to agent (#2452)

This commit is contained in:
nubs
2026-06-05 08:24:04 +00:00
committed by GitHub
parent 2cae5a681d
commit 8b386a172e
2 changed files with 17 additions and 0 deletions

View File

@@ -35,6 +35,7 @@ _CALENDAR_ACTION = (
r"delete|deleting|remove|removing|cancel|cancelling|canceling)"
)
_CALENDAR_THING = r"(?:calendar|calendar\s+(?:entry|item)|event|meeting|appointment|entry|call)"
_CALENDAR_READ_THING = r"(?:calendar|schedule|events?|meetings?|appointments?|classes?)"
_EXPLANATORY_PREFIX = re.compile(
r"^\s*(?:how\s+(?:do|can)\s+i|can\s+you\s+explain|what\s+about|tell\s+me\s+how|show\s+me\s+how)\b",
re.I,
@@ -59,6 +60,14 @@ _ROUTING_PATTERNS: tuple[tuple[str, str, Pattern[str]], ...] = tuple(
("calendar", "calendar target action request", rf"\b{_CALENDAR_ACTION}\b.{{0,120}}\b(?:to|on|in|into|for)\s+(?:my\s+|the\s+|this\s+)?calendar\b"),
("calendar", "put item on calendar request", r"\bput\s+.+\bon\s+(?:my\s+)?calendar\b"),
# Calendar/event lookup. A question such as "Do I have Taekwondo
# classes this week?" needs the calendar tool; plain chat cannot know.
("calendar", "calendar lookup request", rf"\b(?:list|show|check|find)\b.{{0,120}}\b(?:my\s+|the\s+)?(?:upcoming|next|today'?s?|tomorrow'?s?|this\s+week'?s?)\b.{{0,120}}\b{_CALENDAR_READ_THING}\b"),
("calendar", "calendar lookup question", rf"\b(?:what|which)\b.{{0,120}}\b(?:upcoming|next|today'?s?|tomorrow'?s?|this\s+week'?s?)\b.{{0,120}}\b{_CALENDAR_READ_THING}\b"),
("calendar", "calendar availability question", rf"\bdo\s+i\s+have\b.{{0,120}}\b(?:upcoming|next|today|tomorrow|this\s+week)\b.{{0,120}}\b{_CALENDAR_READ_THING}\b"),
("calendar", "calendar agenda question", r"\bwhat(?:'s| is)\s+on\s+(?:my\s+)?calendar\b"),
("calendar", "next calendar item question", r"\bwhen\s+(?:is|are)\s+(?:my\s+)?next\s+(?:event|meeting|appointment|class)\b"),
# Notes, todos, checklists, and reminders.
("notes", "reminder request", r"\bremind\s+me\b"),
("notes", "assistant note/todo action request", rf"{_ACTION_QUESTION}(?:add|create|make|take|jot|write\s+down|set)\b.{{0,120}}\b(?:note|todo|task|checklist|reminder)\b"),

View File

@@ -23,6 +23,14 @@ def test_calendar_imperative_variants_promote_to_agent():
)
def test_calendar_read_requests_promote_to_agent():
assert message_needs_tools("What upcoming events do I have?")
assert message_needs_tools("Can you show my next appointments?")
assert message_needs_tools("Do I have upcoming Taekwondo classes this week?")
assert message_needs_tools("What's on my calendar tomorrow?")
assert message_needs_tools("When is my next meeting?")
def test_note_todo_and_reminder_actions_promote_to_agent():
assert message_needs_tools("add milk to my todo list")
assert message_needs_tools("take a note that the server needs checking")