diff --git a/nanobot/agent/tools/calendar.py b/nanobot/agent/tools/calendar.py index 4943952..3f655ad 100644 --- a/nanobot/agent/tools/calendar.py +++ b/nanobot/agent/tools/calendar.py @@ -179,7 +179,34 @@ class CalendarTool(Tool): coerced["action"] = "list_events" if value == "calendar" else value coerced.pop(key, None) break - + + # Models often omit `action` and pass only a range ("this week", "1 week") under a junk key. + if not coerced.get("action"): + _known_actions = { + "list_events", + "create_event", + "delete_event", + "delete_events", + "update_event", + "check_availability", + "calendar", + } + _create_keys = {"title", "start_time", "end_time", "event_id", "event_ids", "description", "location", "attendees"} + if len(coerced) == 1: + only_k, only_v = next(iter(coerced.items())) + if only_k == "time_min" and isinstance(only_v, str): + coerced["action"] = "list_events" + elif isinstance(only_v, str) and only_k not in _create_keys: + if only_v in _known_actions: + coerced["action"] = "list_events" if only_v == "calendar" else only_v + coerced.pop(only_k, None) + else: + coerced = {"action": "list_events", "time_min": only_v} + else: + coerced["action"] = "list_events" + else: + coerced = {**coerced, "action": "list_events"} + return coerced @property