From 7f6d95c026703835cd72f5613a456b0a4b4eacc7 Mon Sep 17 00:00:00 2001 From: Qiaochu Hu <110hqc@gmail.com> Date: Fri, 6 Mar 2026 20:11:08 +0800 Subject: [PATCH] fix: handle zero values in cron schedule type assertions (#1147) Fixes #1126 Go type assertions return true for zero values, which caused recurring cron jobs (every_seconds/cron_expr) to silently become one-time 'at' tasks when LLMs filled unused optional parameters with default values (0). Changes: - Add validity checks after type assertions: atSeconds > 0, everySeconds > 0, cronExpr != "" - This ensures zero values are treated as 'not set' rather than valid schedule values - Recurring tasks like "remind me every 2 hours" now correctly create recurring jobs --- pkg/tools/cron.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/tools/cron.go b/pkg/tools/cron.go index 31ac9ab88..6af0aa9e1 100644 --- a/pkg/tools/cron.go +++ b/pkg/tools/cron.go @@ -141,6 +141,12 @@ func (t *CronTool) addJob(ctx context.Context, args map[string]any) *ToolResult everySeconds, hasEvery := args["every_seconds"].(float64) cronExpr, hasCron := args["cron_expr"].(string) + // Fix: type assertions return true for zero values, need additional validity checks + // This prevents LLMs that fill unused optional parameters with defaults (0) from triggering wrong type + 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