MCPcopy
hub / github.com/agent0ai/agent-zero / _validate_task_schedule

Function _validate_task_schedule

tools/scheduler.py:92–96  ·  view source on GitHub ↗
(task_schedule: TaskSchedule)

Source from the content-addressed store, hash-verified

90
91
92def _validate_task_schedule(task_schedule: TaskSchedule) -> str:
93 # Validate cron expression, agent might hallucinate
94 cron_regex = r"^((((\d+,)+\d+|(\d+(\/|-|#)\d+)|\d+L?|\*(\/\d+)?|L(-\d+)?|\?|[A-Z]{3}(-[A-Z]{3})?) ?){5,7})$"
95 crontab = task_schedule.to_crontab()
96 return "" if re.match(cron_regex, crontab) else f"Invalid cron expression: {crontab}"
97
98
99def _task_plan_from_input(plan: Any) -> tuple[TaskPlan | None, str]:

Callers 2

update_taskMethod · 0.85
create_scheduled_taskMethod · 0.85

Calls 2

matchMethod · 0.80
to_crontabMethod · 0.45

Tested by

no test coverage detected