From 058337486447ef085c8e74ab56c51af894b4e0d4 Mon Sep 17 00:00:00 2001 From: hobostay <110hqc@gmail.com> Date: Thu, 5 Mar 2026 13:00:05 +0800 Subject: [PATCH] Fix: Recurring cron jobs silently become one-time tasks Fixes #1043 Added value validity checks after type assertions to prevent LLMs from inadvertently triggering wrong schedule types. --- pkg/tools/cron.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/tools/cron.go b/pkg/tools/cron.go index 562fffc84..eb98a7b51 100644 --- a/pkg/tools/cron.go +++ b/pkg/tools/cron.go @@ -150,6 +150,13 @@ func (t *CronTool) addJob(args map[string]any) *ToolResult { everySeconds, hasEvery := args["every_seconds"].(float64) cronExpr, hasCron := args["cron_expr"].(string) + // Validate that values are meaningful (not zero/empty) + // This prevents LLMs from setting unused optional params to default values (e.g., at_seconds: 0) + // which would otherwise cause hasAt/hasEvery to be true via Go type assertion + hasAt = hasAt && atSeconds > 0 + hasEvery = hasEvery && everySeconds > 0 + hasCron = hasCron && cronExpr != "" + // Priority: at_seconds > every_seconds > cron_expr if hasAt { atMS := time.Now().UnixMilli() + int64(atSeconds)*1000